cfgrw.formats package¶
Submodules¶
cfgrw.formats.envvar module¶
Environment variable configuration reader.
Reference: https://en.wikipedia.org/wiki/Environment_variable
- cfgrw.formats.envvar.read_values(props: list, opts: dict) dict[source]¶
Read property values from environment variables.
Each property name is upper-cased and prepended with
opts["prefix"]to form the environment variable name, e.g. propertylevelwith prefixAPP_resolves toAPP_LEVEL. Properties whose environment variable is not set are omitted from the result.- Parameters:
props (list[str]) – Property names to read.
opts (dict) –
Reader options. Required key:
prefix(str) — prefix prepended to each upper-cased property name.
- Returns:
Mapping of property names to their environment variable values for all found properties.
- Return type:
dict
cfgrw.formats.ini module¶
INI file configuration reader.
Reference: https://en.wikipedia.org/wiki/INI_file
- cfgrw.formats.ini.read_values(conf_stream: object, props: list, opts: dict) dict[source]¶
Read property values from an INI file.
Only properties present under the specified section are included in the result.
- Parameters:
conf_stream (IO[str]) – Readable stream of the INI file content.
props (list[str]) – Property names to read.
opts (dict) –
Reader options. Required key:
section(str) — INI section name to read properties from.
- Returns:
Mapping of property names to their values for all found properties.
- Return type:
dict
cfgrw.formats.json module¶
JSON file configuration reader.
Reference: https://www.json.org/
- cfgrw.formats.json.read_values(conf_stream: object, props: list, opts: dict) dict[source]¶
Read property values from a JSON file.
Only top-level keys matching the requested property names are included in the result.
- Parameters:
conf_stream (IO[str]) – Readable stream of the JSON file content.
props (list[str]) – Property names to read.
opts (dict) – Reader options (unused for JSON).
- Returns:
Mapping of property names to their values for all found properties.
- Return type:
dict
cfgrw.formats.xml module¶
XML file configuration reader.
Reference: https://www.w3.org/XML/
- cfgrw.formats.xml.read_values(conf_stream: object, props: list, opts: dict) dict[source]¶
Read property values from an XML file.
Each property name is matched against direct child elements of the root node. Only elements that exist are included in the result.
- Parameters:
conf_stream (IO[str]) – Readable stream of the XML file content.
props (list[str]) – Property names to read.
opts (dict) – Reader options (unused for XML).
- Returns:
Mapping of property names to their element text values for all found properties.
- Return type:
dict
cfgrw.formats.yaml module¶
YAML file configuration reader.
Reference: https://yaml.org/
- cfgrw.formats.yaml.read_values(conf_stream: object, props: list, opts: dict) dict[source]¶
Read property values from a YAML file.
Only top-level keys matching the requested property names are included in the result. An empty YAML document returns an empty dict without error.
- Parameters:
conf_stream (IO[str]) – Readable stream of the YAML file content.
props (list[str]) – Property names to read.
opts (dict) – Reader options (unused for YAML).
- Returns:
Mapping of property names to their values for all found properties.
- Return type:
dict
Module contents¶
Configuration format readers for INI, JSON, XML, YAML, and environment variables.