deeppath package

Module contents

Top-level package for deeppath.

deeppath.dget(data: Mapping[str, Any], path: str, default: Optional[Any] = None) → Union[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[KT, VT], path: str, value: Any) → None[source]

Set a key in a deeply nested structure

deeppath.dwalk(data: Dict[str, Any]) → Generator[Tuple[str, Mapping[KT, VT_co]], None, None][source]

Generator that will 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]