pg.KeyPathSet

Accessible via pg.KeyPathSet, pg.utils.KeyPathSet.

class KeyPathSet(paths=None, *, include_intermediate=False)[source]

Bases: pg.Formattable

A 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.

add(path, include_intermediate=False)[source]

Adds a path to the set.

Return type:

bool

clear()[source]

Clears the set.

Return type:

None

copy()[source]

Returns a deep copy of the set.

Return type:

pg.KeyPathSet

difference(other)[source]

Returns the subset KeyPathSet based on a prefix path.

Return type:

pg.KeyPathSet

difference_update(other)[source]

Removes the paths in the other set from the current set.

Return type:

None

format(*args, **kwargs)[source]

Formats the set.

Return type:

str

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:

bool

intersection(other)[source]

Returns the intersection KeyPathSet.

Return type:

pg.KeyPathSet

intersection_update(other)[source]

Removes the paths in the other set from the current set.

Return type:

None

rebase(root_path)[source]

Returns a KeyPathSet with the given prefix path added.

Return type:

None

remove(path)[source]

Removes a path from the set.

Return type:

bool

subtree(root_path)[source]

Returns the relative paths of the sub-tree rooted at the given path.

Return type:

Optional[pg.KeyPathSet]

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.

union(other, copy=False)[source]

Returns the union KeyPathSet.

Return type:

pg.KeyPathSet

update(other)[source]

Updates the current set with the other set.

Return type:

None