MCPcopy Index your code
hub / github.com/python/cpython / setAttributeNode

Method setAttributeNode

Lib/xml/dom/minidom.py:797–814  ·  view source on GitHub ↗
(self, attr)

Source from the content-addressed store, hash-verified

795 return self._attrsNS.get((namespaceURI, localName))
796
797 def setAttributeNode(self, attr):
798 if attr.ownerElement not in (None, self):
799 raise xml.dom.InuseAttributeErr("attribute node already owned")
800 self._ensure_attributes()
801 old1 = self._attrs.get(attr.name, None)
802 if old1 is not None:
803 self.removeAttributeNode(old1)
804 old2 = self._attrsNS.get((attr.namespaceURI, attr.localName), None)
805 if old2 is not None and old2 is not old1:
806 self.removeAttributeNode(old2)
807 _set_attribute_node(self, attr)
808
809 if old1 is not attr:
810 # It might have already been part of this node, in which case
811 # it doesn't represent a change, and should not be returned.
812 return old1
813 if old2 is not attr:
814 return old2
815
816 setAttributeNodeNS = setAttributeNode
817

Callers 9

setAttributeMethod · 0.95
setAttributeNSMethod · 0.95
testSetIdAttributeMethod · 0.80
testSetIdAttributeNSMethod · 0.80
renameNodeMethod · 0.80
startElementNSMethod · 0.80
startElementMethod · 0.80

Calls 4

_ensure_attributesMethod · 0.95
removeAttributeNodeMethod · 0.95
_set_attribute_nodeFunction · 0.85
getMethod · 0.45

Tested by 4

testSetIdAttributeMethod · 0.64
testSetIdAttributeNSMethod · 0.64