scripter API

Warning

Do not use private methods, they may change or disappear in future releases.

Classes

class scripter.Environment(doc=None, version='', handle_files=True)[source]

the base class for scripter

provides an execution environment for jobs

__init__(doc=None, version='', handle_files=True)[source]
_build_default_parser(doc=None, version='', add_help=True)[source]

build the default ArgumentParser

_construct_target(name=None)[source]
static _is_valid_dir(f)[source]

checks if a directory is valid

_is_valid_file(f)[source]

checks if a file is valid for processing

_update_sequence(files=[], recursive=False, **kwargs)[source]

updates _sequence with files specified at command line (wildcards ok)

do_action(action, stay_open=False)[source]

executes an action

actions should be functions that at least take FilenameParser objects

execute_next_script()[source]

execute the next script

get_context(force_new=False)[source]
get_filename_parser(**kwargs)[source]

returns the class being used as the filename parser

if more kwargs are supplied, then partial is used to apply arguments as appropriate

get_sequence(**kwargs)[source]

returns the sequence of FilenameParser objects for action

Running this more than once will not do anything

get_target_dir(name=None)[source]
override_num_cpus(num)[source]

override the number of processes we’re going to start

set_config_reader(reader)[source]

will be called as reader(vars(parser.parse_args())[‘config’])

set_config_writer(writer)[source]

will be called as writer(**parser.parse_args())

set_filename_parser(filename_parser)[source]

use the provided filename parser instead of the default one

update_context(update_dict)[source]
class scripter.FilenameParser(filename, drop_parent_name=True, target_dir=None, no_target=False, *args, **kwargs)[source]

The default FilenameParser class included with scripter

its one mandatory argument is a filename it must accept arbitrary **kwargs or it will be very unhappy

It is recommend you customize this class for parsing filenames as needed

__init__(filename, drop_parent_name=True, target_dir=None, no_target=False, *args, **kwargs)[source]
check_output_dir(output_dir)[source]
set_input_file(filename)[source]
with_extension(ext)[source]

Path to output file with extension

class scripter.AnnounceExitFilter(announce_exit)[source]

rejects messages announcing thread exit iff the initial condition is False

looks for specific messages hardcoded into multiprocessing/pool.py see source for more details

__init__(announce_exit)[source]
filter(record)[source]

Exceptions

class scripter.InvalidFileException(arg=None)[source]

Bases: exceptions.ValueError

Exception for files that do not return a valid FilenameParser object

class scripter.Usage(*args)[source]

Bases: exceptions.Exception

Decorators

scripter.exit_on_Usage(func)[source]

exit_on_Usage is a decorator that cause functions raising Usage to exit nicely

Functions

scripter.assert_path(path)[source]

if path does not exist, raise IOError

scripter.extend_buffer(b, x, spacerlines=0)[source]

extends buffer b with string x, ignores if x is None

scripter.get_logger(level=WARNING) wraps multiprocessing.get_logger()[source]

adds an AnnounceExitFilter to prevent output from getting very garbled at program exit

scripter.is_valid_executable(filename)[source]

checks if a filename is a valid executable

scripter.leaves(dir_or_file, allow_symlinks=True, ignore_hidden_files=True, max_depth=None)[source]

takes as input a VALID path and descends into all directories

WARNING: this will get caught in an infinite loop if you have a symlink which references a node above itself in tree

scripter.path_to_executable(name, directories=None, max_depth=2, environ=None)[source]

construct the path to the executable, search in order

the directory specified (or any directory that matches with Unix
style pathname pattern expansion*)

then env PATH then the current directory then give up

*we reverse the order so that we will usually get the newest version

scripter.pformat_list(L)[source]

Takes a list and turns each item into a str then returns the pretty-printed version of that list

scripter.valid_directories(directory)[source]

wrapper for glob.glob, enforces that output must be a valid directory

scripter.valid_int(thing, msg, vmin, vmax)[source]

checks if something is a valid integer and thing >= vmin and thing <= vmax

returns the thing as an integer

Indices and tables

Table Of Contents

Previous topic

Default command-line options

This Page