MCPcopy Create free account
hub / github.com/clips/pattern / _popToTag

Method _popToTag

pattern/web/soup/BeautifulSoup.py:1262–1282  ·  view source on GitHub ↗

Pops the tag stack up to and including the most recent instance of the given tag. If inclusivePop is false, pops the tag stack up to but *not* including the most recent instqance of the given tag.

(self, name, inclusivePop=True)

Source from the content-addressed store, hash-verified

1260
1261
1262 def _popToTag(self, name, inclusivePop=True):
1263 """Pops the tag stack up to and including the most recent
1264 instance of the given tag. If inclusivePop is false, pops the tag
1265 stack up to but *not* including the most recent instqance of
1266 the given tag."""
1267 #print "Popping to %s" % name
1268 if name == self.ROOT_TAG_NAME:
1269 return
1270
1271 numPops = 0
1272 mostRecentTag = None
1273 for i in range(len(self.tagStack)-1, 0, -1):
1274 if name == self.tagStack[i].name:
1275 numPops = len(self.tagStack)-i
1276 break
1277 if not inclusivePop:
1278 numPops = numPops - 1
1279
1280 for i in range(0, numPops):
1281 mostRecentTag = self.popTag()
1282 return mostRecentTag
1283
1284 def _smartPop(self, name):
1285

Callers 2

_smartPopMethod · 0.95
unknown_endtagMethod · 0.95

Calls 2

popTagMethod · 0.95
lenFunction · 0.85

Tested by

no test coverage detected