MCPcopy Index your code
hub / github.com/clips/pattern / extract

Method extract

pattern/web/soup/BeautifulSoup.py:168–195  ·  view source on GitHub ↗

Destructively rips this element out of the tree.

(self)

Source from the content-addressed store, hash-verified

166 myParent.insert(myIndex, child)
167
168 def extract(self):
169 """Destructively rips this element out of the tree."""
170 if self.parent:
171 try:
172 del self.parent.contents[self.parent.index(self)]
173 except ValueError:
174 pass
175
176 #Find the two elements that would be next to each other if
177 #this element (and any children) hadn't been parsed. Connect
178 #the two.
179 lastChild = self._lastRecursiveChild()
180 nextElement = lastChild.next
181
182 if self.previous:
183 self.previous.next = nextElement
184 if nextElement:
185 nextElement.previous = self.previous
186 self.previous = None
187 lastChild.next = None
188
189 self.parent = None
190 if self.previousSibling:
191 self.previousSibling.nextSibling = self.nextSibling
192 if self.nextSibling:
193 self.nextSibling.previousSibling = self.previousSibling
194 self.previousSibling = self.nextSibling = None
195 return self
196
197 def _lastRecursiveChild(self):
198 "Finds the last element beneath this object to be parsed."

Callers 7

replaceWithMethod · 0.95
replaceWithChildrenMethod · 0.95
findVCardsMethod · 0.80
insertMethod · 0.80
clearMethod · 0.80
decomposeMethod · 0.80
testTagExtractionMethod · 0.80

Calls 2

_lastRecursiveChildMethod · 0.95
indexMethod · 0.45

Tested by 1

testTagExtractionMethod · 0.64