Opened 5 years ago

Closed 5 years ago

#92 closed enhancement (fixed)

Docs for walk()

Reported by: ftputiluser Owned by: schwa
Priority: minor Milestone: 3.3
Component: Documentation Version:
Keywords: local paths, remote paths Cc:

Description

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

http://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).

Change History (3)

comment:1 Changed 5 years ago by schwa

Keywords: local paths remote paths added
Milestone: 3.3
Priority: majorminor
Status: newassigned

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)

comment:2 in reply to:  1 Changed 5 years ago by schwa

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 [6b49dedd1dcf].

Last edited 5 years ago by schwa (previous) (diff)

comment:3 Changed 5 years ago by schwa

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.