abscal.common.args¶
This module includes an argument-parsing function which adds common arguments, and accepts additional arguments, then returns the parsed arguments. It is intended to be imported by modules that are run from the command line.
Use¶
This module is intended to be imported for argument parsing:
from abscal.common.args import parse
description = "Description of the sub-module defined in this file"
default_out_file = "default_output_file_name.ext"
arg_list = []
# For each additional (non-common) argument that needs to be available for the
# sub-module, create a list where the first item is a list of the positional arguments
# to argparse.ArgumentParser.add_argument(), and the second item is a dictionary of
# the keyword arguments.
arg = [<positional arguments to add_argument>, <keyword arguments same>]
arg_list.append(arg)
...
res = parse(description, default_out_file, arg_list, **kwargs)
Module Contents¶
Functions¶
|
Create an ArgumentParser, add in the common arguments that everything in ABSCAL uses |
- abscal.common.args.parse(description, default_out_file, arg_list, **kwargs)¶
Create an ArgumentParser, add in the common arguments that everything in ABSCAL uses (along with any custom arguments passed in), parse the provided arguments, and return the results object.
- Parameters:
description (str) – Description of the sub-module to be printed in –help
default_out_file (str) – Name of the default output file produced by the sub-module
arg_list (list) – List of custom arguments, consisting of tuples of (<fixed arguments list>, <keyword argument dict>)
kwargs (dict) –
Keyword parameters, including
- split_output: bool, default True
If multiple output files are created based on some characteristic, set this to True
- Returns:
res – Result of parsing all of the command-line arguments.
- Return type:
populated namespace