Loaders

class confz.loaders.Loader

Bases: ABC

An abstract base class for all config loaders.

classmethod update_dict_recursively(original_dict: Dict, update_dict: Dict)

Updates the original dict with the new data. Similar to dict.update(), but works with nested dicts.

Parameters:
  • original_dict – The original dictionary to update in-place.

  • update_dict – The new data.

Raises:

UpdateException – If dict keys contradict each other.

classmethod transform_nested_dicts(dict_in: Dict[str, Any], separator: str = '.') Dict[str, Any]

Transform dictionaries into nested dictionaries, using a separator in the keys as hint.

Parameters:
  • dict_in – A dictionary with string-keys.

  • separator – The string used to separate dict keys. Default value will no longer be set in a future release.

Returns:

The transformed dictionary, splitting keys at the separator and creating a new dictionary out of it.

Raises:

UpdateException – If dict keys contradict each other.

abstract classmethod populate_config(config: dict, config_source)

Populate the config-dict with new config arguments based on the source.

Parameters:
  • config – Config dictionary, gets extended with new arguments

  • config_source – Source configuration.

confz.loaders.register_loader(config_source: Type[ConfigSource], loader: Type[Loader])

Register a ConfigSource with a specific loader. Can be used to extend ConfZ with own loaders.

Parameters: