l.b.a.t.LookupBranch : class documentation

Part of lp.bugs.adapters.treelookup View In Hierarchy

Known subclasses: lp.bugs.externalbugtracker.base.LookupBranch

A branch point during a lookup, containing keys and a result.
Method __init__ Construct a new LookupBranch from the given keys and result.
Method is_leaf Whether or not this is a leaf.
Method is_default Whether or not this is a default branch.
Method describe A representation of this branch.
Method __repr__ A machine-readable representation of this branch.
Method _verify Check the validity of the branch.
Method _describe_key Return a pretty representation of a simple key.
Method _describe_result Return a pretty representation of the branch result.
def __init__(self, *args):
Construct a new LookupBranch from the given keys and result.

Split out the keys from the result. The last argument specified is the result of this branch, and all the other arguments are keys.

As an extra step, the branch is verified by calling _verify.

def _verify(self):
Check the validity of the branch.

The default implementation does nothing.

RaisesTypeErrorIf the branch is invalid.
@property
def is_leaf(self):
Whether or not this is a leaf.

If the result of this branch is not a LookupTree, then this is a leaf... as well as a branch... the terminology is a little confused :)

@property
def is_default(self):
Whether or not this is a default branch.

If there are no keys for this branch, then this is a default branch.

def describe(self, level=1):
A representation of this branch.

If the result of this branch is a LookupTree instance, it's asked for a representation at a specific level, which corresponds to its position in the tree. This allows for pretty indentation to aid human comprehension.

If the result is any other object, _describe_result is used.

Keys are formatted using _describe_key.

This is mainly intended as an aid to development.

def _describe_key(self, key):
Return a pretty representation of a simple key.

If the key, as a string, contains only characters from a small selected set, it is returned without quotes. Otherwise, the result of repr is returned.

def _describe_result(self, result):
Return a pretty representation of the branch result.

By default, return the representation as returned by repr.

def __repr__(self):
A machine-readable representation of this branch.
API Documentation for Launchpad, generated by pydoctor at 2022-06-16 00:00:12.