MCPcopy Index your code
hub / github.com/python/cpython / push

Method push

Lib/email/feedparser.py:102–121  ·  view source on GitHub ↗

Push some new data into this object.

(self, data)

Source from the content-addressed store, hash-verified

100 self._lines.appendleft(line)
101
102 def push(self, data):
103 """Push some new data into this object."""
104 self._partial.write(data)
105 if '\n' not in data and '\r' not in data:
106 # No new complete lines, wait for more.
107 return
108
109 # Crack into lines, preserving the linesep characters.
110 self._partial.seek(0)
111 parts = self._partial.readlines()
112 self._partial.seek(0)
113 self._partial.truncate()
114
115 # If the last element of the list does not end in a newline, then treat
116 # it as a partial line. We only check for '\n' here because a line
117 # ending with '\r' might be a line that was split in the middle of a
118 # '\r\n' sequence (see bugs 1555570 and 1721862).
119 if not parts[-1].endswith('\n'):
120 self._partial.write(parts.pop())
121 self.pushlines(parts)
122
123 def pushlines(self, lines):
124 self._lines.extend(lines)

Callers 3

test_pushCR_LFMethod · 0.95
test_push_randomMethod · 0.95
feedMethod · 0.45

Calls 7

pushlinesMethod · 0.95
writeMethod · 0.45
seekMethod · 0.45
readlinesMethod · 0.45
truncateMethod · 0.45
endswithMethod · 0.45
popMethod · 0.45

Tested by 2

test_pushCR_LFMethod · 0.76
test_push_randomMethod · 0.76