Skip to content

Commit

Permalink
Pairprogramming with Matthijs
Browse files Browse the repository at this point in the history
  • Loading branch information
bartvaneswhiffle committed Aug 8, 2024
1 parent 76a3d2e commit 0c0b9b5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 199 deletions.
3 changes: 0 additions & 3 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,6 @@ Built-in Implementations
.. autoclass:: fsspec.implementations.ftp.FTPFileSystem
:members: __init__

.. autoclass:: fsspec.implementations.ftp.FTPTLSFileSystem
:members: __init__

.. autoclass:: fsspec.implementations.git.GitFileSystem
:members: __init__

Expand Down
15 changes: 8 additions & 7 deletions fsspec/implementations/ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def __init__(
tempdir=None,
timeout=30,
encoding="utf-8",
ssl=False,
prot_p=False,
tls=False,
**kwargs,
):
"""
Expand Down Expand Up @@ -58,26 +57,28 @@ def __init__(
Timeout of the ftp connection in seconds
encoding: str
Encoding to use for directories and filenames in FTP connection
tls: bool
Use FTP-TLS, by default False
"""
super().__init__(**kwargs)
self.host = host
self.port = port
self.tempdir = tempdir or "/tmp"
self.cred = username, password, acct
self.cred = username or "", password or "", acct or ""
print(self.cred)
self.timeout = timeout
self.encoding = encoding
if block_size is not None:
self.blocksize = block_size
else:
self.blocksize = 2**16
self.ssl = ssl
self.prot_p = prot_p
self.tls = tls
self._connect()
if self.prot_p:
if self.tls:
self.ftp.prot_p()

def _connect(self):
if self.ssl:
if self.tls:
ftp_cls = FTP_TLS
else:
ftp_cls = FTP
Expand Down
14 changes: 14 additions & 0 deletions fsspec/implementations/tests/test_ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import subprocess
import sys
import time
from ftplib import FTP, FTP_TLS

import pytest

Expand Down Expand Up @@ -29,6 +30,19 @@ def ftp():
P.wait()


@pytest.mark.parametrize(
"tls,exp_cls",
(
(False, FTP),
(True, FTP_TLS),
),
)
def test_tls(ftp, tls, exp_cls):
host, port = ftp
fs = FTPFileSystem(host, port, tls=tls)
assert isinstance(fs.ftp, exp_cls)


def test_basic(ftp):
host, port = ftp
fs = FTPFileSystem(host, port)
Expand Down
189 changes: 0 additions & 189 deletions fsspec/implementations/tests/test_ftp_tls.py

This file was deleted.

0 comments on commit 0c0b9b5

Please sign in to comment.