MCPcopy Index your code
hub / github.com/RustPython/RustPython / readline

Method readline

Lib/imaplib.py:379–412  ·  view source on GitHub ↗

Read line from remote.

(self)

Source from the content-addressed store, hash-verified

377
378
379 def readline(self):
380 """Read line from remote."""
381 # The comment in read() explains why we implement our own readline().
382
383 LF = b'\n'
384 parts = []
385 length = 0
386
387 while length < _MAXLINE:
388
389 if len(parts) < len(self._readbuf):
390 buf = self._readbuf[len(parts)]
391 else:
392 try:
393 buf = self.sock.recv(DEFAULT_BUFFER_SIZE)
394 except ConnectionError:
395 break
396 if not buf:
397 break
398 self._readbuf.append(buf)
399
400 pos = buf.find(LF)
401 if pos != -1:
402 pos += 1
403 parts.append(buf[:pos])
404 self._readbuf = [buf[pos:]] + self._readbuf[len(parts):]
405 break
406 parts.append(buf)
407 length += len(buf)
408
409 line = b''.join(parts)
410 if len(line) > _MAXLINE:
411 raise self.error("got more than %d bytes" % _MAXLINE)
412 return line
413
414
415 def send(self, data):

Callers 2

_get_lineMethod · 0.95
readlineMethod · 0.45

Calls 6

lenFunction · 0.85
recvMethod · 0.45
appendMethod · 0.45
findMethod · 0.45
joinMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected