From 26125a281f6733d08ffb488668b052ee9c20061a Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 22 May 2020 17:25:24 -0700 Subject: [PATCH] Use xdg packge to find XDG cache dir --- pinch.py | 9 ++++++--- shell.nix | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pinch.py b/pinch.py index a7d5b65..1827281 100644 --- a/pinch.py +++ b/pinch.py @@ -25,6 +25,9 @@ from typing import ( Tuple, ) +import xdg + + Digest16 = NewType('Digest16', str) Digest32 = NewType('Digest32', str) @@ -216,9 +219,9 @@ def fetch_resources(v: Verification, channel: Channel) -> None: def git_cachedir(git_repo: str) -> str: - # TODO: Consider using pyxdg to find this path. - return os.path.expanduser( - '~/.cache/pinch/git/%s' % + return os.path.join( + xdg.XDG_CACHE_HOME, + 'pinch/git', digest_string( git_repo.encode())) diff --git a/shell.nix b/shell.nix index b408ea4..11e4f03 100644 --- a/shell.nix +++ b/shell.nix @@ -1,7 +1,7 @@ { pkgs ? import { } }: pkgs.mkShell rec { doCheck = true; - buildInputs = with pkgs; [ python3 ]; + buildInputs = with pkgs; [ (python3.withPackages (ps: with ps; [ xdg ])) ]; checkInputs = with pkgs; [ mypy python3Packages.autopep8 -- 2.44.1