funpack.config
This module contains functions for parsing funpack
command line
arguments and configuration files.
A funpack
configuration file is simply a plain-text file which contains
command-line options, sans-hyphens.
- funpack.config.loadConfigFile(cfgfile, namespace=None)[source]
Loads arguments from the given configuration file, returning an
argparse.Namespace
object.- Parameters:
cfgfile – Path to configuration file
namespace – Existing
argparse.Namespace
object to merge arguments into.
- funpack.config.makeEpilog()[source]
Generates an epilog for the command line help.
The epilog contains an overview of available plugin functions.
- funpack.config.makeParser(include=None, exclude=None)[source]
Creates and returns an
argparse.ArgumentParser
for parsingfunpack
command line arguments.- Parameters:
include – Configure the parser so it only includes the specified arguments.
exclude – Configure the parser so it excludes the specified arguments - this overrides
include
.
- funpack.config.parseArgs(argv=None, namespace=None)[source]
Parses
funpack
command line arguments.- Parameters:
argv – List of arguments to parse.
namespace – Existing
argparse.Namespace
- if not provided, an empty one will be created.
- Returns:
A tuple containing:
an
argparse.Namespace
object containing the parsed command-line arguments.A list of the original arguments that were parsed.
- funpack.config.parseArgsWithConfigFile(argv=None)[source]
Checks the command line arguments to see if one or more configuration files has been specified. If so, loads the arguments in the configuration file(s), and then parses the rest of the command line arguments.
- Returns:
see
parseArgs()
.
- funpack.config.sanitiseArgs(argv)[source]
Sanitises command-line arguments to work around a bug in
argparse
.The
argparse
module does not work with non-numeric optional argument values that begin with a hyphen, as it thinks that they are argument names (see https://bugs.python.org/issue9334).This function searches for relevant optional argument names, and prepends a space to their values to make sure that
argparse
doesn’t fall over.- Parameters:
argv – Command-line arguments
- Returns:
Sanitised command-line arguments