From fd74fbe2effa2829e39bc3aff2a55f66c6ae502f Mon Sep 17 00:00:00 2001 From: Benexl Date: Sun, 27 Jul 2025 11:48:18 +0300 Subject: [PATCH] feat: rename config path var and add dedicated folder for logs --- fastanime/cli/commands/config.py | 12 ++++++------ fastanime/cli/config/loader.py | 4 ++-- fastanime/cli/interactive/session.py | 4 ++-- fastanime/core/constants.py | 7 +++++-- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/fastanime/cli/commands/config.py b/fastanime/cli/commands/config.py index e04403e..618f27c 100644 --- a/fastanime/cli/commands/config.py +++ b/fastanime/cli/commands/config.py @@ -61,12 +61,12 @@ from ...core.config import AppConfig def config( user_config: AppConfig, path, view, view_json, desktop_entry, update, interactive ): - from ...core.constants import USER_CONFIG_PATH + from ...core.constants import USER_CONFIG from ..config.editor import InteractiveConfigEditor from ..config.generate import generate_config_ini_from_app_model if path: - print(USER_CONFIG_PATH) + print(USER_CONFIG) elif view: from rich.console import Console from rich.syntax import Syntax @@ -90,15 +90,15 @@ def config( elif interactive: editor = InteractiveConfigEditor(current_config=user_config) new_config = editor.run() - with open(USER_CONFIG_PATH, "w", encoding="utf-8") as file: + with open(USER_CONFIG, "w", encoding="utf-8") as file: file.write(generate_config_ini_from_app_model(new_config)) - click.echo(f"Configuration saved successfully to {USER_CONFIG_PATH}") + click.echo(f"Configuration saved successfully to {USER_CONFIG}") elif update: - with open(USER_CONFIG_PATH, "w", encoding="utf-8") as file: + with open(USER_CONFIG, "w", encoding="utf-8") as file: file.write(generate_config_ini_from_app_model(user_config)) print("update successfull") else: - click.edit(filename=str(USER_CONFIG_PATH)) + click.edit(filename=str(USER_CONFIG)) def _generate_desktop_entry(): diff --git a/fastanime/cli/config/loader.py b/fastanime/cli/config/loader.py index 681b060..208dd0f 100644 --- a/fastanime/cli/config/loader.py +++ b/fastanime/cli/config/loader.py @@ -6,7 +6,7 @@ import click from pydantic import ValidationError from ...core.config import AppConfig -from ...core.constants import USER_CONFIG_PATH +from ...core.constants import USER_CONFIG from ...core.exceptions import ConfigError @@ -19,7 +19,7 @@ class ConfigLoader: AppConfig object. """ - def __init__(self, config_path: Path = USER_CONFIG_PATH): + def __init__(self, config_path: Path = USER_CONFIG): """ Initializes the loader with the path to the configuration file. diff --git a/fastanime/cli/interactive/session.py b/fastanime/cli/interactive/session.py index 78b61d0..018237c 100644 --- a/fastanime/cli/interactive/session.py +++ b/fastanime/cli/interactive/session.py @@ -7,7 +7,7 @@ from typing import TYPE_CHECKING, Callable, List, Optional, Union import click from ...core.config import AppConfig -from ...core.constants import APP_DIR, USER_CONFIG_PATH +from ...core.constants import APP_DIR, USER_CONFIG from .state import InternalDirective, MenuName, State if TYPE_CHECKING: @@ -191,7 +191,7 @@ class Session: def _edit_config(self): from ..config import ConfigLoader - click.edit(filename=str(USER_CONFIG_PATH)) + click.edit(filename=str(USER_CONFIG)) logger.debug("Config changed; Reloading context") loader = ConfigLoader() config = loader.load() diff --git a/fastanime/core/constants.py b/fastanime/core/constants.py index 99c9311..a291c9d 100644 --- a/fastanime/core/constants.py +++ b/fastanime/core/constants.py @@ -74,11 +74,14 @@ else: USER_VIDEOS_DIR = xdg_videos_dir / APP_NAME USER_APPLICATIONS = Path.home() / ".local" / "share" / "applications" +LOG_FOLDER = APP_CACHE_DIR / "logs" # USER_APPLICATIONS.mkdir(parents=True,exist_ok=True) APP_DATA_DIR.mkdir(parents=True, exist_ok=True) APP_CACHE_DIR.mkdir(parents=True, exist_ok=True) +LOG_FOLDER.mkdir(parents=True, exist_ok=True) USER_VIDEOS_DIR.mkdir(parents=True, exist_ok=True) -USER_CONFIG_PATH = APP_DATA_DIR / "config.ini" -LOG_FILE_PATH = APP_CACHE_DIR / "fastanime.log" +USER_CONFIG = APP_DATA_DIR / "config.ini" + +LOG_FILE = LOG_FOLDER / "app.log"