MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / retrlines

Method retrlines

tools/python-3.11.9-amd64/Lib/ftplib.py:447–480  ·  view source on GitHub ↗

Retrieve data in line mode. A new port is created for you. Args: cmd: A RETR, LIST, or NLST command. callback: An optional single parameter callable that is called for each line with the trailing CRLF stripped. [default: pri

(self, cmd, callback = None)

Source from the content-addressed store, hash-verified

445 return self.voidresp()
446
447 def retrlines(self, cmd, callback = None):
448 """Retrieve data in line mode. A new port is created for you.
449
450 Args:
451 cmd: A RETR, LIST, or NLST command.
452 callback: An optional single parameter callable that is called
453 for each line with the trailing CRLF stripped.
454 [default: print_line()]
455
456 Returns:
457 The response code.
458 """
459 if callback is None:
460 callback = print_line
461 resp = self.sendcmd('TYPE A')
462 with self.transfercmd(cmd) as conn, \
463 conn.makefile('r', encoding=self.encoding) as fp:
464 while 1:
465 line = fp.readline(self.maxline + 1)
466 if len(line) > self.maxline:
467 raise Error("got more than %d bytes" % self.maxline)
468 if self.debugging > 2:
469 print('*retr*', repr(line))
470 if not line:
471 break
472 if line[-2:] == CRLF:
473 line = line[:-2]
474 elif line[-1:] == '\n':
475 line = line[:-1]
476 callback(line)
477 # shutdown ssl layer
478 if _SSLSocket is not None and isinstance(conn, _SSLSocket):
479 conn.unwrap()
480 return self.voidresp()
481
482 def storbinary(self, cmd, fp, blocksize=8192, callback=None, rest=None):
483 """Store a file in binary mode. A new port is created for you.

Callers 3

nlstMethod · 0.95
dirMethod · 0.95
mlsdMethod · 0.95

Calls 9

sendcmdMethod · 0.95
transfercmdMethod · 0.95
voidrespMethod · 0.95
ErrorClass · 0.70
callbackFunction · 0.70
printFunction · 0.50
makefileMethod · 0.45
readlineMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected