cdm_data_loaders.utils.paths ¶
Generic nested dictionary path operations.
NestedPathError ¶
set_nested ¶
Set a leaf through a nonempty sequence of string keys, creating missing dicts.
Existing leaves are replaced, including dicts and lists. Empty string keys are valid. Intermediate values must be dicts; collisions fail without mutation. The assigned value is not copied. A string alone is not a path sequence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
dict[str, Any]
|
dictionary to mutate in place |
required |
path
|
Sequence[str]
|
nonempty sequence of string keys leading to the leaf |
required |
value
|
object
|
value to assign at the leaf key |
required |
Raises:
| Type | Description |
|---|---|
NestedPathError
|
if |