sec_parser.semantic_tree.tree_node

Classes

TreeNode

The TreeNode class is a fundamental part of the semantic tree structure.

Module Contents

class sec_parser.semantic_tree.tree_node.TreeNode(semantic_element: sec_parser.semantic_elements.abstract_semantic_element.AbstractSemanticElement, *, parent: TreeNode | None = None, children: collections.abc.Iterable[TreeNode] | None = None)

The TreeNode class is a fundamental part of the semantic tree structure. Each TreeNode represents a node in the tree. It holds a reference to a semantic element, maintains a list of its child nodes, and a reference to its parent node. This class provides methods for managing the tree structure, such as adding and removing child nodes. Importantly, these methods ensure logical consistency as children/parents are being changed. For example, if a parent is removed from a child, the child is automatically removed from the parent.

property semantic_element: sec_parser.semantic_elements.abstract_semantic_element.AbstractSemanticElement
property children: list[TreeNode]
property parent: TreeNode | None
add_child(child: TreeNode) None
add_children(children: collections.abc.Iterable[TreeNode]) None
remove_child(child: TreeNode) None
has_child(child: TreeNode) bool
get_descendants() collections.abc.Iterator[TreeNode]
__repr__() str

Return repr(self).

property text: str

Property text is a passthrough to the SemanticElement text property.

get_source_code(*, pretty: bool = False) str

get_source_code is a passthrough to the SemanticElement method.