mirror of https://github.com/scrapy/scrapy.git
Added more verbose error message for unrecognized output format. PEP8.
This commit is contained in:
parent
aa79abc5bd
commit
7e353761a3
|
|
@ -38,7 +38,10 @@ class Command(ScrapyCommand):
|
|||
if not opts.output_format:
|
||||
opts.output_format = os.path.splitext(opts.output)[1].replace(".", "")
|
||||
if opts.output_format not in valid_output_formats:
|
||||
raise UsageError('Invalid/unrecognized output format: %s, Expected %s' % (opts.output_format, valid_output_formats))
|
||||
raise UsageError("Unrecognized output format '%s', set one"
|
||||
" using the '-t' switch or as a file extension"
|
||||
" from the supported list %s" % (opts.output_format,
|
||||
tuple(valid_output_formats)))
|
||||
self.settings.overrides['FEED_FORMAT'] = opts.output_format
|
||||
|
||||
def run(self, args, opts):
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ from scrapy.command import ScrapyCommand
|
|||
from scrapy.exceptions import UsageError
|
||||
from scrapy.utils.conf import arglist_to_dict
|
||||
|
||||
|
||||
def _import_file(filepath):
|
||||
abspath = os.path.abspath(filepath)
|
||||
dirname, file = os.path.split(abspath)
|
||||
|
|
@ -22,6 +23,7 @@ def _import_file(filepath):
|
|||
sys.path.pop(0)
|
||||
return module
|
||||
|
||||
|
||||
class Command(ScrapyCommand):
|
||||
|
||||
requires_project = False
|
||||
|
|
@ -59,7 +61,10 @@ class Command(ScrapyCommand):
|
|||
if not opts.output_format:
|
||||
opts.output_format = os.path.splitext(opts.output)[1].replace(".", "")
|
||||
if opts.output_format not in valid_output_formats:
|
||||
raise UsageError('Invalid/unrecognized output format: %s, Expected %s' % (opts.output_format, valid_output_formats))
|
||||
raise UsageError("Unrecognized output format '%s', set one"
|
||||
" using the '-t' switch or as a file extension"
|
||||
" from the supported list %s" % (opts.output_format,
|
||||
tuple(valid_output_formats)))
|
||||
self.settings.overrides['FEED_FORMAT'] = opts.output_format
|
||||
|
||||
def run(self, args, opts):
|
||||
|
|
|
|||
Loading…
Reference in New Issue