Applied suggested format changes

This commit is contained in:
Jay Rajput 2020-05-10 00:08:34 +05:30
parent 92792cc3f7
commit ed4f4f8408
2 changed files with 10 additions and 17 deletions

View File

@ -80,8 +80,7 @@ class ScrapyCommand:
self.settings.setdict(arglist_to_dict(opts.set),
priority='cmdline')
except ValueError:
raise UsageError(
"Invalid -s value, use -s NAME=VALUE", print_help=False)
raise UsageError("Invalid -s value, use -s NAME=VALUE", print_help=False)
if opts.logfile:
self.settings.set('LOG_ENABLED', True, priority='cmdline')
@ -108,18 +107,15 @@ class ScrapyCommand:
raise NotImplementedError
''''
The BaseRunSpiderCommands class inherits the ScrapyCommand class and it Used for
performing common functionality between crawl.py and runspider.py
'''
class BaseRunSpiderCommands(ScrapyCommand):
''''
The BaseRunSpiderCommands class inherits the ScrapyCommand class and it Used for
performing common functionality between crawl.py and runspider.py
'''
def add_options(self, parser):
ScrapyCommand.add_options(self, parser)
parser.add_option("-a", dest="spargs", action="append", default=[],
metavar="NAME=VALUE",
parser.add_option("-a", dest="spargs", action="append", default=[],metavar="NAME=VALUE",
help="set spider argument (may be repeated)")
parser.add_option("-o", "--output", metavar="FILE", action="append",
help="dump scraped items into FILE"
@ -132,9 +128,7 @@ class BaseRunSpiderCommands(ScrapyCommand):
try:
opts.spargs = arglist_to_dict(opts.spargs)
except ValueError:
raise UsageError(
"Invalid -a value, use -a NAME=VALUE", print_help=False)
raise UsageError("Invalid -a value, use -a NAME=VALUE", print_help=False)
if opts.output:
feeds = feed_process_params_from_cli(
self.settings, opts.output, opts.output_format)
feeds = feed_process_params_from_cli(self.settings, opts.output, opts.output_format)
self.settings.set('FEEDS', feeds, priority='cmdline')

View File

@ -1,5 +1,5 @@
from scrapy.exceptions import UsageError
from scrapy.commands import BaseRunSpiderCommands
from scrapy.exceptions import UsageError
class Command(BaseRunSpiderCommands):
@ -16,8 +16,7 @@ class Command(BaseRunSpiderCommands):
if len(args) < 1:
raise UsageError()
elif len(args) > 1:
raise UsageError(
"running 'scrapy crawl' with more than one spider is no longer supported")
raise UsageError("running 'scrapy crawl' with more than one spider is no longer supported")
spname = args[0]
crawl_defer = self.crawler_process.crawl(spname, **opts.spargs)