tracktable.script_helpers.argparse module¶
Module contents¶
Customized version of argparse with Response Files
Regular argparse has some support for response files but they’re pretty bare. There’s nowhere to put comments, for example. This subclass enhances that. It adds a few capabilities:
Argument Groups - Use a group of thematically-related arguments all at once instead of having to insert them one by one
Response Files - Response files can have comments in them. They will be automatically parsed from the command line.
–write-response-file - Like –help, this will write an example response file and then exit.
- class tracktable.script_helpers.argparse.ArgumentParser(add_response_file=True, fromfile_prefix_chars='@', prefix_chars='-', comment_character='#', conflict_handler='resolve', **kwargs)[source]¶
Bases:
argparse.ArgumentParser
Enhanced version of the standard Python ArgumentParser.
- comment_character¶
This character indicates that a line in a response file should be ignored.
- Type
ORIGINAL ARGPARSE DOCUMENTATION:
Object for parsing command line strings into Python objects.
- Keyword Arguments
(Default (- usage -- A usage message) – sys.argv[0])
(Default – auto-generated from arguments)
does (- description -- A description of what the program) –
descriptions (- epilog -- Text following the argument) –
one (- parents -- Parsers whose arguments should be copied into this) –
messages (- formatter_class -- HelpFormatter class for printing help) –
arguments (- argument_default -- The default value for all) –
containing (- fromfile_prefix_chars -- Characters that prefix files) – additional arguments
arguments –
conflicts (- conflict_handler -- String indicating how to handle) –
option (- add_help -- Add a -h/-help) –
- write_response_file(out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]¶
Write an example response file
Write a response file with every line commented out to the specified file-like object. It will be populated with every argument (positional and optional) that has been configured for this parser including descent into any argument groups. The ‘–help’ and ‘–write-response-file’ arguments will be omitted.
- Keyword Arguments
out (File) – File-like object for output (Default: sys.stdout)
- Returns
No return value