~sschwarzer/ftputil#37: 
Confusing behavior of isdir/isfile/islink when a path isn't found

here an example

In [22]: host=ftputil.FTPHost('ftp.microsoft.com','anonymous','test@test.com')

In [23]: lista=host.listdir('/deskapps/games/public/archive_e3/DungeonSiege&FreeLancer/Dungeon Siege')                                                                        

In [24]: lista
Out[24]:      
['Chris Taylor .doc',
 'Dungeon Siege Fact Sheet.doc',
 'Logos',                       
 'Screenshots',                 
 'Sketches']                    

In [25]: for l in lista:
   ....:     print host.path.isdir(l)
   ....:     print host.path.isfile(l)
   ....:     print host.path.islink(l)
   ....:
False
False
False
False
False
False
False
False
False
False
False
False
False
False
False

maybe the & in the pathname?

regards Nicola

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

schwa (unverified) 15 years ago ยท edit

You list a remote directory, but you don't change into it and call is*() with the relative paths returned by listdir. As Python's os.path.is*() methods, ftputil's return False if they can't find a filesystem item with the given name.

Probably the documentation should point this pitfall out, which I've also run into in the past. I added something on that to the documentation in changeset 862.

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