class ConfigFileParser: (source)
Known subclasses: configargparse.CompositeConfigParser, configargparse.ConfigparserConfigFileParser, configargparse.DefaultConfigFileParser, configargparse.IniConfigParser, configargparse.TomlConfigParser, configargparse.YAMLConfigFileParser
This abstract class can be extended to add support for new config file formats
| Method | get |
Returns a string describing the config file syntax. |
| Method | parse |
Parses the keys and values from a config file. |
| Method | process |
This function may be overridden in custom ConfigFileParser subclasses to allow for modification or values or other side effects when a value is found in a config file. |
| Method | serialize |
Does the inverse of config parsing by taking parsed values and converting them back to a string representing config file contents. |
| Method | _process |
Ensure that all (possibly altered) values really are strings, or list of strings, or None, in order to update the collection of values. |
configargparse.CompositeConfigParser, configargparse.ConfigparserConfigFileParser, configargparse.DefaultConfigFileParser, configargparse.IniConfigParser, configargparse.TomlConfigParser, configargparse.YAMLConfigFileParserReturns a string describing the config file syntax.
configargparse.CompositeConfigParser, configargparse.ConfigparserConfigFileParser, configargparse.DefaultConfigFileParser, configargparse.IniConfigParser, configargparse.TomlConfigParser, configargparse.YAMLConfigFileParserParses the keys and values from a config file.
Note
For keys that were specified to configargparse as action="store_true" or "store_false", the config file value must be one of: "yes", "no", "on", "off", "true", "false", "1", "0". Otherwise an error will be raised.
| Parameters | |
stream:IO | A config file input stream (such as an open file object). |
| Returns | |
OrderedDict | Items where the keys are strings and the values are either strings or lists (eg. to support config file formats like YAML which allow lists). |
This function may be overridden in custom ConfigFileParser subclasses to allow for modification or values or other side effects when a value is found in a config file.
- Your function must return a dict. The default return value is simply:
- {key: value}
You may add more items to set config values other than original key. The returned dict value should be a list, or None to skip the item, or anything else will be turned into a string.
configargparse.ConfigparserConfigFileParser, configargparse.DefaultConfigFileParser, configargparse.YAMLConfigFileParserDoes the inverse of config parsing by taking parsed values and converting them back to a string representing config file contents.
| Parameters | |
| items | an OrderedDict of items to be converted to the config file format. Keys should be strings, and values should be either strings or lists. |
| Returns | |
| Contents of config file as a string |