Refactor utils module structure and update imports
Moved utility modules from src/utils/ to ytsage/utils/ and updated all relative imports accordingly. Adjusted docstring usage examples and fixed a path reference in LocalizationManager to reflect the new directory structure.
This commit is contained in:
@@ -20,7 +20,7 @@ Features
|
|||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
from src.utils.ytsage_config_manager import ConfigManager
|
from .ytsage_config_manager import ConfigManager
|
||||||
|
|
||||||
# Load settings (auto-loads if not already loaded)
|
# Load settings (auto-loads if not already loaded)
|
||||||
download_path = ConfigManager.get("download_path")
|
download_path = ConfigManager.get("download_path")
|
||||||
@@ -54,8 +54,8 @@ import threading
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, Optional
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
from src.utils.ytsage_constants import APP_CONFIG_FILE, USER_HOME_DIR
|
from .ytsage_constants import APP_CONFIG_FILE, USER_HOME_DIR
|
||||||
from src.utils.ytsage_logger import logger
|
from .ytsage_logger import logger
|
||||||
|
|
||||||
|
|
||||||
class ConfigManager:
|
class ConfigManager:
|
||||||
@@ -70,7 +70,7 @@ def get_asset_path(asset_relative_path: str) -> Path:
|
|||||||
|
|
||||||
# Fallback to relative path (for development environment)
|
# Fallback to relative path (for development environment)
|
||||||
current_file = Path(__file__)
|
current_file = Path(__file__)
|
||||||
# Go up from src/utils to ytsage root, then to asset
|
# Go up from utils to ytsage root, then to asset
|
||||||
ytsage_root = current_file.parent.parent.parent
|
ytsage_root = current_file.parent.parent.parent
|
||||||
asset_path = ytsage_root / asset_relative_path
|
asset_path = ytsage_root / asset_relative_path
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ Features
|
|||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
from src.utils.ytsage_history_manager import HistoryManager
|
from .ytsage_history_manager import HistoryManager
|
||||||
|
|
||||||
# Add a download to history
|
# Add a download to history
|
||||||
HistoryManager.add_entry(...)
|
HistoryManager.add_entry(...)
|
||||||
@@ -38,8 +38,8 @@ from datetime import datetime
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
from src.utils.ytsage_constants import APP_HISTORY_FILE, APP_DATA_DIR
|
from .ytsage_constants import APP_HISTORY_FILE, APP_DATA_DIR
|
||||||
from src.utils.ytsage_logger import logger
|
from .ytsage_logger import logger
|
||||||
|
|
||||||
|
|
||||||
class HistoryManager:
|
class HistoryManager:
|
||||||
@@ -15,7 +15,7 @@ Features
|
|||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
from src.utils.ytsage_localization import LocalizationManager
|
from .ytsage_localization import LocalizationManager
|
||||||
|
|
||||||
# Get localized text
|
# Get localized text
|
||||||
text = LocalizationManager.get_text("download.ready")
|
text = LocalizationManager.get_text("download.ready")
|
||||||
@@ -33,7 +33,7 @@ import threading
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
|
|
||||||
from src.utils.ytsage_logger import logger
|
from .ytsage_logger import logger
|
||||||
|
|
||||||
|
|
||||||
class LocalizationManager:
|
class LocalizationManager:
|
||||||
@@ -46,7 +46,7 @@ class LocalizationManager:
|
|||||||
_lock = threading.RLock()
|
_lock = threading.RLock()
|
||||||
_current_language = "en"
|
_current_language = "en"
|
||||||
_languages: Dict[str, Dict[str, Any]] = {}
|
_languages: Dict[str, Dict[str, Any]] = {}
|
||||||
_languages_dir = Path(__file__).parent.parent.parent / "languages"
|
_languages_dir = Path(__file__).parent.parent / "languages"
|
||||||
|
|
||||||
# Fallback English strings embedded in code
|
# Fallback English strings embedded in code
|
||||||
_fallback_strings = {
|
_fallback_strings = {
|
||||||
@@ -9,7 +9,7 @@ import sys
|
|||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
from src.utils.ytsage_constants import APP_LOG_DIR, IS_FROZEN
|
from .ytsage_constants import APP_LOG_DIR, IS_FROZEN
|
||||||
|
|
||||||
# Separate configs for each handler
|
# Separate configs for each handler
|
||||||
CONSOLE_CONFIG = {
|
CONSOLE_CONFIG = {
|
||||||
Reference in New Issue
Block a user