Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
Ë
](j:\ ã óÂ — d Z ddlmZ ddlZddlZddlZddlmZ ddlm Z m
Z
mZmZm
Z
ddlmZ ddlmZ dd lmZ ej( d
k\ ree Zne
e Z G d„ de« Zy)
aS
Node structure in treelib.
A :class:`Node` object contains basic properties such as node identifier,
node tag, parent node, children nodes etc., and some operations for a node.
The Node class is the fundamental building block of a Tree. Each node can store:
- A unique identifier for tree operations
- A human-readable tag for display
- Custom data payload
- Parent-child relationships within one or more trees
Note:
Nodes are typically created through Tree.create_node() rather than
directly instantiated, as the Tree class manages the parent-child
relationships automatically.
é )Úunicode_literalsN)Údefaultdict)ÚAnyÚListÚOptionalÚUnionÚcast)Úwarné )ÚNodePropertyError)Ú
deprecated)é é c óB — e Zd ZdZ e ed« « \ ZZZZ d-de
e de
e dede
ddf
d „Zdefd
„Zdeddfd„Zd
e
e ddfd„Ze ed¬« d„ « « Zej* ed¬« d.d„« « Z ed¬« d.d„« Ze ed¬« d„ « « Zej* ed¬« dedeeef ddfd„« « Z ed¬« edfd„« Zd„ Zd
e
e de
e ddfd„Zde
e defd„Zd/dedeeef de
e ddfd„Z eddfd
e
e de!d e
e de
e ddf
d!„Z"edefd"„« Z#d#ed$eddfd%„Z$d.d&„Z%e#j* deddfd'„« Z#d/de
e defd(„Z&d/de
e defd)„Z'edefd*„« Z(e(j* de
e ddfd+„« Z(defd,„Z)y)0ÚNodea4
Elementary node object stored in Tree structures.
A Node represents a single element in a tree hierarchy. Each node maintains
references to its parent and children within specific tree contexts, along
with a human-readable tag and optional data payload.
Attributes:
identifier (str): Unique identifier for this node within a tree.
tag (str): Human-readable label for display purposes.
expanded (bool): Controls visibility of children in tree displays.
data (Any): User-defined payload associated with this node.
Example:
Creating nodes with different configurations::
# Basic node
node = Node("Root", "root")
# Node with custom data
node = Node("File", "file1", data={"size": 1024, "type": "txt"})
# Node that starts collapsed
node = Node("Folder", "folder1", expanded=False)
Warning:
While nodes can be created directly, it's recommended to use
Tree.create_node() which properly manages tree relationships.
é NÚtagÚ
identifierÚexpandedÚdataÚreturnc óÊ — d| _ | j |« |€| j | _ n|| _ || _ i | _ t t « | _ || _ d| _ y)aU
Create a new Node object to be placed inside a Tree object.
Args:
tag: Human-readable label for the node. If None, uses identifier.
identifier: Unique ID for the node. If None, generates a UUID.
expanded: Whether node children are visible in tree displays.
data: Optional user data to associate with this node.
Example:
Creating different types of nodes::
# Auto-generated identifier
node1 = Node("My Node")
# Explicit identifier
node2 = Node("Root", "root")
# With custom data
node3 = Node("User", "user1", data={"name": "Alice", "role": "admin"})
# Initially collapsed
node4 = Node("Large Folder", "folder", expanded=False)
N)
Ú_identifierÚ_set_identifierÚ_tagr Ú_predecessorr ÚlistÚ_successorsr Ú_initial_tree_id)Úselfr r r r s ú=/opt/nydus/tmp/pip-target-jcxkyz1b/lib/python/treelib/node.pyÚ__init__z
Node.__init__M si € ðB +/ˆÔØ×јZÔ(ð ˆ;Ø×(Ñ(ˆD�IàˆDŒIð !ˆŒ
ð #%ˆÔä!,¬TÓ!2ˆÔ𠈌 ð 04ˆÕó c ó4 — | j |j k S )ar
Compare nodes for sorting based on their tags.
Enables sorting of Node objects in collections by comparing their tag attributes.
This allows natural ordering when displaying or processing collections of nodes.
Args:
other: Another Node object to compare with.
Returns:
bool: True if this node's tag is lexicographically less than other's tag.
Example:
Sorting nodes by tag::
nodes = [Node("Charlie", "c"), Node("Alice", "a"), Node("Bob", "b")]
sorted_nodes = sorted(nodes) # Alice, Bob, Charlie
)r )r Úothers r! Ú__lt__zNode.__lt__† s € ð&