Skip to content

Commit 0c0b9b5

Browse files
Pairprogramming with Matthijs
1 parent 76a3d2e commit 0c0b9b5

File tree

4 files changed

+22
-199
lines changed

4 files changed

+22
-199
lines changed

docs/source/api.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,6 @@ Built-in Implementations
162162
.. autoclass:: fsspec.implementations.ftp.FTPFileSystem
163163
:members: __init__
164164

165-
.. autoclass:: fsspec.implementations.ftp.FTPTLSFileSystem
166-
:members: __init__
167-
168165
.. autoclass:: fsspec.implementations.git.GitFileSystem
169166
:members: __init__
170167

fsspec/implementations/ftp.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ def __init__(
2727
tempdir=None,
2828
timeout=30,
2929
encoding="utf-8",
30-
ssl=False,
31-
prot_p=False,
30+
tls=False,
3231
**kwargs,
3332
):
3433
"""
@@ -58,26 +57,28 @@ def __init__(
5857
Timeout of the ftp connection in seconds
5958
encoding: str
6059
Encoding to use for directories and filenames in FTP connection
60+
tls: bool
61+
Use FTP-TLS, by default False
6162
"""
6263
super().__init__(**kwargs)
6364
self.host = host
6465
self.port = port
6566
self.tempdir = tempdir or "/tmp"
66-
self.cred = username, password, acct
67+
self.cred = username or "", password or "", acct or ""
68+
print(self.cred)
6769
self.timeout = timeout
6870
self.encoding = encoding
6971
if block_size is not None:
7072
self.blocksize = block_size
7173
else:
7274
self.blocksize = 2**16
73-
self.ssl = ssl
74-
self.prot_p = prot_p
75+
self.tls = tls
7576
self._connect()
76-
if self.prot_p:
77+
if self.tls:
7778
self.ftp.prot_p()
7879

7980
def _connect(self):
80-
if self.ssl:
81+
if self.tls:
8182
ftp_cls = FTP_TLS
8283
else:
8384
ftp_cls = FTP

fsspec/implementations/tests/test_ftp.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import subprocess
33
import sys
44
import time
5+
from ftplib import FTP, FTP_TLS
56

67
import pytest
78

@@ -29,6 +30,19 @@ def ftp():
2930
P.wait()
3031

3132

33+
@pytest.mark.parametrize(
34+
"tls,exp_cls",
35+
(
36+
(False, FTP),
37+
(True, FTP_TLS),
38+
),
39+
)
40+
def test_tls(ftp, tls, exp_cls):
41+
host, port = ftp
42+
fs = FTPFileSystem(host, port, tls=tls)
43+
assert isinstance(fs.ftp, exp_cls)
44+
45+
3246
def test_basic(ftp):
3347
host, port = ftp
3448
fs = FTPFileSystem(host, port)

fsspec/implementations/tests/test_ftp_tls.py

Lines changed: 0 additions & 189 deletions
This file was deleted.

0 commit comments

Comments
 (0)