From 4019dd3bc4bca3bc3c7a971342122e2143f36cc6 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Tue, 23 Jan 2024 13:22:31 +0000 Subject: [PATCH] swap appdirs for platformdirs --- dkist/net/globus/auth.py | 4 ++-- dkist/net/globus/tests/test_auth.py | 10 +++++----- setup.cfg | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dkist/net/globus/auth.py b/dkist/net/globus/auth.py index 0f5dc2fd1..36114bd7b 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 3ca4e38cb..1e755c27b 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 5562ab908..fa0069c6e 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