Part of lp.bugs.adapters.treelookup View In Hierarchy
Known subclasses: lp.bugs.externalbugtracker.__init__.LookupTree
Method | __init__ | Construct a new LookupTree . |
Method | find | Search this tree. |
Method | flatten | Generate a flat representation of this tree. |
Method | min_depth | The minimum distance to a leaf. |
Method | max_depth | The maximum distance to a leaf. |
Method | describe | A representation of this tree, formatted for human consumption. |
Method | __repr__ | A machine-readable representation of this tree. |
Method | _verify | Check the validity of the tree. |
Construct a new `LookupTree`. Flatten or promote the given arguments into `LookupBranch`s. As an extra step, the branch is verified by calling `_verify`. :param args: `LookupBranch`s, `LookupTree`s, or iterables to be attached to this tree. Iterable arguments will be promoted to `LookupBranch` by calling `_branch_factory` with all the values from the iterator as positional arguments.
Every branch in the tree must be an instance of
LookupBranch
. In addition, only one default branch can
exist, and it must be the last branch.
Raises | TypeError | If the tree is invalid. |
Searches in the tree for key
. If the result is another tree,
it searches down that tree, using the first value of more
as
key
. Once it gets to a leaf, whether or not all the keys
(i.e. key
+ more
) have been consumed, the result is
returned.
Raises | KeyError | If a result is not found. |
Generates tuples. The last element in the tuple is the result. The previous elements are the branches followed to reach the result.
This can be useful for generating documentation, because it is a compact, flat representation of the tree.
The representation of each branch in this tree is indented
corresponding to level
, which indicates the position we are
at within the tree that is being represented.
When asking each branch for a representation, the next level
is passed to describe
, so that sub-trees will be indented
more.
This is mainly intended as an aid to development.