UrbanHeatPro.Functions.uhp_utils

Module Contents

Functions

nested_get(→ Any)

Get value from nested dictionary given a list of nested keys and return default for missing keys.

access_config_or_default(→ Any)

Get the value for a given configuration parameter and use the default configuration value if the configuration

UrbanHeatPro.Functions.uhp_utils.nested_get(input_dict: dict, nested_key: list, not_there='NotThere') Any[source]

Get value from nested dictionary given a list of nested keys and return default for missing keys.

Parameters:
  • input_dict (dict) – Nested dictionary.

  • nested_key (list) – List of keys to access from outer dictionary to inner.

  • not_there – Default value to be returned in case key does not exist

Returns:

Value for the given list of keys. If a key is not available, then returns the default value.

Return type:

Any

UrbanHeatPro.Functions.uhp_utils.access_config_or_default(config: dict, default_config: dict, nested_key) Any[source]

Get the value for a given configuration parameter and use the default configuration value if the configuration parameter is not in the configuration there.

Parameters:
  • config (dict) – Nested dictionary.

  • default_config (dict) –

  • nested_key – List of keys to access from outer dictionary to inner.

Returns:

Configuration value for the given list of keys. If a key is not available, raises a KeyError.

Return type:

Any