• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python option.OptionParser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中smart.option.OptionParser的典型用法代码示例。如果您正苦于以下问题:Python OptionParser类的具体用法?Python OptionParser怎么用?Python OptionParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了OptionParser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: parse_options

def parse_options(argv):
    parser = OptionParser(usage=USAGE,
                          description=DESCRIPTION,
                          examples=EXAMPLES)
    opts, args = parser.parse_args(argv)
    opts.args = args
    return opts
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:7,代码来源:stats.py


示例2: do_remove

 def do_remove(self, line):
     args = shlex.split(line)
     parser = OptionParser(add_help_option=False)
     parser.add_option("--explain", action="store_true")
     opts, args = parser.parse_args(args)
     cache = self._ctrl.getCache()
     transaction = Transaction(cache, policy=PolicyRemove)
     transaction.setState(self._changeset)
     changeset = transaction.getChangeSet()
     policy = transaction.getPolicy()
     expected = 0
     for arg, pkgs in self.pkgsFromArgs(args):
         expected += 1
         found = False
         for pkg in pkgs:
             if pkg.installed:
                 found = True
                 transaction.enqueue(pkg, REMOVE)
                 for _pkg in cache.getPackages(pkg.name):
                     if not _pkg.installed:
                         policy.setLocked(_pkg, True)
         if not found:
             raise Error, _("'%s' matches no installed packages") % arg
     transaction.run()
     if opts.explain:
         self.setExplain(True)
     if iface.confirmChange(self._changeset, changeset, expected):
         self.saveUndo()
         self._changeset.setState(changeset)
     if opts.explain:
         self.setExplain(False)
开发者ID:KortanZ,项目名称:linux,代码行数:31,代码来源:interactive.py


示例3: do_keep

 def do_keep(self, line):
     args = shlex.split(line)
     parser = OptionParser(add_help_option=False)
     parser.add_option("--explain", action="store_true")
     opts, args = parser.parse_args(args)
     cache = self._ctrl.getCache()
     transaction = Transaction(cache, policy=PolicyInstall)
     transaction.setState(self._changeset)
     changeset = transaction.getChangeSet()
     expected = 0
     for arg, pkgs in self.pkgsFromArgs(args):
         expected += 1
         pkgs = [x for x in pkgs if x in changeset]
         if not pkgs:
             raise Error, _("'%s' matches no marked packages") % arg
         for pkg in pkgs:
             transaction.enqueue(pkg, KEEP)
     transaction.run()
     if opts.explain:
         self.setExplain(True)
     if iface.confirmChange(self._changeset, changeset, expected):
         self.saveUndo()
         self._changeset.setState(changeset)
     if opts.explain:
         self.setExplain(False)
开发者ID:KortanZ,项目名称:linux,代码行数:25,代码来源:interactive.py


示例4: do_reinstall

 def do_reinstall(self, line):
     args = shlex.split(line)
     parser = OptionParser(add_help_option=False)
     parser.add_option("--explain", action="store_true")
     opts, args = parser.parse_args(args)
     cache = self._ctrl.getCache()
     transaction = Transaction(cache, policy=PolicyInstall)
     transaction.setState(self._changeset)
     changeset = transaction.getChangeSet()
     expected = 0
     for arg, pkgs in self.pkgsFromArgs(args):
         expected += 1
         if not pkgs:
             raise Error, _("'%s' matches no installed packages") % arg
         if len(pkgs) > 1:
             raise Error, _("'%s' matches multiple installed packages")%arg
         transaction.enqueue(pkgs[0], REINSTALL)
     transaction.run()
     if opts.explain:
         self.setExplain(True)
     if iface.confirmChange(self._changeset, changeset, expected):
         self.saveUndo()
         self._changeset.setState(changeset)
     if opts.explain:
         self.setExplain(False)
开发者ID:KortanZ,项目名称:linux,代码行数:25,代码来源:interactive.py


示例5: do_upgrade

 def do_upgrade(self, line):
     args = shlex.split(line)
     parser = OptionParser(add_help_option=False)
     parser.add_option("--explain", action="store_true")
     opts, args = parser.parse_args(args)
     cache = self._ctrl.getCache()
     transaction = Transaction(cache, policy=PolicyUpgrade)
     transaction.setState(self._changeset)
     changeset = transaction.getChangeSet()
     expected = 0
     if not args:
         for pkg in cache.getPackages():
             if pkg.installed:
                 transaction.enqueue(pkg, UPGRADE)
     else:
         for arg, pkgs in self.pkgsFromArgs(args):
             expected += 1
             found = False
             for pkg in pkgs:
                 if pkg.installed:
                     found = True
                     transaction.enqueue(pkg, UPGRADE)
             if not found:
                 raise Error, _("'%s' matches no installed packages") % arg
     transaction.run()
     if opts.explain:
         self.setExplain(True)
     if changeset == self._changeset:
         print _("No interesting upgrades available!")
     elif iface.confirmChange(self._changeset, changeset, expected):
         self.saveUndo()
         self._changeset.setState(changeset)
     if opts.explain:
         self.setExplain(False)
开发者ID:KortanZ,项目名称:linux,代码行数:34,代码来源:interactive.py


示例6: do_install

 def do_install(self, line):
     args = shlex.split(line)
     parser = OptionParser(add_help_option=False)
     parser.add_option("--explain", action="store_true")
     opts, args = parser.parse_args(args)
     cache = self._ctrl.getCache()
     transaction = Transaction(cache, policy=PolicyInstall)
     transaction.setState(self._changeset)
     changeset = transaction.getChangeSet()
     expected = 0
     for arg, pkgs in self.pkgsFromArgs(args):
         expected += 1
         names = {}
         found = False
         for pkg in pkgs:
             names.setdefault(pkg.name, []).append(pkg)
         for name in names:
             pkg = names[name][0]
             if pkg.installed:
                 iface.warning(_("%s is already installed") % pkg)
             else:
                 found = True
                 transaction.enqueue(pkg, INSTALL)
         if not found:
             raise Error, _("No uninstalled packages matched '%s'") % arg
     transaction.run()
     if opts.explain:
         self.setExplain(True)
     if iface.confirmChange(self._changeset, changeset, expected):
         self.saveUndo()
         self._changeset.setState(changeset)
     if opts.explain:
         self.setExplain(False)
开发者ID:KortanZ,项目名称:linux,代码行数:33,代码来源:interactive.py


示例7: option_parser

def option_parser():
    parser = OptionParser(usage=USAGE,
                          description=DESCRIPTION,
                          examples=EXAMPLES)
    parser.add_option("--after", metavar="MIN", type="int",
                      help=_("only update if the last successful update "
                             "happened before the given delay"))
    return parser
开发者ID:Kampi,项目名称:Zybo-Linux,代码行数:8,代码来源:update.py


示例8: parse_options

def parse_options(argv):
    parser = OptionParser(usage=USAGE,
                          description=DESCRIPTION,
                          examples=EXAMPLES)
    parser.add_option("--after", metavar="MIN", type="int",
                      help=_("only update if the last successful update "
                             "happened before the given delay"))
    opts, args = parser.parse_args(argv)
    opts.args = args
    return opts
开发者ID:NehaRawat,项目名称:spacewalk,代码行数:10,代码来源:update.py


示例9: parse_options

def parse_options(argv, help=None):
    if help:
        parser = OptionParser(help=help)
    else:
        parser = OptionParser(usage=USAGE,
                              description=DESCRIPTION,
                              examples=EXAMPLES)
    opts, args = parser.parse_args(argv)
    opts.args = args
    return opts
开发者ID:DAP-DarkneSS,项目名称:obs,代码行数:10,代码来源:smart-newer.py


示例10: parse_options

def parse_options(argv):
    parser = OptionParser(usage=USAGE,
                          description=DESCRIPTION,
                          examples=EXAMPLES)
    parser.add_option("--set", action="store_true",
                      help=_("set priority"))
    parser.add_option("--remove", action="store_true",
                      help=_("unset priority"))
    parser.add_option("--show", action="store_true",
                      help=_("show priorities"))
    parser.add_option("--force", action="store_true",
                      help=_("ignore problems"))
    opts, args = parser.parse_args(argv)
    opts.args = args
    return opts
开发者ID:NehaRawat,项目名称:spacewalk,代码行数:15,代码来源:priority.py


示例11: parse_options

def parse_options(argv):
    parser = OptionParser(usage=USAGE,
                          description=DESCRIPTION,
                          examples=EXAMPLES)
    parser.add_option("--stepped", action="store_true",
                      help=_("split operation in steps"))
    parser.add_option("--urls", action="store_true",
                      help=_("dump needed urls and don't commit operation"))
    parser.add_option("--download", action="store_true",
                      help=_("download packages and don't commit operation"))
    parser.add_option("-y", "--yes", action="store_true",
                      help=_("do not ask for confirmation"))
    opts, args = parser.parse_args(argv)
    opts.args = args
    return opts
开发者ID:NehaRawat,项目名称:spacewalk,代码行数:15,代码来源:remove.py


示例12: parse_options

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
开发者ID:NehaRawat,项目名称:spacewalk,代码行数:18,代码来源:download.py


示例13: parse_options

def parse_options(argv):
    parser = OptionParser(usage=USAGE,
                          description=DESCRIPTION,
                          examples=EXAMPLES)
    parser.add_option("--all", action="store_true",
                      help=_("check packages in all channels"))
    parser.add_option("--installed", action="store_true",
                      help=_("check packages which are in at least "
                             "one installed channel (default)"))
    parser.add_option("--available", action="store_true",
                      help=_("check packages which are in at least "
                             "one non-installed channel"))
    parser.add_option("--channels", action="store", metavar="ALIASES",
                      help=_("check packages which are inside the "
                             "given channels (comma separated aliases)"))
    opts, args = parser.parse_args(argv)
    opts.args = args
    return opts
开发者ID:nikhilgv9,项目名称:winlibrepacman,代码行数:18,代码来源:check.py


示例14: parse_options

def parse_options(argv):
    parser = OptionParser(usage=USAGE, description=DESCRIPTION, examples=EXAMPLES)
    parser.add_option("--urls", action="store_true", help=_("show URLs"))
    parser.add_option("--paths", action="store_true", help=_("show path list"))
    opts, args = parser.parse_args(argv)
    opts.args = args
    return opts
开发者ID:pombredanne,项目名称:winlibrepacman,代码行数:7,代码来源:info.py


示例15: option_parser

def option_parser():
    parser = OptionParser(usage=USAGE,
                          description=DESCRIPTION,
                          examples=EXAMPLES)
    parser.add_option("--urls", action="store_true",
                      help=_("show URLs"))
    parser.add_option("--paths", action="store_true",
                      help=_("show path list"))
    parser.add_option("--changelog", action="store_true",
                      help=_("show change log"))
    return parser
开发者ID:Kampi,项目名称:Zybo-Linux,代码行数:11,代码来源:info.py


示例16: do_fix

 def do_fix(self, line):
     args = shlex.split(line)
     parser = OptionParser(add_help_option=False)
     parser.add_option("--explain", action="store_true")
     opts, args = parser.parse_args(args)
     cache = self._ctrl.getCache()
     transaction = Transaction(cache, policy=PolicyInstall)
     transaction.setState(self._changeset)
     changeset = transaction.getChangeSet()
     expected = 0
     for arg, pkgs in self.pkgsFromArgs(args):
         expected += 1
         for pkg in pkgs:
             transaction.enqueue(pkg, FIX)
     transaction.run()
     if opts.explain:
         self.setExplain(True)
     if changeset == self._changeset:
         print _("No problems to resolve!")
     elif iface.confirmChange(self._changeset, changeset, expected):
         self.saveUndo()
         self._changeset.setState(changeset)
     if opts.explain:
         self.setExplain(False)
开发者ID:KortanZ,项目名称:linux,代码行数:24,代码来源:interactive.py


示例17: parse_options

def parse_options(argv):
    parser = OptionParser(usage=USAGE,
                          description=DESCRIPTION,
                          examples=EXAMPLES)
    parser.add_option("--all", action="store_true",
                      help=_("check uninstalled packages as well"))
    parser.add_option("--uninstalled", action="store_true",
                      help=_("check only uninstalled packages"))
    opts, args = parser.parse_args(argv)
    opts.args = args
    return opts
开发者ID:NehaRawat,项目名称:spacewalk,代码行数:11,代码来源:check.py


示例18: option_parser

def option_parser():
    parser = OptionParser(usage=USAGE,
                          description=DESCRIPTION,
                          examples=EXAMPLES)
    parser.add_option("--set", action="store_true",
                      help=_("set priority"))
    parser.add_option("--remove", action="store_true",
                      help=_("unset priority"))
    parser.add_option("--show", action="store_true",
                      help=_("show priorities"))
    parser.add_option("--yaml", action="store_true",
                      help=_("show priorities in YAML format"))
    parser.add_option("--force", action="store_true",
                      help=_("ignore problems"))
    return parser
开发者ID:bluelightning,项目名称:smart,代码行数:15,代码来源:priority.py


示例19: parse_options

def parse_options(argv):
    parser = OptionParser(usage=USAGE, description=DESCRIPTION, examples=EXAMPLES, version="smart %s" % VERSION)
    parser.disable_interspersed_args()
    parser.add_option(
        "--config-file", metavar=_("FILE"), help=_("configuration file " "(default is <data-dir>/config)")
    )
    parser.add_option("--data-dir", metavar=_("DIR"), help=_("data directory (default is %s)") % DATADIR)
    parser.add_option(
        "--log-level", metavar=_("LEVEL"), help=_("set the log level to LEVEL (debug, info, " "warning, error)")
    )
    parser.add_option("--gui", action="store_true", help=_("use the default graphic interface"))
    parser.add_option("--shell", action="store_true", help=_("use the default shell interface"))
    parser.add_option("--interface", metavar=_("NAME"), help=_("use the given interface"))
    parser.add_option("--ignore-locks", action="store_true", help=_("don't respect locking"))
    parser.add_option(
        "-o",
        "--option",
        action="append",
        default=[],
        metavar=_("OPT"),
        help=_("set the option given by a name=value pair"),
    )
    opts, args = parser.parse_args()
    if args:
        opts.command = args[0]
        opts.argv = args[1:]
    else:
        opts.command = None
        opts.argv = []
    if not (opts.command or opts.gui or opts.shell):
        parser.print_help()
        sys.exit(1)
    return opts
开发者ID:jbzhang99,项目名称:spacewalk,代码行数:33,代码来源:smart.py


示例20: parse_options

def parse_options(argv, help=None):
    if help:
        parser = OptionParser(help=help)
    else:
        parser = OptionParser(usage=USAGE,
                              description=DESCRIPTION,
                              examples=EXAMPLES)
    parser.add_option("--installed", action="store_true",
                      help=_("consider only installed packages"))
    parser.add_option("--provides", action="append", default=[], metavar="DEP",
                      help=_("show only packages providing the given "
                             "dependency"))
    parser.add_option("--requires", action="append", default=[], metavar="DEP",
                      help=_("show only packages requiring the given "
                             "dependency"))
    parser.add_option("--conflicts", action="append", default=[], metavar="DEP",
                      help=_("show only packages conflicting with the given "
                             "dependency"))
    parser.add_option("--upgrades", action="append", default=[], metavar="DEP",
                      help=_("show only packages upgrading the given "
                             "dependency"))
    parser.add_option("--name", action="append", default=[], metavar="STR",
                      help=_("show only packages which match given name"))
    parser.add_option("--summary", action="append", default=[], metavar="STR",
                      help=_("show only packages which match given summary"))
    parser.add_option("--description", action="append", default=[], metavar="STR",
                      help=_("show only packages which match given "
                             "description"))
    parser.add_option("--path", action="append", default=[], metavar="STR",
                      help=_("show only packages which include the given "
                             "path in the available meta information"))
    parser.add_option("--url", action="append", default=[], metavar="STR",
                      help=_("show only packages which include the given "
                             "reference url in the available meta "
                             "information"))
    parser.add_option("--hide-version", action="store_true",
                      help=_("hide package version"))
    parser.add_option("--show-summary", action="store_true",
                      help=_("show package summaries"))
    parser.add_option("--show-provides", action="store_true",
                      help=_("show provides for the given packages"))
    parser.add_option("--show-requires", action="store_true",
                      help=_("show requires for the given packages"))
    parser.add_option("--show-prerequires", action="store_true",
                      help=_("show requires selecting only pre-dependencies"))
    parser.add_option("--show-upgrades", action="store_true",
                      help=_("show upgrades for the given packages"))
    parser.add_option("--show-conflicts", action="store_true",
                      help=_("show conflicts for the given packages"))
    parser.add_option("--show-providedby", action="store_true",
                      help=_("show packages providing dependencies"))
    parser.add_option("--show-requiredby", action="store_true",
                      help=_("show packages requiring provided information"))
    parser.add_option("--show-upgradedby", action="store_true",
                      help=_("show packages upgrading provided information"))
    parser.add_option("--show-conflictedby", action="store_true",
                      help=_("show packages conflicting with provided "
                             "information"))
    parser.add_option("--show-priority", action="store_true",
                      help=_("show package priority"))
    parser.add_option("--show-channels", action="store_true",
                      help=_("show channels that include this package"))
    parser.add_option("--show-all", action="store_true",
                      help=_("enable all --show-* options"))
    parser.add_option("--format", action="store", default="text",
                      metavar="FMT", help=_("change output format"))
    parser.add_option("--output", action="store", metavar="FILE",
                      help=_("redirect output to given filename"))
    opts, args = parser.parse_args(argv)
    opts.args = args
    if opts.show_all:
        for attr in dir(opts):
            if attr.startswith("show_") and attr != "show_prerequires":
                setattr(opts, attr, True)
    return opts
开发者ID:nikhilgv9,项目名称:winlibrepacman,代码行数:75,代码来源:query.py



注:本文中的smart.option.OptionParser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sysconf.get函数代码示例发布时间:2022-05-27
下一篇:
Python gtk.getPixbuf函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap