Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ftpwalf function

5 views
Skip to first unread message

Martin Franklin

unread,
Dec 13, 2001, 11:06:17 AM12/13/01
to

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

unread,
Dec 13, 2001, 11:22:31 AM12/13/01
to
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

unread,
Dec 13, 2001, 12:28:06 PM12/13/01
to
> 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 new messages