Beispiel #1
0
 def getChildren(self, tag_name=None):
   """
   Fetches all direct children of this element that match a particular tag
   name (or all children if no tag is given)
   """
   if not tag_name:
     return self._children
   tag_name = tag2class(tag_name)
   return [child for child in self._children if child.__class__.__name__ == tag_name]
Beispiel #2
0
def nud(self):
  yield XHPY_SENTINEL, None
  xhpy_class_name = []
  for t in xhpy_attribute_name():
    xhpy_class_name.append(t[1])
  while True:
    if token.id != ':':
      break
    xhpy_class_name.append(token.value)
    advance(':')
    for t in xhpy_attribute_name():
      xhpy_class_name.append(t[1])
  yield tokenize.NAME, tag2class(''.join(xhpy_class_name))