pg.KeyPathSet¶
Accessible via pg.KeyPathSet, pg.utils.KeyPathSet.
- class KeyPathSet(paths=None, *, include_intermediate=False)[source]¶
Bases:
pg.FormattableA KeyPath set based on trie-like data structure.
Methods:
add(path[, include_intermediate])Adds a path to the set.
clear()Clears the set.
copy()Returns a deep copy of the set.
difference(other)Returns the subset KeyPathSet based on a prefix path.
difference_update(other)Removes the paths in the other set from the current set.
format(*args, **kwargs)Formats the set.
from_value(value[, include_intermediate])Returns a KeyPathSet from a compatible value.
has_prefix(root_path)Returns True if the set has a path with the given prefix.
intersection(other)Returns the intersection KeyPathSet.
intersection_update(other)Removes the paths in the other set from the current set.
rebase(root_path)Returns a KeyPathSet with the given prefix path added.
remove(path)Removes a path from the set.
subtree(root_path)Returns the relative paths of the sub-tree rooted at the given path.
union(other[, copy])Returns the union KeyPathSet.
update(other)Updates the current set with the other set.
- difference_update(other)[source]¶
Removes the paths in the other set from the current set.
- Return type:
- classmethod from_value(value, include_intermediate=False)[source]¶
Returns a KeyPathSet from a compatible value.
- has_prefix(root_path)[source]¶
Returns True if the set has a path with the given prefix.
- Return type:
- intersection_update(other)[source]¶
Removes the paths in the other set from the current set.
- Return type:
- subtree(root_path)[source]¶
Returns the relative paths of the sub-tree rooted at the given path.
- Return type:
- Parameters:
root_path – A KeyPath for the root of the sub-tree.
- Returns:
A KeyPathSet that contains all the child paths of the given root path. Please note that the returned value share the same trie as the current value. So addition/removal of paths in the returned value will also affect the current value. If there is no child path under the given root path, None will be returned.