Refactor: Replace CallbackManager with Events pattern
- Replace callback system with events library in SerieScanner - Update SeriesApp to subscribe to loader and scanner events - Refactor ScanService to use Events instead of CallbackManager - Remove CallbackManager imports and callback classes - Add safe event calling with error handling in SerieScanner - Update AniworldLoader to use Events for download progress - Remove progress_callback parameter from download methods - Update all affected tests for Events pattern - Fix test_series_app.py for new event subscription model - Comment out obsolete callback tests in test_scan_service.py All core tests passing. Events provide cleaner event-driven architecture.
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Any, Callable, Dict, List, Optional
|
||||
from typing import Any, Dict, List
|
||||
|
||||
|
||||
class Loader(ABC):
|
||||
"""Abstract base class for anime data loaders/providers."""
|
||||
@abstractmethod
|
||||
def subscribe_download_progress(self, handler):
|
||||
"""Subscribe a handler to the download_progress event.
|
||||
Args:
|
||||
handler: Callable to be called with progress dict.
|
||||
def subscribe_download_progress(self, handler):
|
||||
"""Subscribe a handler to the download_progress event.
|
||||
Args:
|
||||
handler: Callable to be called with progress dict.
|
||||
"""
|
||||
@abstractmethod
|
||||
def unsubscribe_download_progress(self, handler):
|
||||
"""Unsubscribe a handler from the download_progress event.
|
||||
Args:
|
||||
handler: Callable previously subscribed.
|
||||
def unsubscribe_download_progress(self, handler):
|
||||
"""Unsubscribe a handler from the download_progress event.
|
||||
Args:
|
||||
handler: Callable previously subscribed.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
@@ -56,8 +56,7 @@ class Loader(ABC):
|
||||
season: int,
|
||||
episode: int,
|
||||
key: str,
|
||||
language: str = "German Dub",
|
||||
progress_callback: Optional[Callable[[str, Dict], None]] = None,
|
||||
language: str = "German Dub"
|
||||
) -> bool:
|
||||
"""Download episode to specified directory.
|
||||
|
||||
@@ -68,8 +67,6 @@ class Loader(ABC):
|
||||
episode: Episode number within season
|
||||
key: Unique series identifier/key
|
||||
language: Language version to download (default: German Dub)
|
||||
progress_callback: Optional callback for progress updates
|
||||
called with (event_type: str, data: Dict)
|
||||
|
||||
Returns:
|
||||
True if download successful, False otherwise
|
||||
|
||||
Reference in New Issue
Block a user