Task 1.5: Update Provider Factory documentation for key usage
- Added comprehensive module-level docstring explaining provider vs series keys - Enhanced Loaders class docstring with purpose and attributes documentation - Added detailed docstring to GetLoader() method with Args/Returns/Raises sections - Added type hints: Dict[str, Loader] for self.dict and -> None for __init__ - Clarified distinction between provider keys (e.g., 'aniworld.to') and series keys - No functional changes - existing implementation already correct - All 34 provider tests pass - All 16 SeriesApp tests pass - Updated instructions.md to mark Task 1.5 as completed - Follows PEP 8 and PEP 257 standards
This commit is contained in:
@@ -1,10 +1,56 @@
|
||||
"""Provider factory for managing anime content providers.
|
||||
|
||||
This module provides a factory class for accessing different anime content
|
||||
providers (loaders). The factory uses provider identifiers (keys) to return
|
||||
the appropriate provider instance.
|
||||
|
||||
Note: The 'key' parameter in this factory refers to the provider identifier
|
||||
(e.g., 'aniworld.to'), not to be confused with series keys used within
|
||||
providers to identify specific anime series.
|
||||
"""
|
||||
|
||||
from typing import Dict
|
||||
|
||||
from .aniworld_provider import AniworldLoader
|
||||
from .base_provider import Loader
|
||||
|
||||
class Loaders:
|
||||
|
||||
def __init__(self):
|
||||
self.dict = {"aniworld.to": AniworldLoader()}
|
||||
class Loaders:
|
||||
"""Factory class for managing and retrieving anime content providers.
|
||||
|
||||
This factory maintains a registry of available providers and provides
|
||||
access to them via provider keys. Each provider implements the Loader
|
||||
interface for searching and downloading anime content.
|
||||
|
||||
Attributes:
|
||||
dict: Dictionary mapping provider keys to provider instances.
|
||||
Provider keys are site identifiers (e.g., 'aniworld.to').
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""Initialize the provider factory with available providers.
|
||||
|
||||
Currently supports:
|
||||
- 'aniworld.to': AniworldLoader for aniworld.to content
|
||||
"""
|
||||
self.dict: Dict[str, Loader] = {"aniworld.to": AniworldLoader()}
|
||||
|
||||
def GetLoader(self, key: str) -> Loader:
|
||||
"""Retrieve a provider instance by its provider key.
|
||||
|
||||
Args:
|
||||
key: Provider identifier (e.g., 'aniworld.to').
|
||||
This is the site/provider key, not a series key.
|
||||
|
||||
Returns:
|
||||
Loader instance for the specified provider.
|
||||
|
||||
Raises:
|
||||
KeyError: If the provider key is not found in the registry.
|
||||
|
||||
Note:
|
||||
The 'key' parameter here identifies the provider/site, while
|
||||
series-specific operations on the returned Loader use series
|
||||
keys to identify individual anime series.
|
||||
"""
|
||||
return self.dict[key]
|
||||
|
||||
Reference in New Issue
Block a user