Arguments
Source
def descendant_cls(self, cls):
ret = pyNodeList()
cls_name = re.compile(cls)
if self.has_child():
children = self.children()
if isinstance(children, pyNode):
tmp = pyNodeList()
tmp.append(children)
children = tmp
if isinstance(children, pyNodeList) and len(children) != 0:
for ch in children:
c = ch.attr('class')
if c is not None and cls_name.search(c) is not None:
ret.append(ch)
descendant = ch.descendant_cls(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