Node
Node
Source code in zenaura/client/tags/node.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
|
parent
property
writable
Read-only property referencing the node's parent.
__init__(name=None, children=None, attributes=None, text=None)
Represents an HTML element with attributes, children, and text content.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The tag name of the element. |
children |
list of Node
|
The child elements of this node. |
attributes |
list of Attribute
|
The attributes of this node. |
text |
str
|
The text content of this node. |
nodeId |
str
|
A unique identifier for this node. |
is_leaf |
bool
|
Whether this node has no children. |
is_text_node |
bool
|
Whether this node represents text content. |
level |
int
|
The depth of this node in the tree. |
key |
int
|
A unique identifier for this node within its level. |
path |
str
|
The path from the root to this node. |
Source code in zenaura/client/tags/node.py
appendAttributeToChild(node, attribute)
Appends an attribute to a child node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node |
Node
|
The child node to add the attribute to. |
required |
attribute |
Attribute
|
The attribute to add. |
required |
Source code in zenaura/client/tags/node.py
append_child(child)
Adds a child node to this node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
child |
Node or str
|
The child node to add. If a string is provided, it will be converted to a text node. |
required |
Source code in zenaura/client/tags/node.py
findAllByName(name)
Finds all child nodes with the given name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the child nodes to find. |
required |
Returns:
Type | Description |
---|---|
List[Node]
|
List[Node]: A list of child nodes with the given name. |
Source code in zenaura/client/tags/node.py
findAllChildrenByAttributeKey(key)
Finds all child nodes with the given attribute key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The attribute key to search for. |
required |
Returns:
Type | Description |
---|---|
List[Node]
|
List[Node]: A list of child nodes with the given attribute key. |
Source code in zenaura/client/tags/node.py
findAllChildrenByAttributeValue(value)
Finds all child nodes with the given attribute value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
The attribute value to search for. |
required |
Returns:
Type | Description |
---|---|
List[Node]
|
List[Node]: A list of child nodes with the given attribute value. |
Source code in zenaura/client/tags/node.py
findByAttribute(key, value)
Finds a child node with the given attribute key and value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The attribute key to search for. |
required |
value |
str
|
The attribute value to search for. |
required |
Returns:
Name | Type | Description |
---|---|---|
Node |
Node
|
The child node with the given attribute, or None if not found. |
Source code in zenaura/client/tags/node.py
findChildByName(name)
Finds a child node with the given name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the child node to find. |
required |
Returns:
Name | Type | Description |
---|---|---|
Node |
Node
|
The child node with the given name, or None if not found. |
Source code in zenaura/client/tags/node.py
getChildIndex(node)
Gets the index of a child node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node |
Node
|
The child node to find the index of. |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The index of the child node, or -1 if not found. |
Source code in zenaura/client/tags/node.py
insertAfter(node, newNode)
Inserts a new node after a specific child node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node |
Node
|
The child node to insert after. |
required |
newNode |
Node
|
The new node to insert. |
required |
Source code in zenaura/client/tags/node.py
insertBefore(node, newNode)
Inserts a new node before a specific child node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node |
Node
|
The child node to insert before. |
required |
newNode |
Node
|
The new node to insert. |
required |
Source code in zenaura/client/tags/node.py
remove(node)
Removes a child node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node |
Node
|
The child node to remove. |
required |
replace(oldNode, newNode)
to_dict()
Converts this node and its children into a nested dictionary representation.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary representing the node and its children. |
Source code in zenaura/client/tags/node.py
to_html()
Converts this node and its children into an HTML string.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The HTML representation of the node and its children. |
Source code in zenaura/client/tags/node.py
NodeList
Bases: list
Custom list subclass to trigger update on append.
Source code in zenaura/client/tags/node.py
update_root_properties(root)
Upon intialization of a node or setting children This method create infromation rich tree nodes: 1. link children to their parent 2. assign level, key information 3. is_leaf_node, is_text node and so on