开发者

Is there a rich ftp client library for Python?

开发者 https://www.devze.com 2023-03-16 16:50 出处:网络
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 com

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号