This class represents a sub-tree of a string parsed into a rich
structure. It is also the base class of all placeables.
|
__init__(self,
sub=None,
id=None,
rid=None,
xid=None,
**kwargs)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature |
source code
|
|
|
__add__(self,
rhs)
Emulate the unicode class. |
source code
|
|
|
__contains__(self,
item)
Emulate the unicode class. |
source code
|
|
|
__eq__(self,
rhs)
Returns:
True if (and only if) all members as well as sub-trees
are equal. |
source code
|
|
|
__ge__(self,
rhs)
Emulate the unicode class. |
source code
|
|
|
__getitem__(self,
i)
Emulate the unicode class. |
source code
|
|
|
__getslice__(self,
i,
j)
Emulate the unicode class. |
source code
|
|
|
__gt__(self,
rhs)
Emulate the unicode class. |
source code
|
|
|
__iter__(self)
Create an iterator of this element's sub-elements. |
source code
|
|
|
__le__(self,
rhs)
Emulate the unicode class. |
source code
|
|
|
|
|
__lt__(self,
rhs)
Emulate the unicode class. |
source code
|
|
|
__mul__(self,
rhs)
Emulate the unicode class. |
source code
|
|
|
|
|
__radd__(self,
lhs)
Emulate the unicode class. |
source code
|
|
|
__rmul__(self,
lhs)
Emulate the unicode class. |
source code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
delete_range(self,
start_index,
end_index)
Delete the text in the range given by the string-indexes
start_index and end_index . |
source code
|
|
|
depth_first(self,
filter=None)
Returns a list of the nodes in the tree in depth-first order. |
source code
|
|
|
encode(self,
encoding=' ascii ' )
More unicode class emulation. |
source code
|
|
|
|
|
elem_at_offset(self,
offset)
Get the StringElem in the tree that contains the string
rendered at the given offset. |
source code
|
|
|
find(self,
x)
Find sub-string x in this string tree and return the
position at which it starts. |
source code
|
|
|
find_elems_with(self,
x)
Find all elements in the current sub-tree containing x . |
source code
|
|
|
flatten(self,
filter=None)
Flatten the tree by returning a depth-first search over the tree's
leaves. |
source code
|
|
|
|
|
|
|
get_parent_elem(self,
child)
Searches the current sub-tree for and returns the parent of the
child element. |
source code
|
|
|
insert(self,
offset,
text)
Insert the given text at the specified offset of this string-tree's
string (Unicode) representation. |
source code
|
|
|
insert_between(self,
left,
right,
text)
Insert the given text between the two parameter
StringElem s. |
source code
|
|
bool
|
isleaf(self)
Whether or not this instance is a leaf node in the
StringElem tree. |
source code
|
|
|
iter_depth_first(self,
filter=None)
Iterate through the nodes in the tree in dept-first order. |
source code
|
|
|
map(self,
f,
filter=None)
Apply f to all nodes for which filter
returned True (optional). |
source code
|
|
|
print_tree(self,
indent=0,
verbose=False)
Print the tree from the current instance's point in an indented
manner. |
source code
|
|
|
prune(self)
Remove unnecessary nodes to make the tree optimal. |
source code
|
|
|
remove_type(self,
ptype)
Replace nodes with type ptype with base
StringElem s, containing the same sub-elements. |
source code
|
|
|
|
Inherited from object :
__delattr__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__setattr__
|