MCPcopy
hub / github.com/scrapy/scrapy / __init__

Method __init__

scrapy/core/downloader/handlers/__init__.py:50–70  ·  view source on GitHub ↗
(self, crawler: Crawler)

Source from the content-addressed store, hash-verified

48
49class 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

Callers

nothing calls this directly

Calls 5

_load_handlerMethod · 0.95
without_none_valuesFunction · 0.90
getwithbaseMethod · 0.80
itemsMethod · 0.80
connectMethod · 0.45

Tested by

no test coverage detected