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

Method replaceWith

pattern/web/soup/BeautifulSoup.py:144–157  ·  view source on GitHub ↗
(self, replaceWith)

Source from the content-addressed store, hash-verified

142 self.previousSibling.nextSibling = self
143
144 def replaceWith(self, replaceWith):
145 oldParent = self.parent
146 myIndex = self.parent.index(self)
147 if hasattr(replaceWith, "parent")\
148 and replaceWith.parent is self.parent:
149 # We're replacing this element with one of its siblings.
150 index = replaceWith.parent.index(replaceWith)
151 if index and index < myIndex:
152 # Furthermore, it comes before this element. That
153 # means that when we extract it, the index of this
154 # element will change.
155 myIndex = myIndex - 1
156 self.extract()
157 oldParent.insert(myIndex, replaceWith)
158
159 def replaceWithChildren(self):
160 myParent = self.parent

Callers 1

testTagReplacementMethod · 0.80

Calls 3

extractMethod · 0.95
indexMethod · 0.45
insertMethod · 0.45

Tested by 1

testTagReplacementMethod · 0.64