mirror of https://github.com/scrapy/scrapy.git
Make AddonManager.add() private.
This commit is contained in:
parent
cdda8ad46d
commit
5c34f34ecb
|
|
@ -17,15 +17,8 @@ class AddonManager:
|
|||
self.crawler: "Crawler" = crawler
|
||||
self.addons: List[Any] = []
|
||||
|
||||
def add(self, addon: Any) -> None:
|
||||
"""Store an add-on.
|
||||
|
||||
:param addon: The add-on object (or path) to be stored
|
||||
:type addon: Python object, class or ``str``
|
||||
|
||||
:param config: The add-on configuration dictionary
|
||||
:type config: ``dict``
|
||||
"""
|
||||
def _add(self, addon: Any) -> None:
|
||||
"""Store an add-on."""
|
||||
if isinstance(addon, (type, str)):
|
||||
addon = load_object(addon)
|
||||
if isinstance(addon, type):
|
||||
|
|
@ -33,7 +26,7 @@ class AddonManager:
|
|||
self.addons.append(addon)
|
||||
|
||||
def load_settings(self, settings) -> None:
|
||||
"""Load add-ons and configurations from settings object.
|
||||
"""Load add-ons and configurations from a settings object.
|
||||
|
||||
This will load the addon for every add-on path in the
|
||||
``ADDONS`` setting.
|
||||
|
|
@ -42,10 +35,9 @@ class AddonManager:
|
|||
which to read the add-on configuration
|
||||
:type settings: :class:`~scrapy.settings.Settings`
|
||||
"""
|
||||
paths = build_component_list(settings["ADDONS"])
|
||||
addons = [load_object(path) for path in paths]
|
||||
for a in addons:
|
||||
self.add(a)
|
||||
addons = build_component_list(settings["ADDONS"])
|
||||
for addon in build_component_list(settings["ADDONS"]):
|
||||
self._add(addon)
|
||||
logger.info(
|
||||
"Enabled addons:\n%(addons)s",
|
||||
{
|
||||
|
|
|
|||
|
|
@ -43,12 +43,6 @@ class AddonTest(unittest.TestCase):
|
|||
|
||||
|
||||
class AddonManagerTest(unittest.TestCase):
|
||||
def test_add(self):
|
||||
crawler = get_crawler()
|
||||
manager = crawler.addons
|
||||
manager.add("tests.test_addons.GoodAddon")
|
||||
self.assertIsInstance(manager.addons[0], GoodAddon)
|
||||
|
||||
def test_load_settings(self):
|
||||
settings_dict = {
|
||||
"ADDONS": {"tests.test_addons.GoodAddon": 0},
|
||||
|
|
|
|||
Loading…
Reference in New Issue