yera._internal.path_tree

Reusable dotted-path object trees.

Symbols

class PathTree — A navigable tree whose leaves are addressed by dotted paths.

PathTree

Inherits: Generic[TLeaf]

A navigable tree whose leaves are addressed by dotted paths.

Methods

__contains__ — Return whether a dotted path resolves within the tree.
__getitem__ — Resolve a leaf or branch by dotted path.
__dir__ — Return public branches and leaves for interactive discovery.

PathTree.__contains__

__contains__(
    path: str,
) → bool

Return whether a dotted path resolves within the tree.

Parameters

path
type: str

Dot-delimited path to test.

Returns

type: bool

True when the path resolves to a branch or leaf.

PathTree.__getitem__

__getitem__(
    path: str,
) → TLeaf | PathTree[TLeaf]

Resolve a leaf or branch by dotted path.

Parameters

path
type: str

Dot-delimited path to resolve.

Returns

type: TLeaf | PathTree[TLeaf]

The matching leaf or intermediate tree branch.

Raises

KeyError

If any path component does not exist.

PathTree.__dir__

__dir__() → list[str]

Return public branches and leaves for interactive discovery.

Returns

type: list[str]

Public instance and class attribute names.