gsetup: Add a CACHE_DIR path

This points to the user's ~/.cache directory where Emmental can store
files.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2023-06-28 09:57:49 -04:00
parent 3e73ce0650
commit 3b8fb8531e
2 changed files with 9 additions and 0 deletions

View File

@ -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"

View File

@ -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")