

def gotTagEnd(self, name):
    if (not self.elementstack):
        if self.beExtremelyLenient:
            return
        raise MismatchedTags(*(((self.filename, 'NOTHING', name) + self.saveMark()) + (0, 0)))
    el = self.elementstack.pop()
    pfxdix = self.nsstack[(- 1)][2]
    if (self.nsstack[(- 1)][1] is el):
        nstuple = self.nsstack.pop()
    else:
        nstuple = None
    if self.caseInsensitive:
        tn = el.tagName.lower()
        cname = name.lower()
    else:
        tn = el.tagName
        cname = name
    nsplit = name.split(':', 1)
    if (len(nsplit) == 2):
        (pfx, newname) = nsplit
        ns = pfxdix.get(pfx, None)
        if (ns is not None):
            if (el.namespace != ns):
                if (not self.beExtremelyLenient):
                    raise MismatchedTags(*(((self.filename, el.tagName, name) + self.saveMark()) + el._markpos))
    if (not (tn == cname)):
        if self.beExtremelyLenient:
            if self.elementstack:
                lastEl = self.elementstack[0]
                for idx in xrange(len(self.elementstack)):
                    if (self.elementstack[(- (idx + 1))].tagName == cname):
                        self.elementstack[(- (idx + 1))].endTag(name)
                        break
                else:
                    self.elementstack.append(el)
                    if (nstuple is not None):
                        self.nsstack.append(nstuple)
                    return
                del self.elementstack[(- (idx + 1)):]
                if (not self.elementstack):
                    self.documents.append(lastEl)
                    return
        else:
            raise MismatchedTags(*(((self.filename, el.tagName, name) + self.saveMark()) + el._markpos))
    el.endTag(name)
    if (not self.elementstack):
        self.documents.append(el)
    if (self.beExtremelyLenient and (el.tagName == 'script')):
        self._fixScriptElement(el)

dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/web/microdom.py MicroDOMParser.gotTagEnd/original