polymerist.genutils.trees.treebase
Interfaces for encoding arbitrary classes into tree-like data structures
Attributes
Classes
Abstract base for implementing how to build an anytree Node tree for an arbitrary class |
Functions
|
Factory method for producing a tree-generating function from a NodeCorrespondence |
Module Contents
- polymerist.genutils.trees.treebase.T
- class polymerist.genutils.trees.treebase.NodeCorrespondence[source]
Bases:
abc.ABC,Generic[T]Abstract base for implementing how to build an anytree Node tree for an arbitrary class
- polymerist.genutils.trees.treebase.compile_tree_factory(node_corresp: NodeCorrespondence[T], class_alias: str | None = None, obj_attr_name: str | None = None, exclude_mixin: polymerist.genutils.filters.Filter[T] | None = None) Callable[[T, int | None, polymerist.genutils.filters.Filter[T] | None], anytree.node.Node][source]
Factory method for producing a tree-generating function from a NodeCorrespondence
- Parameters:
node_corresp (NodeCorrespondence[T]) – Definition of a correpondence between an arbitrary type and a Tree Node
class_alias (str (optional)) – Name of the corresponding class to inject into docstring If not provided, will default to the __name__ of the class wrapped by node_corresp
obj_attr_name (str (optional)) – The name of the Node attribute to which a copy of the class instance should be bound If not provided, will default to the value of class_alias
exclude_mixin (Filter[T] (optional)) – An optional “master” filter to mix into any
- Returns:
compile_tree – Factory function which takes an instance of type T, builds a Tree from it, and returns the root Node
- Return type:
Callable[[T, Optional[int], Optional[Filter[T]]], Node]