(self, crawler: Crawler)
| 48 | |
| 49 | class DownloadHandlers: |
| 50 | def __init__(self, crawler: Crawler): |
| 51 | self._crawler: Crawler = crawler |
| 52 | # stores acceptable schemes on instancing |
| 53 | self._schemes: dict[str, str | Callable[..., Any]] = {} |
| 54 | # stores instanced handlers for schemes |
| 55 | self._handlers: dict[str, DownloadHandlerProtocol] = {} |
| 56 | # remembers failed handlers |
| 57 | self._notconfigured: dict[str, str] = {} |
| 58 | # remembers handlers with Deferred-based download_request() |
| 59 | self._old_style_handlers: set[str] = set() |
| 60 | handlers: dict[str, str | Callable[..., Any]] = without_none_values( |
| 61 | cast( |
| 62 | "dict[str, str | Callable[..., Any]]", |
| 63 | crawler.settings.getwithbase("DOWNLOAD_HANDLERS"), |
| 64 | ) |
| 65 | ) |
| 66 | for scheme, clspath in handlers.items(): |
| 67 | self._schemes[scheme] = clspath |
| 68 | self._load_handler(scheme, skip_lazy=True) |
| 69 | |
| 70 | crawler.signals.connect(self._close, signals.engine_stopped) |
| 71 | |
| 72 | def _get_handler(self, scheme: str) -> DownloadHandlerProtocol | None: |
| 73 | """Lazy-load the downloadhandler for a scheme |
nothing calls this directly
no test coverage detected