mirror of https://github.com/scrapy/scrapy.git
backwards compatibility support for FeedExport's that don't receive a settings object in their constructor
This commit is contained in:
parent
caa64908d2
commit
251d9a9033
|
|
@ -18,6 +18,7 @@ from scrapy import log, signals
|
|||
from scrapy.utils.ftp import ftp_makedirs_cwd
|
||||
from scrapy.exceptions import NotConfigured
|
||||
from scrapy.utils.misc import load_object
|
||||
from scrapy.utils.python import get_func_args
|
||||
|
||||
|
||||
class IFeedStorage(Interface):
|
||||
|
|
@ -133,7 +134,6 @@ class SpiderSlot(object):
|
|||
class FeedExporter(object):
|
||||
|
||||
def __init__(self, settings):
|
||||
self.settings = settings
|
||||
self.urifmt = settings['FEED_URI']
|
||||
if not self.urifmt:
|
||||
raise NotConfigured
|
||||
|
|
@ -151,7 +151,15 @@ class FeedExporter(object):
|
|||
|
||||
@classmethod
|
||||
def from_crawler(cls, crawler):
|
||||
o = cls(crawler.settings)
|
||||
if len(get_func_args(cls)) < 1:
|
||||
# FIXME: remove for scrapy 0.17
|
||||
import warnings
|
||||
from scrapy.exceptions import ScrapyDeprecationWarning
|
||||
warnings.warn("%s must receive a settings object as first constructor argument." % cls.__name__,
|
||||
ScrapyDeprecationWarning, stacklevel=2)
|
||||
o = cls()
|
||||
else:
|
||||
o = cls(crawler.settings)
|
||||
crawler.signals.connect(o.open_spider, signals.spider_opened)
|
||||
crawler.signals.connect(o.close_spider, signals.spider_closed)
|
||||
crawler.signals.connect(o.item_scraped, signals.item_scraped)
|
||||
|
|
|
|||
Loading…
Reference in New Issue