select_has

returns elements that have given elements.

Arguments

Source


def select_has(self, pynodelist):
    ret = pyNodeList()
    for node in self:
        descendant = node.descendant()
        if isinstance(descendant, pyNode):
            for another in pynodelist:
                if descendant == another:
                    ret.append(node)
        elif isinstance(descendant, pyNodeList) and len(descendant) != 0:
            for d in descendant:
                for another in pynodelist:
                    if d == another:
                        ret.append(node)
    if len(ret) == 1: return ret[0]
    else: return ret