config
¶
Read e3 config file.
Module Contents¶
Classes¶
Load e3 configuration file and validate each section. |
Attributes¶
- config.CONFIG_CHECK_TYPE = True¶
- config.T¶
- config.KNOWN_CONFIG_FILES¶
- class config.ConfigSection¶
- title: ClassVar[str]¶
- classmethod load() T ¶
Load a section of the configuration file.
To load a new section, subclass ConfigSection and document the fields that you expect to parse, e.g.:
@dataclass class MyConfig(ConfigSection): title = "my_config_subsection" option : str = "default value"
my_config = MyConfig.load()
If the package typeguard is installed type defined in the metaclass will be verified.
- class config.Config¶
Load e3 configuration file and validate each section.
This class expose the .load_section(<section>, <dataclass>) method that can be used by ConfigSection instance corresponding to the loaded configuration section after validation.
Note that without the tomlkit package the configuration is not read.
- data: ClassVar[dict]¶
- classmethod load_section(section: str) dict ¶
Load a configuration section content.
- Parameters:
section –
if contains “.” nested subsection will be found. For instance “log.fmt” will return the section:
- [log]
[log.fmt]
- Returns:
the configuration dict
- classmethod load_file(filename: str) None ¶
Load the configuration file(s).
Note that this method is automatically loaded the first time .get() is called.
- Parameters:
filename – configuration file to load
- classmethod load() None ¶
Load the configuration file(s).
Note that this method is automatically loaded the first time .get() is called.
- Parameters:
filename – if not None load this configuration file instead of the default config files