diff --git a/.gitignore b/.gitignore index bd59574..4925e01 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,7 @@ nosetests.xml coverage.xml *,cover .hypothesis/ +.pytest_cache/ # Translations *.mo diff --git a/setup.cfg b/setup.cfg index fadca27..c31358b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -29,7 +29,7 @@ classifiers = zip_safe = true include_package_data = true python_requires = >= 2.7, != 3.0.*, != 3.1.*, != 3.2.*, != 3.3.* -packages = fs.sshfs, fs.opener +packages = sshfs test_suite = tests setup_requires = setuptools install_requires = @@ -55,8 +55,8 @@ test = [options.entry_points] fs.opener = - ssh = fs.opener.sshfs:SSHOpener - sftp = fs.opener.sshfs:SSHOpener + ssh = sshfs.opener:SSHOpener + sftp = sshfs.opener:SSHOpener [coverage:report] show_missing = true @@ -73,7 +73,7 @@ exclude_lines = verbosity = 2 with-coverage = true cover-xml = true -cover-package = fs.sshfs, fs.opener.sshfs +cover-package = sshfs._sshfs, sshfs.opener with-doctest = true doctest-extension = .rst rednose = true diff --git a/fs/sshfs/__init__.py b/sshfs/__init__.py similarity index 91% rename from fs/sshfs/__init__.py rename to sshfs/__init__.py index 4891971..3353111 100644 --- a/fs/sshfs/__init__.py +++ b/sshfs/__init__.py @@ -4,7 +4,9 @@ from __future__ import absolute_import from __future__ import unicode_literals -from .sshfs import SSHFS +from . import opener +from ._sshfs import SSHFS + __license__ = "LGPL-2.1+" __copyright__ = "Copyright (c) 2017 Martin Larralde" diff --git a/fs/sshfs/file.py b/sshfs/_file.py similarity index 97% rename from fs/sshfs/file.py rename to sshfs/_file.py index d54c7ca..e08a47e 100644 --- a/fs/sshfs/file.py +++ b/sshfs/_file.py @@ -6,7 +6,7 @@ import io -from ..iotools import RawWrapper +from fs.iotools import RawWrapper class SSHFile(RawWrapper): diff --git a/fs/sshfs/sshfs.py b/sshfs/_sshfs.py similarity index 98% rename from fs/sshfs/sshfs.py rename to sshfs/_sshfs.py index 8e281bf..6379d92 100644 --- a/fs/sshfs/sshfs.py +++ b/sshfs/_sshfs.py @@ -13,17 +13,17 @@ import six import paramiko -from .. import errors -from ..base import FS -from ..info import Info -from ..enums import ResourceType -from ..iotools import RawWrapper -from ..path import basename -from ..permissions import Permissions -from ..osfs import OSFS -from ..mode import Mode - -from .file import SSHFile +from fs import errors +from fs.base import FS +from fs.info import Info +from fs.enums import ResourceType +from fs.iotools import RawWrapper +from fs.path import basename +from fs.permissions import Permissions +from fs.osfs import OSFS +from fs.mode import Mode + +from ._file import SSHFile from .error_tools import convert_sshfs_errors diff --git a/fs/sshfs/error_tools.py b/sshfs/error_tools.py similarity index 99% rename from fs/sshfs/error_tools.py rename to sshfs/error_tools.py index 41fc5ad..12dc24a 100644 --- a/fs/sshfs/error_tools.py +++ b/sshfs/error_tools.py @@ -9,7 +9,7 @@ import six -from .. import errors +from fs import errors class _ConvertSSHFSErrors(object): diff --git a/fs/opener/sshfs.py b/sshfs/opener.py similarity index 71% rename from fs/opener/sshfs.py rename to sshfs/opener.py index 5a9e800..a6c0019 100644 --- a/fs/opener/sshfs.py +++ b/sshfs/opener.py @@ -6,25 +6,9 @@ import six -from .base import Opener -from ..subfs import ClosingSubFS -from ..errors import FSError, CreateFailed - -__license__ = "LGPL-2.1+" -__copyright__ = "Copyright (c) 2017 Martin Larralde" -__author__ = "Martin Larralde " -__version__ = 'dev' - - -# Dynamically get the version of the main module -try: - _name = __name__.replace('.opener', '') - import pkg_resources - __version__ = pkg_resources.get_distribution(_name).version -except Exception: # pragma: no cover - pkg_resources = None -finally: - del pkg_resources +from fs.opener.base import Opener +from fs.subfs import ClosingSubFS +from fs.errors import FSError, CreateFailed class SSHOpener(Opener): @@ -32,7 +16,7 @@ class SSHOpener(Opener): @staticmethod def open_fs(fs_url, parse_result, writeable, create, cwd): - from ..sshfs import SSHFS + from ._sshfs import SSHFS ssh_host, _, dir_path = parse_result.resource.partition('/') ssh_host, _, ssh_port = ssh_host.partition(':') ssh_port = int(ssh_port) if ssh_port.isdigit() else 22 diff --git a/tests/__init__.py b/tests/__init__.py index 903804d..47fcef7 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -7,16 +7,9 @@ import pkg_resources -# Add the local code directory to the `fs` module path -fs.__path__.insert(0, os.path.realpath( - os.path.join(__file__, '..', '..', 'fs'))) -fs.opener.__path__.insert(0, os.path.realpath( - os.path.join(__file__, '..', '..', 'fs', 'opener'))) - - # Add additional openers to the entry points pkg_resources.get_entry_map('fs', 'fs.opener')['ssh'] = \ pkg_resources.EntryPoint.parse( - 'ssh = fs.opener.sshfs:SSHOpener', + 'ssh = sshfs.opener:SSHOpener', dist=pkg_resources.get_distribution('fs') ) diff --git a/tests/test_opener.py b/tests/test_opener.py index 10d513f..e213bd3 100644 --- a/tests/test_opener.py +++ b/tests/test_opener.py @@ -11,7 +11,7 @@ import fs.errors import fs.path -from fs.sshfs import SSHFS +from sshfs import SSHFS from . import utils diff --git a/tests/test_sshfs.py b/tests/test_sshfs.py index 6ad2d5c..b3bfbc2 100644 --- a/tests/test_sshfs.py +++ b/tests/test_sshfs.py @@ -11,9 +11,9 @@ import fs.path import fs.test import fs.errors -from fs.sshfs import SSHFS from fs.subfs import ClosingSubFS from fs.permissions import Permissions +from sshfs import SSHFS from . import utils diff --git a/tests/test_url.py b/tests/test_url.py index 456c062..3248f9c 100644 --- a/tests/test_url.py +++ b/tests/test_url.py @@ -16,14 +16,14 @@ class TestFSURL(unittest.TestCase): port = 2224 def test_timeout(self): - with utils.mock.patch('fs.sshfs.SSHFS', utils.mock.MagicMock()) as magic: + with utils.mock.patch('sshfs.SSHFS', utils.mock.MagicMock()) as magic: fs.open_fs('ssh://user:pass@localhost:2224/?timeout=1') self.assertEqual(magic.call_args[-1]['timeout'], 1) fs.open_fs('ssh://user:pass@localhost:2224/?compress=1&timeout=5') self.assertEqual(magic.call_args[-1]['timeout'], 5) def test_compress(self): - with utils.mock.patch('fs.sshfs.SSHFS', utils.mock.MagicMock()) as magic: + with utils.mock.patch('sshfs.SSHFS', utils.mock.MagicMock()) as magic: fs.open_fs('ssh://user:pass@localhost:2224/?compress=true') self.assertEqual(magic.call_args[-1]['compress'], True) fs.open_fs('ssh://user:pass@localhost:2224/?timeout=5&compress=1')