Loaders

class confz.loaders.Loader

Bases: abc.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

ConfZUpdateException – 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.

Returns

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

Raises

ConfZUpdateException – If dict keys contradict each other.

abstract classmethod populate_config(config: dict, confz_source: confz.confz_source.ConfZSource)

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

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

  • confz_source – Source configuration.

confz.loaders.register_loader(confz_source: Type[confz.confz_source.ConfZSource], loader: Type[confz.loaders.loader.Loader])

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

Parameters