mirror of
https://github.com/Benexl/FastAnime.git
synced 2026-01-06 17:53:40 -08:00
feat: rename config path var and add dedicated folder for logs
This commit is contained in:
@@ -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():
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user