Adding config sources¶
To add config sources to a ConfigParser
, use ConfigParser.add_source()
method:
-
ConfigParser.
add_source
(source, *args, **kwargs) Add a new config source to the
ConfigParser
.The only argument required for all sources is the
source
parameter which may be the name of a source or a class that implements a source. Other arguments are passed on to the class that implements the source.The built-in sources are:
argparse
: for getting config values from the command line using anargparse.ArgumentParser
.simple_argparse
: a simpler version of theargparse
source that is easier to use but doesn’t allow you to add any arguments that aren’t also config items.environment
: for getting config values from environment variables.json
: for getting config values from JSON files.dict
: for getting config values from Python dictionaries.
See Sources for more information about the built-in sources and creating your own sources.
Return the created config source object.