at master 973 B view raw
1diff --git a/unidic/download.py b/unidic/download.py 2index 445ce55..d488bd6 100644 3--- a/unidic/download.py 4+++ b/unidic/download.py 5@@ -6,6 +6,8 @@ import sys 6 from wasabi import msg 7 from urllib.request import urlretrieve 8 from tqdm import tqdm 9+from platformdirs import user_cache_dir 10+from pathlib import Path 11 12 # This is used to show progress when downloading. 13 # see here: https://github.com/tqdm/tqdm#hooks-and-callbacks 14@@ -56,7 +58,8 @@ def download_and_clean(version, url, dirname='unidic', delfiles=[]): 15 This downloads the zip file from the source, extracts it, renames the 16 resulting directory, and removes large files not used at runtime. 17 """ 18- cdir = os.path.dirname(os.path.abspath(__file__)) 19+ cdir = Path(user_cache_dir('unidic-py')) 20+ cdir.mkdir(parents=True, exist_ok=True) 21 fname = os.path.join(cdir, 'unidic.zip') 22 print("Downloading UniDic v{}...".format(version), file=sys.stderr) 23 download_progress(url, fname)