From a20de4f0ad0ca2c3e7c53d9cc442cd0fa16762f4 Mon Sep 17 00:00:00 2001 From: 100gle Date: Mon, 3 Jul 2023 20:43:52 +0800 Subject: [PATCH] refactor: shorten import content --- backend/src/module/conf/__init__.py | 6 +++--- backend/src/module/conf/config.py | 4 ++-- backend/src/module/conf/log.py | 4 ++-- backend/src/module/parser/analyser/torrent_parser.py | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/backend/src/module/conf/__init__.py b/backend/src/module/conf/__init__.py index 8af4f5ea..cc64c8a3 100644 --- a/backend/src/module/conf/__init__.py +++ b/backend/src/module/conf/__init__.py @@ -1,10 +1,10 @@ -import pathlib +from pathlib import Path from .config import VERSION, settings from .log import LOG_PATH, setup_logger TMDB_API = "32b19d6a05b512190a056fa4e747cbbc" -DATA_PATH = pathlib.Path("data/data.db") -LEGACY_DATA_PATH = pathlib.Path("data/data.json") +DATA_PATH = Path("data/data.db") +LEGACY_DATA_PATH = Path("data/data.json") PLATFORM = "Windows" if "\\" in settings.downloader.path else "Unix" diff --git a/backend/src/module/conf/config.py b/backend/src/module/conf/config.py index 402d9f9f..6e466dbc 100644 --- a/backend/src/module/conf/config.py +++ b/backend/src/module/conf/config.py @@ -1,7 +1,7 @@ import json import logging import os -import pathlib +from pathlib import Path from dotenv import load_dotenv @@ -10,7 +10,7 @@ from module.models.config import Config from .const import ENV_TO_ATTR logger = logging.getLogger(__name__) -CONFIG_ROOT = pathlib.Path("config") +CONFIG_ROOT = Path("config") try: diff --git a/backend/src/module/conf/log.py b/backend/src/module/conf/log.py index 76ce5383..37a0b905 100644 --- a/backend/src/module/conf/log.py +++ b/backend/src/module/conf/log.py @@ -1,9 +1,9 @@ import logging -import pathlib +from pathlib import Path from .config import settings -LOG_ROOT = pathlib.Path("data") +LOG_ROOT = Path("data") LOG_PATH = LOG_ROOT / "log.txt" diff --git a/backend/src/module/parser/analyser/torrent_parser.py b/backend/src/module/parser/analyser/torrent_parser.py index 366d91ff..d4063526 100644 --- a/backend/src/module/parser/analyser/torrent_parser.py +++ b/backend/src/module/parser/analyser/torrent_parser.py @@ -1,5 +1,5 @@ import logging -import pathlib +from pathlib import Path import re from module.models import EpisodeFile, SubtitleFile @@ -31,7 +31,7 @@ def get_path_basename(torrent_path: str) -> str: :return: A string representing the basename of the given path. :rtype: str """ - return pathlib.Path(torrent_path).name + return Path(torrent_path).name def get_group(group_and_title) -> tuple[str | None, str]: @@ -81,7 +81,7 @@ def torrent_parser( else: title, _ = get_season_and_title(title) episode = int(match_obj.group(2)) - suffix = pathlib.Path(torrent_path).suffix + suffix = Path(torrent_path).suffix if file_type == "media": return EpisodeFile( media_path=torrent_path,