qwikstart.utils.dict_utils module¶
-
qwikstart.utils.dict_utils.
get_nested_dict_value
(nested_dict: Dict[str, Any], nested_key: str, separator: str = '.') → Any¶
-
qwikstart.utils.dict_utils.
merge_nested_dicts
(default: Mapping[str, Any], overwrite: Mapping[str, Any], inplace: bool = False) → Dict[str, Any]¶ Return new dictionary from the combination of
default
andoverwrite
.Dict values that are dictionaries themselves will be updated, whilst preserving existing keys.
- Parameters
default – Dictionary containing default values
overwrite – Dictionary containing values that will overwrite default values.
inplace – If True, the
default
dictionary will be modified in-place. Otherwise, a new dictionary will be returned.
Adapted from
cookiecutter.config.merge_configs
.
-
qwikstart.utils.dict_utils.
pop_nested_dict_value
(nested_dict: Dict[str, Any], nested_key: str, separator: str = '.') → Any¶
-
qwikstart.utils.dict_utils.
remap_dict
(original_dict: Mapping[str, Any], key_mapping: Mapping[str, str], nested_key_separator: str = '.') → Dict[str, Any]¶ Return dict with any keys in
key_mapping
renamed.- Parameters
original_dict – Dictionary with keys to be renamed.
key_mapping – Dictionary mapping keys in
original_dict
to new keys. Any keys not inkey_mapping
are returned unchanged.nested_key_separator – Separator used in keys in
key_mapping
to specify nested dictionaries.
-
qwikstart.utils.dict_utils.
set_nested_dict_value
(nested_dict: Dict[str, Any], nested_key: str, value: Any, separator: str = '.') → None¶