本文整理汇总了Python中scrapy.utils.conf.arglist_to_dict方法的典型用法代码示例。如果您正苦于以下问题:Python conf.arglist_to_dict方法的具体用法?Python conf.arglist_to_dict怎么用?Python conf.arglist_to_dict使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scrapy.utils.conf
的用法示例。
在下文中一共展示了conf.arglist_to_dict方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_options
# 需要导入模块: from scrapy.utils import conf [as 别名]
# 或者: from scrapy.utils.conf import arglist_to_dict [as 别名]
def process_options(self, args, opts):
try:
self.settings.setdict(arglist_to_dict(opts.set),
priority='cmdline')
except ValueError:
raise UsageError("Invalid -s value, use -s NAME=VALUE", print_help=False)
if opts.logfile:
self.settings.set('LOG_ENABLED', True, priority='cmdline')
self.settings.set('LOG_FILE', opts.logfile, priority='cmdline')
if opts.loglevel:
self.settings.set('LOG_ENABLED', True, priority='cmdline')
self.settings.set('LOG_LEVEL', opts.loglevel, priority='cmdline')
if opts.nolog:
self.settings.set('LOG_ENABLED', False, priority='cmdline')
if opts.pidfile:
with open(opts.pidfile, "w") as f:
f.write(str(os.getpid()) + os.linesep)
if opts.pdb:
failure.startDebugMode()
示例2: process_options
# 需要导入模块: from scrapy.utils import conf [as 别名]
# 或者: from scrapy.utils.conf import arglist_to_dict [as 别名]
def process_options(self, args, opts):
ScrapyCommand.process_options(self, args, opts)
try:
opts.spargs = arglist_to_dict(opts.spargs)
except ValueError:
raise UsageError("Invalid -a value, use -a NAME=VALUE", print_help=False)
if opts.output:
if opts.output == '-':
self.settings.set('FEED_URI', 'stdout:', priority='cmdline')
else:
self.settings.set('FEED_URI', opts.output, priority='cmdline')
feed_exporters = without_none_values(
self.settings.getwithbase('FEED_EXPORTERS'))
valid_output_formats = feed_exporters.keys()
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("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.set('FEED_FORMAT', opts.output_format, priority='cmdline')
#??
示例3: process_options
# 需要导入模块: from scrapy.utils import conf [as 别名]
# 或者: from scrapy.utils.conf import arglist_to_dict [as 别名]
def process_options(self, args, opts):
ScrapyCommand.process_options(self, args, opts)
try:
opts.spargs = arglist_to_dict(opts.spargs)
except ValueError:
raise UsageError("Invalid -a value, use -a NAME=VALUE", print_help=False)
示例4: process_options
# 需要导入模块: from scrapy.utils import conf [as 别名]
# 或者: from scrapy.utils.conf import arglist_to_dict [as 别名]
def process_options(self, args, opts):
ScrapyCommand.process_options(self, args, opts)
try:
opts.spargs = arglist_to_dict(opts.spargs)
except ValueError:
raise UsageError("Invalid -a value, use -a NAME=VALUE", print_help=False)
示例5: process_options
# 需要导入模块: from scrapy.utils import conf [as 别名]
# 或者: from scrapy.utils.conf import arglist_to_dict [as 别名]
def process_options(self,args,opts):
ScrapyCommand.process_options(self,args,opts)
try:
opts.spargs = arglist_to_dict(opts.spargs)
except ValueError:
raise UsageError("Invalid -a value,use -a NAME=VALUE",print_help=False)