darbia.utils.mappings
#
Assorted utility functions.
Module Contents#
Functions#
|
Compare two different dictionaries. |
Parse nested values from dictionaries. |
|
|
Create a dict of chains of keys from sequential dicts. |
Attributes#
- darbia.utils.mappings.dict_compare(old_dict: dict[Any, Any], new_dict: dict[Any, Any]) tuple[list[Any], list[Any], dict[Any, Any], list[Any]] [source]#
Compare two different dictionaries.
- Parameters:
- Returns:
Comparison results
- Return type:
Examples
>>> dict_compare(old_dict=dict(), new_dict=dict()) ([], [], {}, [])
Notes
- darbia.utils.mappings.get_nested_dict_value(dct: dict, keypath: str, default: T = None, separator: str = '.') T [source]#
Parse nested values from dictionaries.
- Parameters:
dct – The dictionary to search
keypath – The path of keys to check through
default – The default value to return if the value is not found
separator – The character used to split the keypath
- Return type:
The value at the keypath or the default value
Examples
>>> get_nested_dict_value({"key": {"path": "value"}}, "key.path") 'value'
- darbia.utils.mappings.keychain(dicts: list[dict]) dict [source]#
Create a dict of chains of keys from sequential dicts.
- Parameters:
dicts – The list of dictionaries to chain
- Return type:
A dictionary of lists of all chains
Notes
https://discord.com/channels/267624335836053506/587375768556797982/1044549320948584528