PyFilesystem / pyfilesystem

Python filesystem abstraction layer
http://pyfilesystem.org/
BSD 3-Clause "New" or "Revised" License
287 stars 63 forks source link

Support encoding option for ftpfs #281

Open frafra opened 2 years ago

frafra commented 2 years ago

I am fetching data from a Windows FTP server, which contains some special characters.

Python built-in ftplib can use a different encoding: https://docs.python.org/3/library/ftplib.html#ftplib.FTP

class ftplib.FTP(host='', user='', passwd='', acct='', timeout=None, source_address=None, *, encoding='utf-8')¶

ftpfs does not take "encoding" as parameter:

https://github.com/PyFilesystem/pyfilesystem/blob/7dfe14ae6c3b9c53543c1c3890232d9f37579f34/fs/ftpfs.py#L1080

I propose to accept encoding as an optional parameter, which should then passed to the FTP constructor.

It would then be possible to connect to resources like: ftp://user:password@ftpserver/path?encoding=windows-1252