yaloader.ConfigLoader#
- class yaloader.ConfigLoader(yaml_loader: ~typing.Type[~yaloader.loader.YAMLConfigLoader] = <class 'yaloader.loader.YAMLConfigLoader'>, cacheing: bool = True)[source]#
Bases:
objectThe loader which will keep track of all loaded yaml configs.
- add_config(config_with_priority: ConfigWithPriority)[source]#
Add a config object together with its priority to the loader.
- add_config_data(config_data: List[Dict | List], priority=None)[source]#
Add multiple configs or priorities.
- add_single_config_string(string: str, priority)[source]#
Add a yaml string with a single config object.
- construct_from_file(file_path: Path, final: bool = True)[source]#
Construct the configuration for a yaml file with a single yaml config.
- construct_from_string(string: str, final: bool = True)[source]#
Construct the configuration for a yaml string with a single yaml config.
- deep_construct_from_config(config: YAMLBaseConfig, final: bool = False) Any[source]#
Deeply construct the config based on a config object.
- Parameters:
config – The config which should be constructed
final – If False missing values will be ignored
- Returns:
The constructed config
- flat_construct_from_config(config: YAMLBaseConfig) YAMLBaseConfig[source]#
Construct the config based on a config object.
- Parameters:
config – The config which should be constructed
- Returns:
The constructed config
- flat_construct_from_tag(tag: str) YAMLBaseConfig[source]#
Construct the config for a tag.
This is not deep. If the config contains another config the included one is NOT constructed!
- This includes inheritance as following:
explict set fields go over not explict set fields
local field go over inherited fields
inherited explict field goes over local not explict field
if there are multiple base classes the most left is most important
for multiple yaml configs high priority goes over low priority
for multiple yaml configs with same priority order matters
- Parameters:
tag – The tag of the config which should be constructed
- Returns:
The constructed config
- load_directory(directory_path: Path, priority: int | None = None)[source]#
Load all files ending with .yaml from a directory.
- load_file(file_path: Path, priority: int | None = None)[source]#
Load a yaml file including multiple configs or priorities.
- load_string(string, priority: int | None = None)[source]#
Load a yaml string including multiple configs or priorities.
- static update_config_attributes(config_attributes: dict, config_updates: List[YAMLBaseConfig], explicit: bool) None[source]#
Add config attributes from update configs to the current config attributes.
If the field already exists overwrite it. So config_updates are lowest priority first.
- Parameters:
config_attributes – Dict of existing attributes of the config
config_updates – List of configs from which the attributes should be updated
explicit – If True use only explicit attributes. Else use only not explicit ones.