mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-12 15:50:01 -08:00
feat: new config logic
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import sys
|
||||
import importlib.metadata
|
||||
import sys
|
||||
|
||||
if sys.version_info < (3, 10):
|
||||
raise ImportError(
|
||||
|
||||
@@ -2,11 +2,11 @@ import click
|
||||
from click.core import ParameterSource
|
||||
|
||||
from .. import __version__
|
||||
from .utils.lazyloader import LazyGroup
|
||||
from .utils.logging import setup_logging
|
||||
from .config import AppConfig, ConfigLoader
|
||||
from .constants import USER_CONFIG_PATH
|
||||
from .options import options_from_model
|
||||
from .utils.lazyloader import LazyGroup
|
||||
from .utils.logging import setup_logging
|
||||
|
||||
commands = {
|
||||
"config": ".config",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import click
|
||||
|
||||
from ...utils.tools import FastAnimeRuntimeState
|
||||
from ...utils.lazyloader import LazyGroup
|
||||
from ...utils.tools import FastAnimeRuntimeState
|
||||
|
||||
commands = {
|
||||
"trending": "trending.trending",
|
||||
|
||||
@@ -44,8 +44,8 @@ from ..config.model import AppConfig
|
||||
)
|
||||
@click.pass_obj
|
||||
def config(user_config: AppConfig, path, view, desktop_entry, update):
|
||||
from ..constants import USER_CONFIG_PATH
|
||||
from ..config.generate import generate_config_ini_from_app_model
|
||||
from ..constants import USER_CONFIG_PATH
|
||||
|
||||
print(user_config.mpv.args)
|
||||
if path:
|
||||
@@ -66,17 +66,16 @@ def _generate_desktop_entry():
|
||||
"""
|
||||
Generates a desktop entry for FastAnime.
|
||||
"""
|
||||
from ... import __version__
|
||||
import sys
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from textwrap import dedent
|
||||
|
||||
from rich import print
|
||||
from rich.prompt import Confirm
|
||||
|
||||
from ... import __version__
|
||||
from ..constants import APP_NAME, ICON_PATH, PLATFORM
|
||||
|
||||
FASTANIME_EXECUTABLE = shutil.which("fastanime")
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
from .model import AppConfig
|
||||
import textwrap
|
||||
from pathlib import Path
|
||||
|
||||
from ..constants import APP_ASCII_ART
|
||||
from .model import AppConfig
|
||||
|
||||
# The header for the config file.
|
||||
config_asci = "\n".join([f"# {line}" for line in APP_ASCII_ART.split()])
|
||||
|
||||
@@ -6,8 +6,8 @@ from pydantic import ValidationError
|
||||
|
||||
from ...core.exceptions import ConfigError
|
||||
from ..constants import USER_CONFIG_PATH
|
||||
from .model import AppConfig
|
||||
from .generate import generate_config_ini_from_app_model
|
||||
from .model import AppConfig
|
||||
|
||||
|
||||
class ConfigLoader:
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Literal
|
||||
import os
|
||||
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
|
||||
from ...core.constants import (
|
||||
FZF_DEFAULT_OPTS,
|
||||
ROFI_THEME_MAIN,
|
||||
ROFI_THEME_INPUT,
|
||||
ROFI_THEME_CONFIRM,
|
||||
ROFI_THEME_INPUT,
|
||||
ROFI_THEME_MAIN,
|
||||
ROFI_THEME_PREVIEW,
|
||||
)
|
||||
from ..constants import USER_VIDEOS_DIR, APP_ASCII_ART
|
||||
from ...libs.anime_provider import SERVERS_AVAILABLE, PROVIDERS_AVAILABLE
|
||||
from ...libs.anilist.constants import SORTS_AVAILABLE
|
||||
from ...libs.anime_provider import PROVIDERS_AVAILABLE, SERVERS_AVAILABLE
|
||||
from ..constants import APP_ASCII_ART, USER_VIDEOS_DIR
|
||||
|
||||
|
||||
class External(BaseModel):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
from typing import Any, Literal, get_origin, get_args
|
||||
from typing import Any, Literal, get_args, get_origin
|
||||
|
||||
import click
|
||||
from pydantic import BaseModel
|
||||
@@ -113,7 +113,7 @@ def options_from_model(model: type[BaseModel], parent_name: str = "") -> Callabl
|
||||
return f
|
||||
|
||||
# Store the list of decorators as an attribute for nested calls
|
||||
setattr(decorator, "decorators", decorators)
|
||||
decorator.decorators = decorators
|
||||
return decorator
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import click
|
||||
|
||||
|
||||
class LazyGroup(click.Group):
|
||||
def __init__(self, root:str, *args, lazy_subcommands=None, **kwargs):
|
||||
def __init__(self, root: str, *args, lazy_subcommands=None, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
# lazy_subcommands is a map of the form:
|
||||
#
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import logging
|
||||
|
||||
from rich.traceback import install as rich_install
|
||||
|
||||
from ..constants import LOG_FILE_PATH
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user