Skip to content

Commit

Permalink
Merge pull request #12 from daltonmaag/platform-dirs
Browse files Browse the repository at this point in the history
 Use operating system application cache directories (`platformdirs` edition)
  • Loading branch information
simoncozens authored Dec 20, 2024
2 parents 4585e87 + cad8086 commit 18ee1db
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/youseedee/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import zipfile
from pathlib import Path

import platformdirs
import requests
from filelock import FileLock

Expand Down Expand Up @@ -37,8 +38,8 @@ def bisect_key(haystack, needle, key):

def ucd_dir():
"""Return the directory where Unicode data is stored"""
ucddir = Path("~/.youseedee").expanduser()
ucddir.mkdir(exist_ok=True)
ucddir = Path(platformdirs.user_cache_dir("youseedee"))
ucddir.mkdir(exist_ok=True, parents=True)
return ucddir


Expand Down
3 changes: 1 addition & 2 deletions lib/youseedee/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import argparse
import sys
import os
from filelock import FileLock

from youseedee import ucd_data, _download_files, ucd_dir
Expand All @@ -21,7 +20,7 @@ def main(args=None):

args = parser.parse_args(args)
if args.force_download:
file_lock = FileLock(os.path.join(ucd_dir(), ".youseedee_ensure_files.lock"))
file_lock = FileLock(ucd_dir() / ".youseedee_ensure_files.lock")
with file_lock:
_download_files()
char = sys.argv[1]
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ authors = [{ name = "Simon Cozens", email = "[email protected]" }]
readme = { file = "README.md", content-type = "text/markdown" }

keywords = []
dependencies = ["requests", "filelock"]
dependencies = [
"requests",
"filelock",
"platformdirs>=4.3",
]

[project.urls]
homepage = "https://pypi.org/project/youseedee"
Expand Down

0 comments on commit 18ee1db

Please sign in to comment.