Tree functions¶
-
change_parent
(cur, node, new_parent, position=None, auto_position=True)¶ Move node and its subtree from its current to another parent node. Return updated
Node
object with new parent set. RaiseValueError
ifnew_parent
is insidenode
s subtree.Parameters: - node (Node or uuid4) –
- new_parent (Node or uuid4) – Reference to the new parent node
- position (int) – Position in between siblings. If 0, the node will be inserted at the beginning of the parents children. If -1, the node will be inserted the the end of the parents children. If auto_position is disabled, this is just a value.
- auto_position (bool) – See Positioning functions.
-
delete_node
(cur, node, auto_position=True)¶ Delete node and its subtree.
Parameters: - node (Node or uuid4) –
- auto_position (bool) – See Positioning functions
-
insert_node
(cur, parent, properties=None, position=None, auto_position=True, id=None)¶ Create a
Node
object, insert it into the tree and then return it.Parameters: - parent (Node or uuid4) – Reference to its parent node. If None, this will be the root node.
- properties (dict) – Inheritable key/value pairs (see Property functions)
- position (int) – Position in between siblings. If 0, the node will be inserted at the beginning of the parents children. If -1, the node will be inserted the the end of the parents children. If auto_position is disabled, this is just a value.
- auto_position (bool) – See Positioning functions
- id (uuid4) – Use this ID instead of automatically generating one.
-
print_tree
(cur, start_node=None, indent=' ', _level=0)¶ Print tree to stdout.
Parameters: - start_node (int, Node, NodaData or None) – Starting point for tree output.
If
None
, start at root node. - indent (str) – String to print per level (default: ‘ ‘)
- start_node (int, Node, NodaData or None) – Starting point for tree output.
If