refactor: Apply PEP8 naming conventions - convert PascalCase methods to snake_case
This comprehensive refactoring applies PEP8 naming conventions across the codebase: ## Core Changes: ### src/cli/Main.py - Renamed __InitList__() to __init_list__() - Renamed print_Download_Progress() to print_download_progress() - Fixed variable naming: task3 -> download_progress_task - Fixed parameter spacing: words :str -> words: str - Updated all method calls to use snake_case - Added comprehensive docstrings ### src/core/SerieScanner.py - Renamed Scan() to scan() - Renamed GetTotalToScan() to get_total_to_scan() - Renamed Reinit() to reinit() - Renamed private methods to snake_case: - __ReadDataFromFile() -> __read_data_from_file() - __GetMissingEpisodesAndSeason() -> __get_missing_episodes_and_season() - __GetEpisodeAndSeason() -> __get_episode_and_season() - __GetEpisodesAndSeasons() -> __get_episodes_and_seasons() - Added comprehensive docstrings to all methods - Fixed long line issues ### src/core/providers/base_provider.py - Refactored abstract base class with proper naming: - Search() -> search() - IsLanguage() -> is_language() - Download() -> download() - GetSiteKey() -> get_site_key() - GetTitle() -> get_title() - Added proper type hints (Dict, List, etc.) - Added comprehensive docstrings explaining contracts - Fixed newline at end of file ### src/core/providers/aniworld_provider.py - Renamed public methods to snake_case: - Search() -> search() - IsLanguage() -> is_language() - Download() -> download() - GetSiteKey() -> get_site_key() - GetTitle() -> get_title() - ClearCache() -> clear_cache() - RemoveFromCache() -> remove_from_cache() - Renamed private methods to snake_case: - _GetLanguageKey() -> _get_language_key() - _GetKeyHTML() -> _get_key_html() - _GetEpisodeHTML() -> _get_episode_html() - Fixed import organization - Improved code formatting and line lengths - Added docstrings to all methods ### src/core/SeriesApp.py - Updated all calls to use new snake_case method names - Updated loader calls: loader.Search() -> loader.search() - Updated loader calls: loader.Download() -> loader.download() - Updated scanner calls: SerieScanner.GetTotalToScan() -> SerieScanner.get_total_to_scan() - Updated scanner calls: SerieScanner.Reinit() -> SerieScanner.reinit() - Updated scanner calls: SerieScanner.Scan() -> SerieScanner.scan() ### tests/unit/test_series_app.py - Updated mock calls to use new snake_case method names: - get_total_to_scan() instead of GetTotalToScan() - reinit() instead of Reinit() - scan() instead of Scan() ## Verification: - All unit tests pass ✅ - All integration tests pass ✅ - All tests pass ✅ - No breaking changes to functionality ## Standards Applied: - PEP 8: Function/method names use lowercase with underscores (snake_case) - PEP 257: Added comprehensive docstrings - Type hints: Proper type annotations where applicable - Code formatting: Fixed line lengths and spacing
This commit is contained in:
@@ -1,27 +1,94 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Dict, List
|
||||
|
||||
|
||||
class Loader(ABC):
|
||||
"""Abstract base class for anime data loaders/providers."""
|
||||
|
||||
@abstractmethod
|
||||
def Search(self, word: str) -> list:
|
||||
def search(self, word: str) -> List[Dict]:
|
||||
"""Search for anime series by name.
|
||||
|
||||
Args:
|
||||
word: Search term
|
||||
|
||||
Returns:
|
||||
List of found series as dictionaries
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def IsLanguage(self, season: int, episode: int, key: str, language: str = "German Dub") -> bool:
|
||||
def is_language(
|
||||
self,
|
||||
season: int,
|
||||
episode: int,
|
||||
key: str,
|
||||
language: str = "German Dub"
|
||||
) -> bool:
|
||||
"""Check if episode exists in specified language.
|
||||
|
||||
Args:
|
||||
season: Season number
|
||||
episode: Episode number
|
||||
key: Series key
|
||||
language: Language to check (default: German Dub)
|
||||
|
||||
Returns:
|
||||
True if episode exists in specified language
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def Download(self, baseDirectory: str, serieFolder: str, season: int, episode: int, key: str, progress_callback: callable = None) -> bool:
|
||||
def download(
|
||||
self,
|
||||
base_directory: str,
|
||||
serie_folder: str,
|
||||
season: int,
|
||||
episode: int,
|
||||
key: str,
|
||||
progress_callback=None
|
||||
) -> bool:
|
||||
"""Download episode to specified directory.
|
||||
|
||||
Args:
|
||||
base_directory: Base directory for downloads
|
||||
serie_folder: Series folder name
|
||||
season: Season number
|
||||
episode: Episode number
|
||||
key: Series key
|
||||
progress_callback: Optional callback for progress updates
|
||||
|
||||
Returns:
|
||||
True if download successful
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def GetSiteKey(self) -> str:
|
||||
def get_site_key(self) -> str:
|
||||
"""Get the site key/identifier for this provider.
|
||||
|
||||
Returns:
|
||||
Site key string (e.g., 'aniworld.to')
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def GetTitle(self) -> str:
|
||||
def get_title(self) -> str:
|
||||
"""Get the human-readable title of this provider.
|
||||
|
||||
Returns:
|
||||
Provider title string
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_season_episode_count(self, slug: str) -> dict:
|
||||
pass
|
||||
def get_season_episode_count(self, slug: str) -> Dict[int, int]:
|
||||
"""Get season and episode counts for a series.
|
||||
|
||||
Args:
|
||||
slug: Series slug/key
|
||||
|
||||
Returns:
|
||||
Dictionary mapping season number to episode count
|
||||
"""
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user