A drop-in replacement for argparse
that allows options to also be set via config files and/or environment variables.
See Also | |
configargparse.ArgumentParser , configargparse.add_argument |
Class |
|
HelpFormatter that adds default values AND doesn't do line-wrapping |
Class |
|
Drop-in replacement for argparse.ArgumentParser that adds support for environment variables and .ini or .yaml-style config files. |
Class |
|
Createa a config parser composed by others `ConfigFileParser`s. |
Class |
|
This abstract class can be extended to add support for new config file formats |
Class |
|
parses INI files using pythons configparser. |
Class |
|
Based on a simplified subset of INI and YAML formats. Here is the supported syntax |
Class |
|
Create a INI parser bounded to the list of provided sections. Optionaly convert multiline strings to list. |
Class |
|
Create a TOML parser bounded to the list of provided sections. |
Class |
|
Parses YAML config files. Depends on the PyYAML module. https://pypi.python.org/pypi/PyYAML |
Exception |
|
Raised when config file parsing failed. |
Function | add |
This method supports the same args as ArgumentParser.add_argument(..) as well as the additional args below. |
Function | already |
Utility method for checking if any of the potential_command_line_args is already present in existing_args. |
Function | get |
Returns the global ArgumentParser instance with the given name. The 1st time this function is called, a new ArgumentParser instance will be created for the given name, and any args other than "name" will be passed on to the ArgumentParser constructor. |
Function | get |
Given some TOML data (as loaded with toml.load() ), returns the requested section of the data. Returns None if the section is not found. |
Function | init |
Creates a global ArgumentParser instance with the given name, passing any args other than "name" to the ArgumentParser constructor. This instance can then be retrieved using get_argument_parser(..) |
Function | is |
Detect whether a string is a quoted representation. |
Function | parse |
Parse a TOML section name to a sequence of strings. |
Function | unquote |
Unquote a maybe quoted string representation. If the string is not detected as being a quoted representation, it returns the same string as passed. It supports all kinds of python quotes: """, ''', " and ... |
Constant | ACTION |
Undocumented |
Variable | is |
Undocumented |
Constant | _COMMAND |
Undocumented |
Constant | _CONFIG |
Undocumented |
Constant | _DEFAULTS |
Undocumented |
Constant | _ENV |
Undocumented |
Constant | _QUOTED |
Undocumented |
Constant | _TRIPLE |
Undocumented |
Variable | _parsers |
Undocumented |
This method supports the same args as ArgumentParser.add_argument(..) as well as the additional args below.
Parameters | |
self | Undocumented |
*args | Undocumented |
**kwargs | Undocumented |
env | If set, the value of this environment variable will override any config file or default values for this arg (but can itself be overridden on the commandline). Also, if auto_env_var_prefix is set in the constructor, this env var name will be used instead of the automatic name. |
is | If True, this arg is treated as a config file path This provides an alternative way to specify config files in place of the ArgumentParser(fromfile_prefix_chars=..) mechanism. Default: False |
is | If True, this arg will be treated as a config file path, and, when it is specified, will cause configargparse to write all current commandline args to this file as config options and then exit. Default: False |
Returns | |
argparse.Action | the new argparse action |
Utility method for checking if any of the potential_command_line_args is already present in existing_args.
Returns | |
bool | already on command line? |
Returns the global ArgumentParser instance with the given name. The 1st time this function is called, a new ArgumentParser instance will be created for the given name, and any args other than "name" will be passed on to the ArgumentParser constructor.
Given some TOML data (as loaded with toml.load()
), returns the requested section of the data.
Returns None if the section is not found.
Creates a global ArgumentParser instance with the given name, passing any args other than "name" to the ArgumentParser constructor. This instance can then be retrieved using get_argument_parser(..)
Detect whether a string is a quoted representation.
Parameters | |
text | Undocumented |
triple | Also match tripple quoted strings. |
Parse a TOML section name to a sequence of strings.
The following names are all valid:
"a.b.c" # this is best practice -> returns ("a", "b", "c") " d.e.f " # same as [d.e.f] -> returns ("d", "e", "f") " g . h . i " # same as [g.h.i] -> returns ("g", "h", "i") ' j . "ʞ" . "l" ' # same as [j."ʞ"."l"], double or simple quotes here are supported. -> returns ("j", "ʞ", "l")
Unquote a maybe quoted string representation. If the string is not detected as being a quoted representation, it returns the same string as passed. It supports all kinds of python quotes: """, ''', " and '.
- @raises ValueError: If the string is detected as beeing quoted but literal_eval() fails to evaluate it as string.
- This would be a bug in the regex.
Parameters | |
text | Undocumented |
triple | Also unquote tripple quoted strings. |
Undocumented
Value |
|