mirror of https://github.com/scrapy/scrapy.git
Drop support for ScrapyCommand.crawler property
This commit is contained in:
parent
870438e5f4
commit
d0edad4b0b
|
|
@ -2,12 +2,11 @@
|
|||
Base class for Scrapy commands
|
||||
"""
|
||||
import os
|
||||
import warnings
|
||||
from optparse import OptionGroup
|
||||
from twisted.python import failure
|
||||
|
||||
from scrapy.utils.conf import arglist_to_dict
|
||||
from scrapy.exceptions import UsageError, ScrapyDeprecationWarning
|
||||
from scrapy.exceptions import UsageError
|
||||
|
||||
|
||||
class ScrapyCommand(object):
|
||||
|
|
@ -27,31 +26,6 @@ class ScrapyCommand(object):
|
|||
assert not hasattr(self, '_crawler'), "crawler already set"
|
||||
self._crawler = crawler
|
||||
|
||||
@property
|
||||
def crawler(self):
|
||||
warnings.warn("Command's default `crawler` is deprecated and will be removed. "
|
||||
"Use `create_crawler` method to instatiate crawlers.",
|
||||
ScrapyDeprecationWarning)
|
||||
|
||||
if not hasattr(self, '_crawler'):
|
||||
crawler = self.crawler_process.create_crawler()
|
||||
|
||||
old_start = crawler.start
|
||||
self.crawler_process.started = False
|
||||
|
||||
def wrapped_start():
|
||||
if self.crawler_process.started:
|
||||
old_start()
|
||||
else:
|
||||
self.crawler_process.started = True
|
||||
self.crawler_process.start()
|
||||
|
||||
crawler.start = wrapped_start
|
||||
|
||||
self.set_crawler(crawler)
|
||||
|
||||
return self._crawler
|
||||
|
||||
def syntax(self):
|
||||
"""
|
||||
Command syntax (preferably one-line). Do not include command name.
|
||||
|
|
|
|||
Loading…
Reference in New Issue