Tree¶
-
class
shajara.Tree(root=None)¶ Bases:
objectGeneric tree representation
Parameters: - value (ANY) – the value of the root node
- label (ANY) – the label of the root node
-
node_stack¶ the stack for browsing nodes
Type: array
Methods Summary
add_child(label, node)Adds a child to the current node. current_node()Returns the current node get_root()Returns the root of the tree process([processor])Short summary. select_child(label)Select a child node of the current one, using its label. up()Select the parent of the current node. Methods Documentation
-
add_child(label, node)¶ Adds a child to the current node. To browse the nodes use select_child and up
Parameters: Returns: this object
Return type:
-
get_root()¶ Returns the root of the tree
Returns: The root of the tree if it exists or None Return type: Node
-
process(processor=<shajara.NodeProcessor object>)¶ Short summary.
Parameters: processor (NodeProcessor) – the processor used to manipulate the tree starting from its root Returns: The result of processing, it can be None, a node, a string, etc. Return type: type