MCPcopy
hub / github.com/csev/py4e / endData

Method endData

code3/bs4/__init__.py:287–315  ·  view source on GitHub ↗
(self, containerClass=NavigableString)

Source from the content-addressed store, hash-verified

285 self.preserve_whitespace_tag_stack.append(tag)
286
287 def endData(self, containerClass=NavigableString):
288 if self.current_data:
289 current_data = ''.join(self.current_data)
290 # If whitespace is not preserved, and this string contains
291 # nothing but ASCII spaces, replace it with a single space
292 # or newline.
293 if not self.preserve_whitespace_tag_stack:
294 strippable = True
295 for i in current_data:
296 if i not in self.ASCII_SPACES:
297 strippable = False
298 break
299 if strippable:
300 if '\n' in current_data:
301 current_data = '\n'
302 else:
303 current_data = ' '
304
305 # Reset the data collector.
306 self.current_data = []
307
308 # Should we add this string to the tree at all?
309 if self.parse_only and len(self.tagStack) <= 1 and \
310 (not self.parse_only.text or \
311 not self.parse_only.search(current_data)):
312 return
313
314 o = containerClass(current_data)
315 self.object_was_parsed(o)
316
317 def object_was_parsed(self, o, parent=None, most_recent_element=None):
318 """Add an object to the parse tree."""

Callers 11

_feedMethod · 0.95
handle_starttagMethod · 0.95
handle_endtagMethod · 0.95
endMethod · 0.45
piMethod · 0.45
doctypeMethod · 0.45
commentMethod · 0.45
handle_commentMethod · 0.45
handle_declMethod · 0.45
unknown_declMethod · 0.45
handle_piMethod · 0.45

Calls 2

object_was_parsedMethod · 0.95
searchMethod · 0.45

Tested by

no test coverage detected