Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Drop support for add-on configuration in scrapy.cfg

Jakob de Maeyerb10caf91a14d
diff --git a/scrapy/addons/__init__.py b/scrapy/addons/__init__.py
index a1a9a388a..40a98676d 100644
--- a/scrapy/addons/__init__.py
+++ b/scrapy/addons/__init__.py
@@ -9,8 +9,7 @@ from zope.interface.verify import verifyObject
from scrapy.exceptions import NotConfigured
from scrapy.interfaces import IAddon
-from scrapy.utils.conf import (build_component_list, config_from_filepath,
- get_config)
+from scrapy.utils.conf import build_component_list
from scrapy.utils.misc import load_module_or_object
from scrapy.utils.project import get_project_path
@@ -325,31 +324,6 @@ class AddonManager(Mapping):
for a, c in zip(addons, configs):
self.add(a, c)
- def load_cfg(self, cfg=None):
- """Load add-ons and configurations from given ``ConfigParser`` object or
- config file path.
-
- Each add-on should have its own section, where the section has a name in
- the form ``addon:my_addon_path``. The add-on object is searched for via
- the :meth:`get_addon` method, ``my_addon_path`` can be either a Python
- or a file path.
-
- If ``cfg`` is ``None``, ``scrapy.cfg`` will be used.
-
- :param cfg: ``ConfigParser`` object or config file path from which to \
- read add-on configuration
- :type cfg: ``ConfigParser`` or ``str``
- """
- if cfg is None:
- cfg = get_config()
- elif isinstance(cfg, six.string_types):
- cfg = config_from_filepath(cfg)
- for secname in cfg.sections():
- if secname.startswith("addon:"):
- addonkey = secname.split("addon:", 1)[1]
- addoncfg = dict(cfg.items(secname))
- self.add(addonkey, addoncfg)
-
def check_dependency_clashes(self):
"""Check for incompatibilities in add-on dependencies.
diff --git a/scrapy/cmdline.py b/scrapy/cmdline.py
index b403df570..b7c349793 100644
--- a/scrapy/cmdline.py
+++ b/scrapy/cmdline.py
@@ -120,7 +120,6 @@ def execute(argv=None, settings=None):
# ------------------------------------------------------------------
addons = AddonManager()
- addons.load_cfg()
inproject = inside_project()
cmds = _get_commands_dict(settings, inproject)
diff --git a/tests/test_addons/__init__.py b/tests/test_addons/__init__.py
index aa8dfbb63..f10819685 100644
--- a/tests/test_addons/__init__.py
+++ b/tests/test_addons/__init__.py
@@ -16,7 +16,6 @@ from scrapy.addons import Addon, AddonManager
from scrapy.crawler import Crawler
from scrapy.interfaces import IAddon
from scrapy.settings import BaseSettings
-from scrapy.utils.conf import config_from_filepath
from . import addons
from . import addonmod
@@ -107,7 +106,6 @@ class AddonTest(unittest.TestCase):
class AddonManagerTest(unittest.TestCase):
- TESTCFGPATH = os.path.join(os.path.dirname(__file__), 'cfg.cfg')
ADDONMODPATH = os.path.join(os.path.dirname(__file__), 'addonmod.py')
def setUp(self):
@@ -262,24 +260,6 @@ class AddonManagerTest(unittest.TestCase):
})
_test_load_method(expected_order, 'load_settings', settings)
- def test_load_cfg(self):
- def _check_loaded_addons(manager):
- six.assertCountEqual(self, manager, ['GoodAddon', 'AddonModule'])
- self.assertIsInstance(manager['GoodAddon'], addons.GoodAddon)
- six.assertCountEqual(self, manager.configs['GoodAddon'], ['key'])
- self.assertEqual(manager.configs['GoodAddon']['key'], 'val1')
- # XXX: Check module equality, see above
- self.assertEqual(manager['AddonModule'].name, addonmod.name)
- six.assertCountEqual(self, manager.configs['AddonModule'], ['key'])
- self.assertEqual(manager.configs['AddonModule']['key'], 'val2')
- manager = AddonManager()
- manager.load_cfg(self.TESTCFGPATH)
- _check_loaded_addons(manager)
- manager = AddonManager()
- preloaded_cfg = config_from_filepath(self.TESTCFGPATH)
- manager.load_cfg(preloaded_cfg)
- _check_loaded_addons(manager)
-
def test_enabled_disabled(self):
manager = AddonManager()
manager.add(addons.GoodAddon('FirstAddon'))
diff --git a/tests/test_addons/cfg.cfg b/tests/test_addons/cfg.cfg
deleted file mode 100644
index 98c4f0f25..000000000
--- a/tests/test_addons/cfg.cfg
+++ /dev/null
@@ -1,5 +0,0 @@
-[addon:tests.test_addons.addons.GoodAddon]
-key = val1
-
-[addon:tests/test_addons/addonmod.py]
-key = val2