From 5bafc28b7bc122272cd76575a68bdf419e8588a6 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Tue, 23 Jan 2024 17:05:15 +0000 Subject: [PATCH] swap appdirs for platformdirs (#318) * swap appdirs for platformdirs * Add changelog --- changelog/318.bugfix.rst | 1 + dkist/net/globus/auth.py | 4 ++-- dkist/net/globus/tests/test_auth.py | 10 +++++----- setup.cfg | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 changelog/318.bugfix.rst diff --git a/changelog/318.bugfix.rst b/changelog/318.bugfix.rst new file mode 100644 index 00000000..af5379c3 --- /dev/null +++ b/changelog/318.bugfix.rst @@ -0,0 +1 @@ +Change the ``appdirs`` dependancy for the maintained ``platformdirs`` package. diff --git a/dkist/net/globus/auth.py b/dkist/net/globus/auth.py index 0f5dc2fd..36114bd7 100644 --- a/dkist/net/globus/auth.py +++ b/dkist/net/globus/auth.py @@ -14,8 +14,8 @@ from http.server import HTTPServer, BaseHTTPRequestHandler from urllib.parse import parse_qs, urlparse -import appdirs import globus_sdk +import platformdirs CLIENT_ID = 'dd2d62af-0b44-4e2e-9454-1092c94b46b3' SCOPES = ('urn:globus:auth:scope:transfer.api.globus.org:all', @@ -80,7 +80,7 @@ def get_cache_file_path(): """ Use appdirs to get the cache path for the user and add the filename. """ - cache_dir = Path(appdirs.user_cache_dir("dkist")) + cache_dir = Path(platformdirs.user_cache_dir("dkist")) return cache_dir / "globus_auth_cache.json" diff --git a/dkist/net/globus/tests/test_auth.py b/dkist/net/globus/tests/test_auth.py index 3ca4e38c..1e755c27 100644 --- a/dkist/net/globus/tests/test_auth.py +++ b/dkist/net/globus/tests/test_auth.py @@ -24,7 +24,7 @@ def test_http_server(): def test_get_cache_file_path(mocker): - mocker.patch("appdirs.user_cache_dir", return_value="/tmp/test/") + mocker.patch("platformdirs.user_cache_dir", return_value="/tmp/test/") path = get_cache_file_path() assert isinstance(path, pathlib.Path) @@ -33,7 +33,7 @@ def test_get_cache_file_path(mocker): def test_get_no_cache(mocker, tmpdir): - mocker.patch("appdirs.user_cache_dir", return_value=str(tmpdir)) + mocker.patch("platformdirs.user_cache_dir", return_value=str(tmpdir)) # Test file not exists cache = get_cache_contents() assert isinstance(cache, dict) @@ -41,7 +41,7 @@ def test_get_no_cache(mocker, tmpdir): def test_get_cache(mocker, tmpdir): - mocker.patch("appdirs.user_cache_dir", return_value=str(tmpdir)) + mocker.patch("platformdirs.user_cache_dir", return_value=str(tmpdir)) with open(tmpdir / "globus_auth_cache.json", "w") as fd: json.dump({"hello": "world"}, fd) @@ -52,7 +52,7 @@ def test_get_cache(mocker, tmpdir): def test_get_cache_not_json(mocker, tmpdir): - mocker.patch("appdirs.user_cache_dir", return_value=str(tmpdir)) + mocker.patch("platformdirs.user_cache_dir", return_value=str(tmpdir)) with open(tmpdir / "globus_auth_cache.json", "w") as fd: fd.write("aslkjdasdjjdlsajdjklasjdj, akldjaskldjasd, lkjasdkljasldkjas") @@ -64,7 +64,7 @@ def test_get_cache_not_json(mocker, tmpdir): def test_save_auth_cache(mocker, tmpdir): filename = tmpdir / "globus_auth_cache.json" assert not filename.exists() # Sanity check - mocker.patch("appdirs.user_cache_dir", return_value=str(tmpdir)) + mocker.patch("platformdirs.user_cache_dir", return_value=str(tmpdir)) save_auth_cache({"hello": "world"}) assert filename.exists() diff --git a/setup.cfg b/setup.cfg index 5562ab90..fa0069c6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,7 +22,7 @@ packages = find: include_package_data = True install_requires = aiohttp>=3.6 - appdirs>=1.4 + platformdirs>=3.0 asdf>=2.11.2 # Pick up jsonschema bug fix asdf-astropy>=0.2.0 asdf-transform-schemas>=0.3.0