nodes.py
Bases: foundations.dataStructures.Structure
This class represents a storage object for the AbstractNode class attributes.
Usage:
>>> attribute = Attribute(name="My Attribute", value="My Value")
>>> attribute.name
'My Attribute'
>>> attribute["name"]
'My Attribute'
>>> attribute.value
'My Value'
>>> attribute["value"]
'My Value'
Parameters: |
|
---|
Bases: foundations.dataStructures.Structure
Note : | This class doesn’t provide compositing capabilities, AbstractCompositeNode class must be used for that purpose. |
---|
This decorator is used for execution tracing.
Parameters: |
|
---|---|
Returns: | Object. ( Object ) |
This method is the property for self.__family attribute.
Returns: | self.__family. ( String ) |
---|
This method is the property for self.__nodesInstances attribute.
Returns: | self.__nodesInstances. ( WeakValueDictionary ) |
---|
This method is the property for self.__identity attribute.
Returns: | self.__identity. ( String ) |
---|
This method is the property for self.__name attribute.
Returns: | self.__name. ( String ) |
---|
This decorator is used for execution tracing.
Parameters: |
|
---|---|
Returns: | Object. ( Object ) |
This decorator is used for execution tracing.
Parameters: |
|
---|---|
Returns: | Object. ( Object ) |
This decorator is used for execution tracing.
Parameters: |
|
---|---|
Returns: | Object. ( Object ) |
This decorator is used for execution tracing.
Parameters: |
|
---|---|
Returns: | Object. ( Object ) |
Bases: foundations.nodes.AbstractNode
Parameters: |
|
---|---|
Note : | pickle.HIGHEST_PROTOCOL must be used to pickle foundations.nodes.AbstractCompositeNode class. |
This method is the property for self.__parent attribute.
Returns: | self.__parent. ( AbstractNode / AbstractCompositeNode ) |
---|
This method is the property for self.__children attribute.
Returns: | self.__children. ( List ) |
---|
This method returns the child associated with given index.
Usage:
>>> nodeB = AbstractCompositeNode("MyNodeB")
>>> nodeC = AbstractCompositeNode("MyNodeC")
>>> nodeA = AbstractCompositeNode("MyNodeA", children=[nodeB, nodeC])
>>> nodeA.child(0)
<AbstractCompositeNode object at 0x10107b6f0>
>>> nodeA.child(0).name
'MyNodeB'
Parameters: | index – Child index. ( Integer ) |
---|---|
Returns: | Child node. ( AbstractNode / AbstractCompositeNode / Object ) |
This method returns the given child index.
Usage:
>>> nodeA = AbstractCompositeNode("MyNodeA")
>>> nodeB = AbstractCompositeNode("MyNodeB", nodeA)
>>> nodeC = AbstractCompositeNode("MyNodeC", nodeA)
>>> nodeA.indexOf(nodeB)
0
>>> nodeA.indexOf(nodeC)
1
Parameters: | child – Child node. ( AbstractNode / AbstractCompositeNode / Object ) |
---|---|
Returns: | Child index. ( Integer ) |
This method returns the node row.
Usage:
>>> nodeA = AbstractCompositeNode("MyNodeA")
>>> nodeB = AbstractCompositeNode("MyNodeB", nodeA)
>>> nodeC = AbstractCompositeNode("MyNodeC", nodeA)
>>> nodeB.row()
0
>>> nodeC.row()
1
Returns: | Node row. ( Integer ) |
---|
This method adds given child to the node.
Usage:
>>> nodeA = AbstractCompositeNode("MyNodeA")
>>> nodeB = AbstractCompositeNode("MyNodeB")
>>> nodeA.addChild(nodeB)
True
>>> nodeA.children
[<AbstractCompositeNode object at 0x10107afe0>]
Parameters: | child – Child node. ( AbstractNode / AbstractCompositeNode / Object ) |
---|---|
Returns: | Method success. ( Boolean ) |
This method removes child at given index from the node children.
Usage:
>>> nodeA = AbstractCompositeNode("MyNodeA")
>>> nodeB = AbstractCompositeNode("MyNodeB", nodeA)
>>> nodeC = AbstractCompositeNode("MyNodeC", nodeA)
>>> nodeA.removeChild(1)
True
>>> [child.name for child in nodeA.children]
['MyNodeB']
Parameters: | index – Node index. ( Integer ) |
---|---|
Returns: | Removed child. ( AbstractNode / AbstractCompositeNode / Object ) |
This method inserts given child at given index.
Usage:
>>> nodeA = AbstractCompositeNode("MyNodeA")
>>> nodeB = AbstractCompositeNode("MyNodeB", nodeA)
>>> nodeC = AbstractCompositeNode("MyNodeC", nodeA)
>>> nodeD = AbstractCompositeNode("MyNodeD")
>>> nodeA.insertChild(nodeD, 1)
True
>>> [child.name for child in nodeA.children]
['MyNodeB', 'MyNodeD', 'MyNodeC']
Parameters: |
|
---|---|
Returns: | Method success. ( Boolean ) |
This method returns if the node has children.
Usage:
>>> nodeA = AbstractCompositeNode("MyNodeA")
>>> nodeA.hasChildren()
False
Returns: | Children count. ( Integer ) |
---|
This method returns the children count.
Usage:
>>> nodeA = AbstractCompositeNode("MyNodeA")
>>> nodeB = AbstractCompositeNode("MyNodeB", nodeA)
>>> nodeC = AbstractCompositeNode("MyNodeC", nodeA)
>>> nodeA.childrenCount()
2
Returns: | Children count. ( Integer ) |
---|
This method sorts the children using either the given attribute or the node name.
Parameters: |
|
---|---|
Returns: | Method success. ( Boolean ) |
This method finds the children matching the given patten.
Usage:
>>> nodeA = AbstractCompositeNode("MyNodeA")
>>> nodeB = AbstractCompositeNode("MyNodeB", nodeA)
>>> nodeC = AbstractCompositeNode("MyNodeC", nodeA)
>>> nodeA.findChildren("c", re.IGNORECASE)
[<AbstractCompositeNode object at 0x101078040>]
Parameters: |
|
---|---|
Returns: | Matching children. ( List ) |
This method returns the nodes from given family.
Parameters: |
|
---|---|
Returns: | Family nodes. ( List ) |
This method lists the current node and its children.
Usage:
>>> nodeA = AbstractCompositeNode("MyNodeA")
>>> nodeB = AbstractCompositeNode("MyNodeB", nodeA)
>>> nodeC = AbstractCompositeNode("MyNodeC", nodeA)
>>> print nodeA.listNode()
|----'MyNodeA'
|----'MyNodeB'
|----'MyNodeC'
Parameters: | tabLevel – Tab level. ( Integer ) |
---|---|
Returns: | Node listing. ( String ) |