smart_open
smart_open copied to clipboard
Support for reading and writing files directly to/from ftp
Title
Support for reading and writing files directly to/from ftp
Motivation
As elaborated in issue #33, there is currently no support for reading from ftp servers. With my change, developers will be able to read ftp files using smart open by doing the following:
from smart_open import open
with open('ftp://user:password@host:port/dir1/dir2/file') as fin:
for line in fin:
print(line)
Tests
Added test_ftp::FTPOpen
@mpenkov @petedannemann
Just to summarize the changes that I have made:
- I have added integration tests which bring up an FTP server and tests reading, writing and appending to it.
- I have created a wrapper around the file object returned by
open("ftp://...")
so that when the file is closed, the underlying socket is closed as well - For bringing up the FTP server during ci tests, there doesn't seem to be any viable lightweight solutions, besides perhaps twisted.
Let me know if there is anything that you think should be changed or added.
@petedannemann Thank you! I have added your recommended changes. Let me know if you have any questions or if anything is confusing.
@mpenkov Do these changes look good to you?
@mpenkov Thank you for the suggestions. I have integrated the changes. Let me know if there is anything else that should be added.
Thank you for your work @RachitSharma2001 !!