diff --git a/jsoncache/ApplicationCache.py b/jsoncache/ApplicationCache.py index 902ae39..62112f9 100644 --- a/jsoncache/ApplicationCache.py +++ b/jsoncache/ApplicationCache.py @@ -10,10 +10,16 @@ import time # tries to follow XDG Base Directory Specification, if it fails due to a missing module, uses default cache dir ~/.cache try: - import xdg - CACHE_DIR = xdg.xdg_cache_home() + # pip package: pyxdg + import xdg.BaseDirectory + CACHE_DIR = Path(xdg.BaseDirectory.xdg_cache_home) except ModuleNotFoundError: - CACHE_DIR = Path.home() / ".cache" + try: + # pip package: xdg + import xdg + CACHE_DIR = xdg.xdg_cache_home() + except ModuleNotFoundError: + CACHE_DIR = Path.home() / ".cache" GZIP_MAGIC_NUMBER = b'\x1f\x8b' IDENTITY = lambda x: x