deeppath package#

Submodules#

Module contents#

Top-level package for deeppath.

deeppath.dget(data: Mapping[str, Any], path: str, default: Any | None = None) list[Any] | Any[source]#

Match a path in a deep container.

data should be a mapping of str to values, other mappings or sequences path is a /-separated list of keywords representing the path inside our container default will be returned if the path does not match and is not using any wildcards

This function will return a single value if no wildcard (*) is used in the path. If a wildcard is used, it will return a list of matching elements (so possibly an empty list).

deeppath.dset(data: MutableMapping[str, Any], path: str, value: Any) None[source]#

Set a key in a deeply nested structure.

deeppath.dwalk(data: dict[str, Any]) Generator[tuple[str, Mapping[str, Any]], None, None][source]#

Yield values for each path to a leaf of a nested structure.

deeppath.flatten(nested_iterable: Iterable[Any]) list[Any][source]#

Flattens a nested list.

E.g [[[[[1]]]],[2]] -> [1,2].