descendant_cls

returns descendant matching the class name.

Arguments

Source


def descendant_cls(self, cls):
    ret = pyNodeList()
    for node in self:
        descendant = node.descendant_class(cls)
        if isinstance(descendant, pyNodeList) and len(descendant) != 0:
            ret.extend(descendant)
        elif isinstance(descendant, pyNode):
            ret.append(descendant)
    if len(ret) == 1: return ret[0]
    else: return ret