ocebuild.parsers.dict
#
Dictionary helper functions.
Module Contents#
Functions#
|
Flattens a dictionary. |
|
Retrieves a nested value from a dictionary. |
|
Sets a nested value in a dictionary. |
|
Deletes a nested value in a dictionary. |
|
Merges two dictionaries recursively. |
- ocebuild.parsers.dict.flatten_dict(dic: dict, delimiter: str = '.') Dict[str, any] [source]#
Flattens a dictionary.
- Parameters:
dic – The dictionary to flatten.
delimiter (optional) – custom key delimiter.
- Returns:
A flattened dictionary
- ocebuild.parsers.dict.nested_get(dic: dict, keys: List[str], default: any | None = None) dict | any | None [source]#
Retrieves a nested value from a dictionary.
- Parameters:
dic – The dictionary to retrieve the value from.
keys – The keys to traverse the dictionary.
- Returns:
The value at the end of the keys list.
- ocebuild.parsers.dict.nested_set(dic: dict, keys: List[str], value: any) None [source]#
Sets a nested value in a dictionary.
- Parameters:
dic – The dictionary to set the value in.
keys – The keys to traverse the dictionary.
value – The value to set.