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

Method mlsd

Lib/ftplib.py:565–591  ·  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 yield

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

Source from the content-addressed store, hash-verified

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

Callers 2

test_mlsdMethod · 0.80
test_entryMethod · 0.80

Calls 7

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

Tested by 2

test_mlsdMethod · 0.64
test_entryMethod · 0.64