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

Method mlsd

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

List a directory in a standardized format by using MLSD command (RFC-3659). If path is omitted the current directory is assumed. "facts" is a list of strings representing the type of information desired (e.g. ["type", "size", "perm"]). Return a generator object

(self, path="", facts=[])

Source from the content-addressed store, hash-verified

569 self.retrlines(cmd, func)
570
571 def mlsd(self, path="", facts=[]):
572 '''List a directory in a standardized format by using MLSD
573 command (RFC-3659). If path is omitted the current directory
574 is assumed. "facts" is a list of strings representing the type
575 of information desired (e.g. ["type", "size", "perm"]).
576
577 Return a generator object yielding a tuple of two elements
578 for every file found in path.
579 First element is the file name, the second one is a dictionary
580 including a variable number of "facts" depending on the server
581 and whether "facts" argument has been provided.
582 '''
583 if facts:
584 self.sendcmd("OPTS MLST " + ";".join(facts) + ";")
585 if path:
586 cmd = "MLSD %s" % path
587 else:
588 cmd = "MLSD"
589 lines = []
590 self.retrlines(cmd, lines.append)
591 for line in lines:
592 facts_found, _, name = line.rstrip(CRLF).partition(' ')
593 entry = {}
594 for fact in facts_found[:-1].split(";"):
595 key, _, value = fact.partition("=")
596 entry[key.lower()] = value
597 yield (name, entry)
598
599 def rename(self, fromname, toname):
600 '''Rename a file.'''

Callers

nothing calls this directly

Calls 7

sendcmdMethod · 0.95
retrlinesMethod · 0.95
partitionMethod · 0.80
joinMethod · 0.45
rstripMethod · 0.45
splitMethod · 0.45
lowerMethod · 0.45

Tested by

no test coverage detected