

def __iter__(self):
    vmatch = self.vmatch
    vdict = self.vdict
    with self.source.open('rb') as xmlf:
        tree = etree.parse(xmlf)
        if (not hasattr(tree, 'iterfind')):
            tree.iterfind = tree.findall
        if (vmatch is not None):
            for rowelm in tree.iterfind(self.rmatch):
                if (self.attr is None):
                    getv = attrgetter('text')
                else:
                    getv = (lambda e: e.get(self.attr))
                if isinstance(vmatch, string_types):
                    velms = rowelm.findall(vmatch)
                else:
                    velms = itertools.chain(*[rowelm.findall(enm) for enm in vmatch])
                (yield tuple((getv(velm) for velm in velms)))
        else:
            flds = tuple(sorted(map(text_type, vdict.keys())))
            (yield flds)
            vmatches = dict()
            vgetters = dict()
            for f in flds:
                vmatch = self.vdict[f]
                if isinstance(vmatch, string_types):
                    vmatches[f] = vmatch
                    vgetters[f] = element_text_getter(self.missing)
                else:
                    vmatches[f] = vmatch[0]
                    attr = vmatch[1]
                    vgetters[f] = attribute_text_getter(attr, self.missing)
            for rowelm in tree.iterfind(self.rmatch):
                (yield tuple((vgetters[f](rowelm.findall(vmatches[f])) for f in flds)))

dataset/ETHPy150Open alimanfoo/petl/petl/io/xml.py XmlView.__iter__/original