~sschwarzer/ftputil#92: 
Docs for walk()

It would be very nice to have an example for walk():

https://ftputil.sschwarzer.net/trac/wiki/Documentation#ftphost-walk

Background: I am not sure how to join the remote path segments. Can I just use os.path.join()? I am not sure if this works if local client is linux and remote is windows (or vice versa).

Status
RESOLVED FIXED
Submitter
ftputiluser (unverified)
Assigned to
No-one
Submitted
9 years ago
Updated
9 years ago
Labels
documentation enhancement

schwa (unverified) 9 years ago · edit

Sorry, somehow I missed this ticket.

I think this shouldn't be handled as a question regarding FTPHost.walk since that concrete method is only one example of the confusion. :-)

ftputil is supposed to work the same like the os module if you replace os with the FTPHost instance. Use os for operations on the local file system and the FTPHost instance for operations on the remote file system.

So to join paths intended for operations on the FTP server, you'd use ftp_host.path.join, where ftp_host is an FTPHost instance:

dir = "/some/remote/dir"
file = "some_file.txt"
joined_path = ftp_host.path.join(dir, file)

schwa (unverified) 9 years ago · edit

Replying to schwa:

ftputil is supposed to work the same like the os module if you replace os with the FTPHost instance. Use os for operations on the local file system and the FTPHost instance for operations on the remote file system.

I've added an example to the "ftputil features" section with commit fd53db64040d9c2e2dcfeb533d71d934120f1e0f.

Register here or Log in to comment, or comment via email.