示例#1
0
def option_parser(help=None):
    if help:
        parser = OptionParser(help=help)
    else:
        parser = OptionParser(usage=USAGE,
                              description=DESCRIPTION,
                              examples=EXAMPLES)
    return parser
示例#2
0
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("--check",
                      action="store_true",
                      help=_("just check if there are upgrades to be done"))
    parser.add_option("--check-update",
                      action="store_true",
                      help=_("check if there are upgrades to be done, and "
                             "update the known upgrades"))
    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
示例#3
0
 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)
示例#4
0
def option_parser():
    parser = OptionParser(usage=USAGE,
                          description=DESCRIPTION,
                          examples=EXAMPLES)
    parser.defaults["set"] = []
    parser.defaults["remove"] = []
    parser.defaults["show"] = None
    parser.defaults["yaml"] = None
    parser.add_option("--set",
                      action="callback",
                      callback=append_all,
                      help=_("set given key=value options"))
    parser.add_option("--show",
                      action="callback",
                      callback=append_all,
                      help=_("show given options"))
    parser.add_option("--yaml",
                      action="callback",
                      callback=append_all,
                      help=_("show given options in YAML format"))
    parser.add_option("--remove",
                      action="callback",
                      callback=append_all,
                      help=_("remove given options"))
    parser.add_option("--force",
                      action="store_true",
                      help=_("ignore problems"))
    return parser
示例#5
0
def parse_options(argv):
    parser = OptionParser(usage=USAGE,
                          description=DESCRIPTION,
                          examples=EXAMPLES)
    opts, args = parser.parse_args(argv)
    opts.args = args
    return opts
示例#6
0
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
示例#7
0
 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)
示例#8
0
def option_parser():
    parser = OptionParser(usage=USAGE,
                          description=DESCRIPTION,
                          examples=EXAMPLES)
    parser.add_option("--attempt",
                      action="store_true",
                      help=_("attempt to install packages, ignore failures"))
    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("--metalink",
                      action="store_true",
                      help=_("dump metalink xml and don't commit operation"))
    parser.add_option("--download",
                      action="store_true",
                      help=_("download packages and don't commit operation"))
    parser.add_option("--explain",
                      action="store_true",
                      help=_("include additional information about changes,"
                             "when possible"))
    parser.add_option("-y",
                      "--yes",
                      action="store_true",
                      help=_("do not ask for confirmation"))
    parser.add_option("--dump",
                      action="store_true",
                      help=_("dump package names and versions to stderr but "
                             "don't commit operation"))
    return parser
示例#9
0
 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)
示例#10
0
 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)
示例#11
0
def parse_options(argv):
    parser = OptionParser(usage=USAGE,
                          description=DESCRIPTION,
                          examples=EXAMPLES)
    parser.defaults["set"] = []
    parser.defaults["remove"] = []
    parser.defaults["show"] = None
    parser.add_option("--set",
                      action="callback",
                      callback=append_all,
                      help=_("set given key=value options"))
    parser.add_option("--show",
                      action="callback",
                      callback=append_all,
                      help=_("show given options"))
    parser.add_option("--remove",
                      action="callback",
                      callback=append_all,
                      help=_("remove given options"))
    parser.add_option("--force",
                      action="store_true",
                      help=_("ignore problems"))
    opts, args = parser.parse_args(argv)
    opts.args = args
    return opts
示例#12
0
 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)
示例#13
0
def option_parser():
    parser = OptionParser(usage=USAGE,
                          description=DESCRIPTION,
                          examples=EXAMPLES)
    parser.allow_interspersed_args = False
    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("--metalink", action="store_true",
                      help=_("dump metalink xml and don't commit operation"))
    parser.add_option("--download", action="store_true",
                      help=_("download packages and don't commit operation"))
    parser.add_option("--update", action="store_true",
                      help=_("update channel information before trying "
                             "to upgrade"))
    parser.add_option("--check", action="store_true",
                      help=_("just check if there are upgrades to be done"))
    parser.add_option("--check-update", action="store_true",
                      help=_("check if there are upgrades to be done, and "
                             "update the known upgrades"))
    parser.add_option("--explain", action="store_true",
                      help=_("include additional information about changes,"
                             "when possible"))
    parser.add_option("--flag", action="store", default=None,
                      help=_("check only upgrades with the given flag set"))
    parser.add_option("-y", "--yes", action="store_true",
                      help=_("do not ask for confirmation"))
    parser.add_option("--dump", action="store_true",
                      help=_("dump package names and versions to stderr but "
                             "don't commit operation"))
    return parser
示例#14
0
def parse_options(argv):
    parser = OptionParser(usage=USAGE,
                          description=DESCRIPTION,
                          examples=EXAMPLES)
    parser.defaults["set"] = []
    parser.defaults["remove"] = []
    parser.defaults["show"] = None
    parser.add_option("--set",
                      action="callback",
                      callback=append_all,
                      help=_("set flags given in pairs of flag name/target, "
                             "where targets may use just the package "
                             "name, or the package name, relation, and "
                             "version, such as: lock 'python > 1.0'"))
    parser.add_option("--remove",
                      action="callback",
                      callback=append_all,
                      help=_(
                          "remove flags given in pairs of flag name/target, "
                          "where targets may use just the package "
                          "name, or the package name, relation, and "
                          "version, such as: lock 'python > 1.0'"))
    parser.add_option("--show",
                      action="callback",
                      callback=append_all,
                      help=_("show packages with the flags given as arguments "
                             "or all flags if no argument was given"))
    parser.add_option("--force",
                      action="store_true",
                      help=_("ignore problems"))
    opts, args = parser.parse_args(argv)
    opts.args = args
    return opts
示例#15
0
def parse_options(argv):
    parser = OptionParser(usage=USAGE,
                          description=DESCRIPTION,
                          examples=EXAMPLES,
                          skipunknown=True,
                          add_help_option=False,
                          version="smart %s" % VERSION)
    parser.add_option("--config-file",
                      metavar=_("FILE"),
                      help=_("configuration file "
                             "(default is <data-dir>/config)"))
    parser.add_option("--rootfs-dir",
                      metavar=_("DIR"),
                      help=_("rootfs directory"))
    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("--quiet",
                      action="store_true",
                      help=_("use the quiet 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 = arg = args[0]
        opts.argv = args[1:]
        if arg and arg[0] == "-":
            if arg == "-h" or len(arg) > 2 and "--help".startswith(arg):
                parser.print_help()
                sys.exit(0)
            else:
                raise Error, _("no such option: %s") % arg
    else:
        opts.command = None
        opts.argv = []
    if not (opts.command or opts.gui or opts.shell or opts.interface):
        parser.print_help()
        sys.exit(1)
    return opts
示例#16
0
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
示例#17
0
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
示例#18
0
def parse_options(argv):
    description = DESCRIPTION % {"types": build_types()}
    parser = OptionParser(usage=USAGE,
                          description=description,
                          examples=EXAMPLES)
    parser.defaults["add"] = []
    parser.defaults["set"] = []
    parser.defaults["remove"] = []
    parser.defaults["enable"] = []
    parser.defaults["disable"] = []
    parser.defaults["show"] = None
    parser.add_option("--add",
                      action="callback",
                      callback=append_all,
                      help=_("argument is an alias and one or more "
                             "key=value pairs defining a channel, or a "
                             "filename/url pointing to a channel description "
                             "in the same format used by --show, or a "
                             "directory path where autodetection will be "
                             "tried"))
    parser.add_option("--set",
                      action="callback",
                      callback=append_all,
                      help=_("argument is an alias, and one or more key=value "
                             "pairs modifying a channel"))
    parser.add_option("--remove",
                      action="callback",
                      callback=append_all,
                      help=_("arguments are channel aliases to be removed"))
    parser.add_option("--show",
                      action="callback",
                      callback=append_all,
                      help=_("show channels with given aliases, or all "
                             "channels if no arguments were given"))
    parser.add_option("--edit",
                      action="store_true",
                      help=_("edit channels in editor set by $EDITOR"))
    parser.add_option("--enable",
                      action="callback",
                      callback=append_all,
                      help=_("enable channels with given aliases"))
    parser.add_option("--disable",
                      action="callback",
                      callback=append_all,
                      help=_("disable channels with given aliases"))
    parser.add_option("-y",
                      "--yes",
                      action="store_true",
                      help=_("execute without asking"))
    parser.add_option("--help-type",
                      action="store",
                      metavar="TYPE",
                      help=_("show further information about given type"))
    opts, args = parser.parse_args(argv)
    opts.args = args
    return opts
示例#19
0
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
示例#20
0
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
示例#21
0
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
示例#22
0
def option_parser():
    parser = OptionParser(usage=USAGE,
                          description=DESCRIPTION,
                          examples=EXAMPLES)
    parser.defaults["add"] = []
    parser.defaults["remove"] = []
    parser.defaults["remove_all"] = []
    parser.defaults["clear_history"] = None
    parser.add_option("--show",
                      action="store_true",
                      help=_("show current mirrors"))
    parser.add_option("--yaml",
                      action="store_true",
                      help=_("show current mirrors in YAML format"))
    parser.add_option("--add",
                      action="callback",
                      callback=append_all,
                      help=_("add to the given origin URL the given mirror "
                             "URL, provided either in pairs, or in a given "
                             "file/url in the format used by --show"))
    parser.add_option("--remove",
                      action="callback",
                      callback=append_all,
                      help=_("remove from the given origin URL the given "
                             "mirror URL, provided either in pairs, or in a "
                             "given file/url in the format used by --show"))
    parser.add_option("--remove-all",
                      action="callback",
                      callback=append_all,
                      help=_("remove all mirrors for the given origin URLs"))
    parser.add_option("--sync",
                      action="store",
                      metavar="FILE",
                      help=_("synchronize mirrors from the given file/url, "
                             "so that origins in the given file will have "
                             "exactly the specified mirrors"))
    parser.add_option("--edit",
                      action="store_true",
                      help=_("edit mirrors in editor set by $EDITOR"))
    parser.add_option("--clear-history",
                      action="callback",
                      callback=append_all,
                      help=_("clear history for the given origins/mirrors, or "
                             "for all mirrors"))
    parser.add_option("--show-penalities",
                      action="store_true",
                      help=_("show current penalities for origins/mirrors, "
                             "based on the history information"))
    return parser
示例#23
0
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
示例#24
0
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
示例#25
0
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
示例#26
0
def option_parser():
    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)"))
    return parser
示例#27
0
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
示例#28
0
 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)
示例#29
0
def parse_options(argv):
    parser = OptionParser(usage=USAGE)
    opts, args = parser.parse_args(argv)
    opts.args = args
    return opts
示例#30
0
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_"):
                setattr(opts, attr, True)
    return opts