Module tree
source code
This module defines three classes, extending the xml.etree.ElementTree
module:
-
Tree: Linguistic trees, with support for: convenient nested indexing
t[1,1,1] instead of t[1][1][1]; leaves() to return the trees leaf
nodes; ...
-
ParentedTree: Each element keeps track of a single parent pointer,
returned by the element's `parent()` method. Elements may have at
most one parent; i.e., subtrees may not be shared. Any attempt to do
use a single element as a child for multiple parents will generate a
ValueError.
-
MultiParentedTree: Each element keeps track of a list of parent
pointers, returned by the element's `parents()` method. Elements may
have zero or more parients; i.e., subtrees may be shraed. If a
single Element is used as multiple children of the same parent, then
that parent will appear multiple times in the parents list.
Note: Mixing of etree implementations is not supported. I.e., you
should never construct a tree that combines elements from ParentedTree
with elements from MultiParentedTree, or elements from either of these
implementations with elements from any other implementation. Doing so
may result in incorrect parent pointers and ValueError exceptions.
|
_AbstractElement
An abstract base class for Elements.
|
|
_AbstractParentedElement
An abstract base class for (multi)parented element tree Elements.
|
|
_ParentedElement
A specialized version of etree.ElementTree.Element that keeps track
of a single parent pointer per element.
|
|
_MultiParentedElement
A specialized version of etree.ElementTree.Element that keeps track
of a list of parent pointers for each element.
|
|
ElementTreeImplementation
Instances of this class can be used as drop-in replacements for the
xml.etree.ElementTree module.
|
|
Tree = ElementTreeImplementation(_AbstractElement)
|
|
ParentedTree = ElementTreeImplementation(_ParentedElement)
|
|
MultiParentedTree = ElementTreeImplementation(_MultiParentedEl...
|
MultiParentedTree
- Value:
ElementTreeImplementation(_MultiParentedElement)
|
|