提交 1ce4c86c 编写于 作者: L Lucas Moauro

Refactored SpiderLoader class constructor for easier subclassing

上级 84dea194
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册