本文整理汇总了Python中smart.option.OptionParser.defaults["target"]方法的典型用法代码示例。如果您正苦于以下问题:Python OptionParser.defaults["target"]方法的具体用法?Python OptionParser.defaults["target"]怎么用?Python OptionParser.defaults["target"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类smart.option.OptionParser
的用法示例。
在下文中一共展示了OptionParser.defaults["target"]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_options
# 需要导入模块: from smart.option import OptionParser [as 别名]
# 或者: from smart.option.OptionParser import defaults["target"] [as 别名]
def parse_options(argv):
parser = OptionParser(usage=USAGE,
description=DESCRIPTION,
examples=EXAMPLES)
parser.defaults["from_urls"] = []
parser.defaults["target"] = os.getcwd()
parser.add_option("--target", action="store", metavar="DIR",
help=_("packages will be saved in given directory"))
parser.add_option("--urls", action="store_true",
help=_("dump needed urls and don't download packages"))
parser.add_option("--from-urls", action="callback", callback=append_all,
help=_("download files from the given urls and/or from "
"the given files with lists of urls"))
opts, args = parser.parse_args(argv)
opts.args = args
if not os.path.isdir(opts.target):
raise Error, _("Directory not found:"), opts.target
return opts
示例2: option_parser
# 需要导入模块: from smart.option import OptionParser [as 别名]
# 或者: from smart.option.OptionParser import defaults["target"] [as 别名]
def option_parser():
parser = OptionParser(usage=USAGE,
description=DESCRIPTION,
examples=EXAMPLES)
parser.defaults["from_urls"] = []
parser.defaults["from_metalink"] = []
parser.defaults["target"] = os.getcwd()
parser.add_option("--target", action="store", metavar="DIR",
help=_("packages will be saved in given directory"))
parser.add_option("--pack", action="store_true",
help=_("pack all downloaded packages in a tarball"))
parser.add_option("--output", action="store", metavar="FILE",
help=_("redirect tarball output to given filename"))
parser.add_option("--urls", action="store_true",
help=_("dump needed urls and don't download packages"))
parser.add_option("--metalink", action="store_true",
help=_("dump metalink xml and don't download packages"))
parser.add_option("--from-urls", action="callback", callback=append_all,
help=_("download files from the given urls and/or from "
"the given files with lists of urls"))
parser.add_option("--from-metalink", action="callback", callback=append_all,
help=_("download files from the given metalink file"))
return parser