mirror of https://github.com/scrapy/scrapy.git
Drop support for add-on configuration in scrapy.cfg
This commit is contained in:
parent
f7ed239fcb
commit
b10caf91a1
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -120,7 +120,6 @@ def execute(argv=None, settings=None):
|
|||
# ------------------------------------------------------------------
|
||||
|
||||
addons = AddonManager()
|
||||
addons.load_cfg()
|
||||
|
||||
inproject = inside_project()
|
||||
cmds = _get_commands_dict(settings, inproject)
|
||||
|
|
|
|||
|
|
@ -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'))
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
[addon:tests.test_addons.addons.GoodAddon]
|
||||
key = val1
|
||||
|
||||
[addon:tests/test_addons/addonmod.py]
|
||||
key = val2
|
||||
Loading…
Reference in New Issue