moosetree.search

findall(node, func=None, method=None, **kwargs)

Find all nodes matching the supplied function.

The root for the search is provided in node. A search is conducted by calling func at each descendant of the root node. If this function evaluates to True the resulting node object is added to the list of nodes that is returned.

The search method defaults to a breath first search, but any IterMethod can be supplied.

If a function is not provided then the default for func is used, which checks that the supplied keyword arguments match the attributes of the node.

find(node, func=None, method=None, **kwargs)

Operates in the same fashion as "findall"; however, if a match is found the search is terminated and the node is returned.

iterate(node, func=None, abort_on_find=False, method=None)

Iterates over the descendants of node.

The search method defaults to a breath first search, but any IterMethod can be supplied. The iteration can be limited to certain nodes by defining func. This function is evaluated at each node during iteration and only nodes that result in True are considered. If abort_on_find is set to True the iteration will stop after the first evaluation of the function that is `True.