Ejemplo n.º 1
0
class Target(object):

    def __init__(self, tagname):
        self._tagname = tagname
        self._builder = TreeBuilder()
        self._rootbuilder = self._builder
        self._depth = 0

    def start(self, tagname, attrs, nsmap=None):
        if tagname == self._tagname:
            if self._depth == 0:
                self._builder = TreeBuilder()
            self._depth += 1
        self._builder.start(tagname, attrs, nsmap)
    
    def data(self, *args, **kwargs):
        self._builder.data(*args, **kwargs)

    def end(self, tagname):
        self._builder.end(tagname)
        if tagname == self._tagname:
            self._depth -= 1
            if self._depth == 0:
                self.root = self._builder.close()
                self._builder = self._rootbuilder
Ejemplo n.º 2
0
class Target(object):

    def __init__(self, tagname):
        self._tagname = tagname
        self._builder = TreeBuilder()
        self._rootbuilder = self._builder
        self._depth = 0

    def start(self, tagname, attrs, nsmap=None):
        if tagname == self._tagname:
            if self._depth == 0:
                self._builder = TreeBuilder()
            self._depth += 1
        self._builder.start(tagname, attrs, nsmap)
    
    def data(self, *args, **kwargs):
        self._builder.data(*args, **kwargs)

    def end(self, tagname):
        self._builder.end(tagname)
        if tagname == self._tagname:
            self._depth -= 1
            if self._depth == 0:
                self.root = self._builder.close()
                self._builder = self._rootbuilder
Ejemplo n.º 3
0
 def start(self, tagname, attrs, nsmap=None):
     if tagname == self._tagname:
         if self._depth == 0:
             self._builder = TreeBuilder()
         self._depth += 1
     self._builder.start(tagname, attrs, nsmap)
Ejemplo n.º 4
0
 def __init__(self, tagname):
     self._tagname = tagname
     self._builder = TreeBuilder()
     self._rootbuilder = self._builder
     self._depth = 0
Ejemplo n.º 5
0
 def start(self, tagname, attrs, nsmap=None):
     if tagname == self._tagname:
         if self._depth == 0:
             self._builder = TreeBuilder()
         self._depth += 1
     self._builder.start(tagname, attrs, nsmap)
Ejemplo n.º 6
0
 def __init__(self, tagname):
     self._tagname = tagname
     self._builder = TreeBuilder()
     self._rootbuilder = self._builder
     self._depth = 0