MCPcopy Index your code
hub / github.com/pyload/pyload / extract

Method extract

module/lib/BeautifulSoup.py:153–180  ·  view source on GitHub ↗

Destructively rips this element out of the tree.

(self)

Source from the content-addressed store, hash-verified

151 myParent.insert(myIndex, child)
152
153 def extract(self):
154 """Destructively rips this element out of the tree."""
155 if self.parent:
156 try:
157 del self.parent.contents[self.parent.index(self)]
158 except ValueError:
159 pass
160
161 #Find the two elements that would be next to each other if
162 #this element (and any children) hadn't been parsed. Connect
163 #the two.
164 lastChild = self._lastRecursiveChild()
165 nextElement = lastChild.next
166
167 if self.previous:
168 self.previous.next = nextElement
169 if nextElement:
170 nextElement.previous = self.previous
171 self.previous = None
172 lastChild.next = None
173
174 self.parent = None
175 if self.previousSibling:
176 self.previousSibling.nextSibling = self.nextSibling
177 if self.nextSibling:
178 self.nextSibling.previousSibling = self.previousSibling
179 self.previousSibling = self.nextSibling = None
180 return self
181
182 def _lastRecursiveChild(self):
183 "Finds the last element beneath this object to be parsed."

Callers 5

replaceWithMethod · 0.95
replaceWithChildrenMethod · 0.95
insertMethod · 0.45
clearMethod · 0.45
decomposeMethod · 0.45

Calls 2

_lastRecursiveChildMethod · 0.95
indexMethod · 0.45

Tested by

no test coverage detected