ftpwalf function
Martin Franklin
martin.franklin at westgeo.com
Thu Dec 13 11:06:17 EST 2001
Hi,
Just came up with this function, don't know where else to put it so ......
def ftpwalk(ftp, top, func, arg):
''' ftpwalk just like os.path.walk functions...
first argumant is the ftp object, second and
subsequent are same as os.path.walk
'''
try:
ftp.cwd(top)
except:
return # not a directory?? this must be the end.....
names=ftp.nlst(top)
func(arg, top, names)
for name in names:
name = os.path.join(top, name)
try:
ftp.cwd(name)
except:
continue
ftpwalk(ftp, name, func, arg)
Martin
More information about the Python-list
mailing list