From eda39186d4c2b2a248bb116da5f9280e4432d1ed Mon Sep 17 00:00:00 2001 From: Hellow Date: Thu, 13 Apr 2023 19:22:54 +0200 Subject: [PATCH] added config directory, and a new dependency --- requirements.txt | 3 ++- src/music_kraken/utils/path_manager/config_directory.py | 7 +++++++ src/music_kraken/utils/path_manager/locations.py | 8 ++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 src/music_kraken/utils/path_manager/config_directory.py diff --git a/requirements.txt b/requirements.txt index bea15a9..be0f7b7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,4 +12,5 @@ SQLAlchemy setuptools~=60.2.0 tqdm~=4.65.0 peewee~=3.15.4 -ffmpeg-python~=0.2.0 \ No newline at end of file +ffmpeg-python~=0.2.0 +platformdirs~=3.2.0 \ No newline at end of file diff --git a/src/music_kraken/utils/path_manager/config_directory.py b/src/music_kraken/utils/path_manager/config_directory.py new file mode 100644 index 0000000..eb450a7 --- /dev/null +++ b/src/music_kraken/utils/path_manager/config_directory.py @@ -0,0 +1,7 @@ +from pathlib import Path + +import platformdirs + + +def get_config_directory(application_name: str) -> Path: + return platformdirs.user_config_path(appname=application_name) diff --git a/src/music_kraken/utils/path_manager/locations.py b/src/music_kraken/utils/path_manager/locations.py index 7afaa42..a53ef3e 100644 --- a/src/music_kraken/utils/path_manager/locations.py +++ b/src/music_kraken/utils/path_manager/locations.py @@ -4,14 +4,18 @@ import os import tempfile from .music_directory import get_music_directory +from .config_directory import get_config_directory class Locations: - def __init__(self, temp_folder_name: os.PathLike = "music-downloader"): - self.TEMP_DIRECTORY = Path(tempfile.gettempdir(), temp_folder_name) + def __init__(self, application_name: os.PathLike = "music-kraken"): + self.TEMP_DIRECTORY = Path(tempfile.gettempdir(), application_name) self.TEMP_DIRECTORY.mkdir(exist_ok=True) self.MUSIC_DIRECTORY = get_music_directory() + self.CONFIG_DIRECTORY = get_config_directory(str(application_name)) + self.CONFIG_DIRECTORY.mkdir(exist_ok=True) + def get_log_file(self, file_name: os.PathLike) -> Path: return Path(self.TEMP_DIRECTORY, file_name)