mirror of https://github.com/scrapy/scrapy.git
Refactored SpiderLoader class constructor for easier subclassing
This commit is contained in:
parent
84dea19455
commit
1ce4c86c2b
|
|
@ -17,14 +17,17 @@ class SpiderLoader(object):
|
|||
def __init__(self, settings):
|
||||
self.spider_modules = settings.getlist('SPIDER_MODULES')
|
||||
self._spiders = {}
|
||||
for name in self.spider_modules:
|
||||
for module in walk_modules(name):
|
||||
self._load_spiders(module)
|
||||
|
||||
self._load_all_spiders()
|
||||
|
||||
def _load_spiders(self, module):
|
||||
for spcls in iter_spider_classes(module):
|
||||
self._spiders[spcls.name] = spcls
|
||||
|
||||
def _load_all_spiders(self):
|
||||
for name in self.spider_modules:
|
||||
for module in walk_modules(name):
|
||||
self._load_spiders(module)
|
||||
|
||||
@classmethod
|
||||
def from_settings(cls, settings):
|
||||
return cls(settings)
|
||||
|
|
|
|||
Loading…
Reference in New Issue