FTP filename escaping

Almad bugs at almad.net
Thu May 11 15:24:19 EDT 2006


Hello,

I feel ashamed, but my google-fu betrayed me again.

How do I escape filenames when using ftplib? I'd like to download it
and upload on ftp again...
        toDown = self.ftpMaster.nlst()
        for fileDown in toDown:
            f = tmpfile()
            # download
            self.ftpMaster.retrbinary(''.join(['RETR ', fileDown]),
f.write)
            f.seek(0)
            self.ftpMirror.storbinary(''.join(["STOR ", fileDown]), f,
1024)
            f.close()

Problem is when fileDown contains special characters / spaces and so
on. I hoped for some ftplib.quote(), urllib.quote() or quote_plus() is
not functional either.

Is there such a function in stdlib or do I have to read through
specification and write it? 

Thank You, 

Almad




More information about the Python-list mailing list