From 3b8fb8531e671e3febb0436498484bd59a10c17e Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Wed, 28 Jun 2023 09:57:49 -0400 Subject: [PATCH] gsetup: Add a CACHE_DIR path This points to the user's ~/.cache directory where Emmental can store files. Signed-off-by: Anna Schumaker --- emmental/gsetup.py | 3 +++ tests/test_gsetup.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/emmental/gsetup.py b/emmental/gsetup.py index 4acd92a..a12e9fb 100644 --- a/emmental/gsetup.py +++ b/emmental/gsetup.py @@ -24,6 +24,9 @@ CSS_PRIORITY = gi.repository.Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION CSS_PROVIDER = gi.repository.Gtk.CssProvider() CSS_PROVIDER.load_from_path(str(CSS_FILE)) +CACHE_DIR = pathlib.Path(xdg.BaseDirectory.save_cache_path("emmental")) +CACHE_DIR = CACHE_DIR / DEBUG_STR.lstrip("-") + DATA_DIR = pathlib.Path(xdg.BaseDirectory.save_data_path("emmental")) RESOURCE_PATH = "/com/nowheycreamery/emmental" diff --git a/tests/test_gsetup.py b/tests/test_gsetup.py index f3ae666..5d4d2db 100644 --- a/tests/test_gsetup.py +++ b/tests/test_gsetup.py @@ -62,6 +62,12 @@ class TestGSetup(unittest.TestCase): self.assertIsInstance(emmental.gsetup.RESOURCE, gi.repository.Gio.Resource) + def test_cache_dir(self): + """Check that the CACHE_DIR points to the right place.""" + cache_path = xdg.BaseDirectory.save_cache_path("emmental") + self.assertEqual(emmental.gsetup.CACHE_DIR, + pathlib.Path(cache_path) / "debug") + def test_data_dir(self): """Check that the DATA_DIR points to the right place.""" data_path = xdg.BaseDirectory.save_data_path("emmental")