class documentation

Concrete implementation for leaf nodes. The __str__ value is derived from the prefix and the value. The prefix is any white space and comments before this item (e.g., Leaf(token.NEWLINE, value=" ", prefix=" # comment"). The _eq method (see Base.__eq__) compares only type and value.

Method __init__ Initializer.
Method __repr__ Return a canonical string representation.
Method __unicode__ Return a pretty string representation.
Method clone Return a cloned (deep) copy of self.
Method leaves Undocumented
Method post_order Post-order iterator for the tree.
Method pre_order Pre-order iterator for the tree.
Class Variable column Undocumented
Class Variable lineno Undocumented
Class Variable prefix Undocumented
Instance Variable fixers_applied Undocumented
Instance Variable type Undocumented
Instance Variable value Undocumented
Method _eq Compare two nodes for equality (type and value).
Method _prefix_getter The whitespace and comments preceding this token in the input.
Method _prefix_setter Undocumented
Instance Variable _prefix 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 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 children 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, value, context=None, prefix=None, fixers_applied=[]): (source)

Initializer. Takes a type constant (a token number < 256), a string value, and an optional context keyword argument (prefix, (lineno, column)). If the prefix keyword argument is provided, it overrides the prefix derived from the context. The prefix is the text that appears before the value (e.g., blanks and comments).

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 clone(self): (source)

Return a cloned (deep) copy of self.

def leaves(self): (source)

Undocumented

def post_order(self): (source)

Post-order iterator for the tree.

def pre_order(self): (source)

Pre-order iterator for the tree.

Undocumented

Undocumented

fixers_applied = (source)

Undocumented

Undocumented

def _eq(self, other): (source)

Compare two nodes for equality (type and value).

def _prefix_getter(self): (source)

The whitespace and comments preceding this token in the input.

def _prefix_setter(self, prefix): (source)

Undocumented

Undocumented