Google Groups unterstützt keine neuen Usenet-Beiträge oder ‑Abos mehr. Bisherige Inhalte sind weiterhin sichtbar.

ftpwalf function

5 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Martin Franklin

ungelesen,
13.12.2001, 11:06:1713.12.01
an

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

Markus Schaber

ungelesen,
13.12.2001, 11:22:3113.12.01
an
Hi,

Martin Franklin wrote in comp.lang.python:

> Hi,
>
> Just came up with this function, don't know where else to put it so
> ......

Maybe you should submit it to the ftp object maintainer for inclusion.

Markus

--
"GPL software is not free - the cost is cooperation"

Daniel Dittmar

ungelesen,
13.12.2001, 12:28:0613.12.01
an
> Just came up with this function, don't know where else to put it so ......

You could put it into the Python Cookbook:
http://aspn.activestate.com/ASPN/Cookbook/Python

or at faqts: http://www.faqts.com/knowledge_base/index.phtml/fid/545.

Daniel

0 neue Nachrichten