MCPcopy Index your code
hub / github.com/bpython/bpython / readlines

Method readlines

bpython/curtsiesfrontend/repl.py:191–206  ·  view source on GitHub ↗
(self, size: int | None = -1)

Source from the content-addressed store, hash-verified

189 return value if size <= -1 else value[:size]
190
191 def readlines(self, size: int | None = -1) -> list[str]:
192 if size is None:
193 # the default readlines implementation also accepts None
194 size = -1
195 if not isinstance(size, int):
196 raise TypeError("argument should be integer or None, not 'str'")
197 if size <= 0:
198 # read as much as we can
199 return list(iter(self.readline, ""))
200
201 lines = []
202 while size > 0:
203 line = self.readline()
204 lines.append(line)
205 size -= len(line)
206 return lines
207
208 def __iter__(self):
209 return iter(self.readlines())

Callers 1

__iter__Method · 0.95

Calls 2

readlineMethod · 0.95
appendMethod · 0.80

Tested by

no test coverage detected