Common module: standard_parsers.py

standard_parsers.py

This module contains a set of commands initializing standard argparse.ArgumentParser objects with standard sets of pre-defined options. The idea here is that I have a standard basic parser with set syntax but can also have a ‘cluster parser’ with a set of pre-defined cluster oriented options that can be added to the standard basic parser for scripts that need cluster support, etc etc

module_version:1.0
created_on:2013-04-08

Standard Parsers

script_options.standard_parsers.standard_parser(ver, prog=None, usage=None, description=None, epilog=None, tmpdir=True, infile=True, infiletype='txt', outfile=True)[source]

Set up a command line parser with standard options.

Depending on the options supplied to the function the standard options include an input file, an output file, a log file, a temporary directory a verbosity switch and standard argparse.ArgumentParser version and help switches.

Returns a argparse.ArgumentParser instance and two lists; the first is a list of the positional arguments and their defaults (which should be None), the second is a list of keyword arguments and their defaults. These lists are used by standard_logging.py to give clarity to the logged script options. Note, the destination in the resulting namespace (and in the first value of tuples in the keyword arguments lists) is the same as the long option for all optional arguments; lets try to keep it that way!

Table Of Contents

Previous topic

Common Routines: Argument parsing

Next topic

Common module: custom_callables.py

This Page