I'm familiar with ftplib and it works开发者_JS百科 great for simple interface but I need file properties and basically a rich ftp client. does anyone know of a good ftp client library?
Use the MLSD command. You have to parse it yourself but it's fairly easy.
# Note that portions of MLSD data are case insensitive...
def parseinfo(info):
for fact in info.split(';'):
if not fact:
continue
name, value = fact.split('=', 1)
yield name.lower(), value
ftp = ftplib.FTP(host, user, passwd)
dirinfo = {}
def callback(line):
info, fname = line.split(' ', 1)
dirinfo[fname] = dict(parseinfo(info))
ftp.retrlines('MLSD {}'.format(path), callback)
print(dirinfo)
That's about as rich as FTP gets.
The ftputil could be what you are looking for:
The FTPHost objects generated with ftputil allow many operations similar to those of os and os.path.
The API supports well file information gathering.
精彩评论