From 2b3b0b05cd726f76b4d111ab691036f78bc5d240 Mon Sep 17 00:00:00 2001 From: Martin Larralde Date: Mon, 2 May 2022 10:09:23 +0200 Subject: [PATCH] Revert switch from `appdirs` to `platformdirs` for backward compatibility --- CHANGELOG.md | 2 -- fs/appfs.py | 6 +++--- setup.cfg | 2 +- tests/test_appfs.py | 2 +- tests/test_opener.py | 6 +++--- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98660f83..c9325628 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed -- Replaced `appdirs` with `platformdirs` dependency - ([#489](https://github.com/PyFilesystem/pyfilesystem2/pull/489)). - Make `fs.zipfs._ZipExtFile` use the seeking mechanism implemented in the Python standard library in Python version 3.7 and later ([#527](https://github.com/PyFilesystem/pyfilesystem2/pull/527)). diff --git a/fs/appfs.py b/fs/appfs.py index 4c337e44..131ea8a8 100644 --- a/fs/appfs.py +++ b/fs/appfs.py @@ -5,7 +5,7 @@ subclasses of `~fs.osfs.OSFS`. """ -# Thanks to authors of https://pypi.org/project/platformdirs +# Thanks to authors of https://pypi.org/project/appdirs # see http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx @@ -16,7 +16,7 @@ from .osfs import OSFS from ._repr import make_repr -from platformdirs import PlatformDirs +from appdirs import AppDirs if typing.TYPE_CHECKING: from typing import Optional, Text @@ -78,7 +78,7 @@ def __init__( will be created if it does not exist. """ - self.app_dirs = PlatformDirs(appname, author, version, roaming) + self.app_dirs = AppDirs(appname, author, version, roaming) self._create = create super(_AppFS, self).__init__( getattr(self.app_dirs, self.app_dir), create=create diff --git a/setup.cfg b/setup.cfg index 1da24f30..d67bb927 100644 --- a/setup.cfg +++ b/setup.cfg @@ -42,7 +42,7 @@ packages = find: setup_requires = setuptools >=38.3.0 install_requires = - platformdirs~=2.0.2 + appdirs~=1.4.3 setuptools six ~=1.10 enum34 ~=1.1.6 ; python_version < '3.4' diff --git a/tests/test_appfs.py b/tests/test_appfs.py index 8cf4b9eb..acc8a7f7 100644 --- a/tests/test_appfs.py +++ b/tests/test_appfs.py @@ -30,7 +30,7 @@ def tearDownClass(cls): def make_fs(self): with mock.patch( - "platformdirs.{}".format(self.AppFS.app_dir), + "appdirs.{}".format(self.AppFS.app_dir), autospec=True, spec_set=True, return_value=tempfile.mkdtemp(dir=self.tmpdir), diff --git a/tests/test_opener.py b/tests/test_opener.py index 49b1a50d..bc2f5cd7 100644 --- a/tests/test_opener.py +++ b/tests/test_opener.py @@ -264,7 +264,7 @@ def test_open_fs(self): mem_fs_2 = opener.open_fs(mem_fs) self.assertEqual(mem_fs, mem_fs_2) - @mock.patch("platformdirs.{}".format(UserDataFS.app_dir), autospec=True, spec_set=True) + @mock.patch("appdirs.{}".format(UserDataFS.app_dir), autospec=True, spec_set=True) def test_open_userdata(self, app_dir): app_dir.return_value = self.tmpdir @@ -276,7 +276,7 @@ def test_open_userdata(self, app_dir): self.assertEqual(app_fs.app_dirs.appauthor, "willmcgugan") self.assertEqual(app_fs.app_dirs.version, "1.0") - @mock.patch("platformdirs.{}".format(UserDataFS.app_dir), autospec=True, spec_set=True) + @mock.patch("appdirs.{}".format(UserDataFS.app_dir), autospec=True, spec_set=True) def test_open_userdata_no_version(self, app_dir): app_dir.return_value = self.tmpdir @@ -285,7 +285,7 @@ def test_open_userdata_no_version(self, app_dir): self.assertEqual(app_fs.app_dirs.appauthor, "willmcgugan") self.assertEqual(app_fs.app_dirs.version, None) - @mock.patch("platformdirs.{}".format(UserDataFS.app_dir), autospec=True, spec_set=True) + @mock.patch("appdirs.{}".format(UserDataFS.app_dir), autospec=True, spec_set=True) def test_user_data_opener(self, app_dir): app_dir.return_value = self.tmpdir