eyconf.config.base.EYConfBase¶
- class eyconf.config.base.EYConfBase(data: dict | D, schema: type[D] | None = None, allow_additional_properties: bool = False)¶
Base class for EYconf.
Can be used to create custom configuration classes in memory without file I/O.
Attributes
Get the configuration data.
Methods
__init__(data[, schema, ...])Return the configs' defaults (inferred from schema) as yaml.
overwrite(data)Overwrite the configuration with provided data.
reset()Reset the configuration data to the default values.
to_dict([include_additional])Convert the configuration data to a dictionary.
to_yaml()Convert the configuration data to a yaml string.
update(data)Update the configuration with provided data.
validate()Validate the current data against the schema.
- property data: D¶
Get the configuration data.
- default_yaml() str¶
Return the configs’ defaults (inferred from schema) as yaml.
You may overwrite this method to customize the default configuration generation.
- overwrite(data: dict | D)¶
Overwrite the configuration with provided data.
If the provided data is missing required fields, an error will be raised.
- reset()¶
Reset the configuration data to the default values.
- to_dict(include_additional: bool = False) dict¶
Convert the configuration data to a dictionary.
- Parameters:
include_additional (bool) – Whether to include extra data not part of the schema.
- update(data: dict)¶
Update the configuration with provided data.
This applies an partial update to the existing configuration data. Only the provided keys will be updated, others will remain unchanged.
- validate()¶
Validate the current data against the schema.