dict_from_flat_dict

dict_from_flat_dict#

tollan.utils.dict.dict_from_flat_dict(dct: dict[str, Any]) dict[str, Any][source]#

Convert flat dict with dotted keys to nested dict structure.

Uses rupdate to merge each key one at a time, handling conflicts automatically through rupdate’s merging logic.

Examples

>>> dict_from_flat_dict({'a.b': 1, 'a.c': 2})
{'a': {'b': 1, 'c': 2}}
>>> dict_from_flat_dict({'items.0': 1, 'items.1': 2})
{'items': {'0': 1, '1': 2}}
Parameters:

dct (dict) – Flat dictionary with dotted keys

Returns:

Nested dict with rupdate DSL patterns applied

Return type:

dict