deeppath.deeppath module#
Support some XPath-like syntax for accessing nested structures.
- 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.deeppath.dset(data: MutableMapping[str, Any], path: str, value: Any) None[source]#
Set a key in a deeply nested structure.