当前位置: 首页>>代码示例>>Python>>正文


Python option.OptionParser类代码示例

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


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


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