

def gotTagStart(self, name, attributes):
    parent = self._getparent()
    if (self.beExtremelyLenient and isinstance(parent, Element)):
        parentName = parent.tagName
        myName = name
        if self.caseInsensitive:
            parentName = parentName.lower()
            myName = myName.lower()
        if (myName in self.laterClosers.get(parentName, [])):
            self.gotTagEnd(parent.tagName)
            parent = self._getparent()
    attributes = _unescapeDict(attributes)
    namespaces = self.nsstack[(- 1)][0]
    newspaces = {
        
    }
    for (k, v) in attributes.items():
        if k.startswith('xmlns'):
            spacenames = k.split(':', 1)
            if (len(spacenames) == 2):
                newspaces[spacenames[1]] = v
            else:
                newspaces[''] = v
            del attributes[k]
    if newspaces:
        namespaces = namespaces.copy()
        namespaces.update(newspaces)
    for (k, v) in attributes.items():
        ksplit = k.split(':', 1)
        if (len(ksplit) == 2):
            (pfx, tv) = ksplit
            if ((pfx != 'xml') and namespaces.has_key(pfx)):
                attributes[(namespaces[pfx], tv)] = v
                del attributes[k]
    el = Element(name, attributes, parent, self.filename, self.saveMark(), caseInsensitive=self.caseInsensitive, preserveCase=self.preserveCase, namespace=namespaces.get(''))
    revspaces = _reverseDict(newspaces)
    el.addPrefixes(revspaces)
    if newspaces:
        rscopy = self.nsstack[(- 1)][2].copy()
        rscopy.update(revspaces)
        self.nsstack.append((namespaces, el, rscopy))
    self.elementstack.append(el)
    if parent:
        parent.appendChild(el)
    if (self.beExtremelyLenient and (el.tagName in self.soonClosers)):
        self.gotTagEnd(name)

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