class documentation

Concrete implementation for interior nodes. The __str__ value is derived entirely from the children, and ultimately from the concrete realization of the Leaf nodes below this. The _eq method (see Base.__eq__) compares only type and recursively the children. Extra attributes, such as context or label, are ignored.

Method __init__ Initializer.
Method __repr__ Return a canonical string representation.
Method __unicode__ Return a pretty string representation.
Method append_child Equivalent to 'node.children.append(child)'. This method also sets the child's parent attribute appropriately.
Method clone Return a cloned (deep) copy of self.
Method insert_child Equivalent to 'node.children.insert(i, child)'. This method also sets the child's parent attribute appropriately.
Method post_order Post-order iterator for the tree.
Method pre_order Pre-order iterator for the tree.
Method set_child Equivalent to 'node.children[i] = child'. This method also sets the child's parent attribute appropriately.
Instance Variable children Undocumented
Instance Variable fixers_applied Undocumented
Instance Variable prefix Undocumented
Instance Variable type Undocumented
Method _eq Compare two nodes for equality (using type, children) - see Base.__eq__
Method _prefix_getter The whitespace and comments preceding this node in the input.
Method _prefix_setter Undocumented

Inherited from Base:

Method __eq__ Compare two nodes for equality.
Method __ne__ Compare two nodes for inequality.
Method __new__ Constructor that prevents Base from being instantiated.
Method __str__ Undocumented
Method changed Undocumented
Method depth Undocumented
Method descend_to Takes a sequence of integers and descends via children.
Method get_lineno Return the line number which generated the invocant node.
Method get_prefix Return the prefix for the node (see Leaf class).
Method get_suffix Return the string immediately following the invocant node. This is effectively equivalent to node.next_sibling.prefix
Method label_nodes Create 'label' attritbute for each Node/Leaf.
Method leaves Undocumented
Method remove Remove the node from the tree. Returns the position of the node in its parent's children before it was removed.
Method replace Replace this node with a new one in the parent.
Method set_prefix Set the prefix for the node (see Leaf class).
Class Variable __hash__ Undocumented
Class Variable was_checked Undocumented
Instance Variable label Undocumented
Instance Variable parent Undocumented
Instance Variable was_changed Undocumented
Property next_sibling The node immediately following the invocant in their parent's children list. If the invocant does not have a next sibling, it is None
Property prev_sibling The node immediately preceding the invocant in their parent's children list. If the invocant does not have a previous sibling, it is None.
Property type_repr Get the type as a human-readable string.
def __init__(self, type, children, context=None, prefix=None, fixers_applied=None): (source)

Initializer. Takes a type constant (a symbol number >= 256) and a sequence of child nodes. The 'context' keyword argument is ignored -- its presence simplifies some callers, but in reality the information (prefix, lineno, column) is kept in the Leaf nodes (this information is used by the __str__ method, which is derived from the children of the node, and utlimately from the Leaf nodes. As a side effect, the parent pointers of the children are updated.

def __repr__(self): (source)

Return a canonical string representation.

def __unicode__(self): (source)

Return a pretty string representation. This reproduces the input source exactly.

def append_child(self, child): (source)

Equivalent to 'node.children.append(child)'. This method also sets the child's parent attribute appropriately.

def clone(self): (source)

Return a cloned (deep) copy of self.

def insert_child(self, i, child): (source)

Equivalent to 'node.children.insert(i, child)'. This method also sets the child's parent attribute appropriately.

def post_order(self): (source)

Post-order iterator for the tree.

def pre_order(self): (source)

Pre-order iterator for the tree.

def set_child(self, i, child): (source)

Equivalent to 'node.children[i] = child'. This method also sets the child's parent attribute appropriately.

fixers_applied = (source)

Undocumented

def _eq(self, other): (source)

Compare two nodes for equality (using type, children) - see Base.__eq__

def _prefix_getter(self): (source)

The whitespace and comments preceding this node in the input.

def _prefix_setter(self, prefix): (source)

Undocumented