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

Method normalize

Lib/xml/dom/minidom.py:179–204  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

177 return oldChild
178
179 def normalize(self):
180 L = []
181 for child in self.childNodes:
182 if child.nodeType == Node.TEXT_NODE:
183 if not child.data:
184 # empty text node; discard
185 if L:
186 L[-1].nextSibling = child.nextSibling
187 if child.nextSibling:
188 child.nextSibling.previousSibling = child.previousSibling
189 child.unlink()
190 elif L and L[-1].nodeType == child.nodeType:
191 # collapse text node
192 node = L[-1]
193 node.data = node.data + child.data
194 node.nextSibling = child.nextSibling
195 if child.nextSibling:
196 child.nextSibling.previousSibling = node
197 child.unlink()
198 else:
199 L.append(child)
200 else:
201 L.append(child)
202 if child.nodeType == Node.ELEMENT_NODE:
203 child.normalize()
204 self.childNodes[:] = L
205
206 def cloneNode(self, deep):
207 return _clone_node(self, deep, self.ownerDocument or self)

Callers 15

nameprepFunction · 0.45
testNormalizeMethod · 0.45
testBug0777884Method · 0.45
testBug1433694Method · 0.45
checkMethod · 0.45
test_named_parametersMethod · 0.45

Calls 2

unlinkMethod · 0.45
appendMethod · 0.45