本文整理匯總了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)