本文整理汇总了Python中solo.commands.descriptor.SoloCommandDescriptor类的典型用法代码示例。如果您正苦于以下问题:Python SoloCommandDescriptor类的具体用法?Python SoloCommandDescriptor怎么用?Python SoloCommandDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SoloCommandDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_parser
def _get_parser(self):
"""
Overridden from SoloCommand.
"""
_commands = {}
descriptor = SoloCommandDescriptor.obtain_descriptor(
SoloPreservedLibs.NAME)
parser = argparse.ArgumentParser(
description=descriptor.get_description(),
formatter_class=argparse.RawDescriptionHelpFormatter,
prog="%s %s" % (sys.argv[0], SoloPreservedLibs.NAME))
subparsers = parser.add_subparsers(
title="action",
description=_("manage preserved libraries"),
help=_("available commands"))
list_parser = subparsers.add_parser(
"list", help=_("list the currently preserved libraries"))
list_parser.set_defaults(func=self._list)
self._setup_verbose_quiet_parser(list_parser)
_commands["list"] = {}
gc_parser = subparsers.add_parser(
"gc", help=_("show libraries that could be garbage collected"))
gc_parser.set_defaults(func=self._gc)
_commands["gc"] = {}
self._commands = _commands
return parser
示例2: _get_parser
def _get_parser(self):
"""
Overridden from SoloCommand.
"""
descriptor = SoloCommandDescriptor.obtain_descriptor(
SoloSearch.NAME)
parser = argparse.ArgumentParser(
description=descriptor.get_description(),
formatter_class=argparse.RawDescriptionHelpFormatter,
prog="%s %s" % (sys.argv[0], SoloSearch.NAME))
parser.add_argument("string", nargs='+',
metavar="<string>", help=_("search keyword"))
parser.add_argument("--quiet", "-q", action="store_true",
default=self._quiet,
help=_('quiet output, for scripting purposes'))
parser.add_argument("--verbose", "-v", action="store_true",
default=self._verbose,
help=_('verbose output'))
group = parser.add_mutually_exclusive_group()
group.add_argument("--installed", action="store_true",
default=self._installed,
help=_('search among installed packages only'))
group.add_argument("--available", action="store_true",
default=self._available,
help=_('search among available packages only'))
return parser
示例3: _get_parser
def _get_parser(self):
"""
Overridden from SoloCommand.
"""
_commands = []
descriptor = SoloCommandDescriptor.obtain_descriptor(
SoloCache.NAME)
parser = argparse.ArgumentParser(
description=descriptor.get_description(),
formatter_class=argparse.RawDescriptionHelpFormatter,
prog="%s %s" % (sys.argv[0], SoloCache.NAME))
subparsers = parser.add_subparsers(
title="action", description=_("manage cache"),
help=_("available commands"))
clean_parser = subparsers.add_parser(
"clean", help=_("clean Entropy Library Cache"))
clean_parser.add_argument(
"--verbose", "-v", action="store_true", default=False,
help=_("show more details"))
clean_parser.add_argument(
"--quiet", "-q", action="store_true", default=False,
help=_("print results in a scriptable way"))
clean_parser.set_defaults(func=self._clean)
_commands.append("clean")
self._commands = _commands
return parser
示例4: _get_parser
def _get_parser(self):
"""
Overridden from SoloCommand.
"""
_commands = []
descriptor = SoloCommandDescriptor.obtain_descriptor(
SoloConf.NAME)
parser = argparse.ArgumentParser(
description=descriptor.get_description(),
formatter_class=argparse.RawDescriptionHelpFormatter,
prog="%s %s" % (sys.argv[0], SoloConf.NAME))
subparsers = parser.add_subparsers(
title="action",
description=_("manage configuration file updates"),
help=_("available commands"))
update_parser = subparsers.add_parser(
"update", help=_("update configuration files"))
update_parser.set_defaults(func=self._update)
_commands.append("update")
self._commands = _commands
return parser
示例5: _get_parser
def _get_parser(self):
"""
Overridden from SoloCommand.
"""
_commands = []
descriptor = SoloCommandDescriptor.obtain_descriptor(
SoloUnused.NAME)
parser = argparse.ArgumentParser(
description=descriptor.get_description(),
formatter_class=argparse.RawDescriptionHelpFormatter,
prog="%s %s" % (sys.argv[0], SoloUnused.NAME))
parser.add_argument("--quiet", "-q", action="store_true",
default=self._quiet,
help=_("show less details (useful for scripting)"))
_commands.append("--quiet")
_commands.append("-q")
parser.add_argument("--sortbysize", action="store_true",
default=self._sortbysize,
help=_("sort packages by size"))
_commands.append("--sortbysize")
parser.add_argument("--by-user", action="store_true",
default=self._byuser,
help=_("include packages installed by user"))
_commands.append("--by-user")
self._commands = _commands
return parser
示例6: _show_help
def _show_help(self, *args):
# equo help <foo> <bar>
if len(self._args) > 1:
# syntax error
return -10
parser = argparse.ArgumentParser(
description=_("Entropy Command Line Client, Equo"),
epilog="http://www.argentlinux.io",
formatter_class=ColorfulFormatter)
# filtered out in solo.main. Will never get here
parser.add_argument(
"--color", action="store_true",
default=None, help=_("force colored output"))
descriptors = SoloCommandDescriptor.obtain()
descriptors.sort(key = lambda x: x.get_name())
group = parser.add_argument_group("command", "available commands")
for descriptor in descriptors:
if descriptor.get_class().HIDDEN:
continue
aliases = descriptor.get_class().ALIASES
aliases_str = ", ".join([teal(x) for x in aliases])
if aliases_str:
aliases_str = " [%s]" % (aliases_str,)
name = "%s%s" % (purple(descriptor.get_name()),
aliases_str)
desc = descriptor.get_description()
group.add_argument(name, help=darkgreen(desc), action="store_true")
parser.print_help()
if not self._args:
return 1
return 0
示例7: bashcomp
def bashcomp(self, last_arg):
"""
Overridden from SoloCommand
"""
import sys
descriptors = SoloCommandDescriptor.obtain()
descriptors.sort(key = lambda x: x.get_name())
outcome = []
for descriptor in descriptors:
name = descriptor.get_name()
if name == SoloHelp.NAME:
# do not add self
continue
outcome.append(name)
aliases = descriptor.get_class().ALIASES
outcome.extend(aliases)
def _startswith(string):
if last_arg is not None:
return string.startswith(last_arg)
return True
outcome = sorted(filter(_startswith, outcome))
sys.stdout.write(" ".join(outcome) + "\n")
sys.stdout.flush()
示例8: _get_parser
def _get_parser(self):
"""
Overridden from SoloCommand.
"""
descriptor = SoloCommandDescriptor.obtain_descriptor(
SoloStatus.NAME)
parser = argparse.ArgumentParser(
description=descriptor.get_description(),
formatter_class=argparse.RawDescriptionHelpFormatter,
prog="%s %s" % (sys.argv[0], SoloStatus.NAME))
return parser
示例9: _get_parser
def _get_parser(self):
"""
Overridden from SoloCommand.
"""
descriptor = SoloCommandDescriptor.obtain_descriptor(
SoloNotice.NAME)
parser = argparse.ArgumentParser(
description=descriptor.get_description(),
formatter_class=argparse.RawDescriptionHelpFormatter,
prog="%s %s" % (sys.argv[0], SoloNotice.NAME))
parser.add_argument("repo", nargs='+',
metavar="<repo>", help=_("repository"))
return parser
示例10: _get_parser
def _get_parser(self):
"""
Overridden from SoloCommand.
"""
descriptor = SoloCommandDescriptor.obtain_descriptor(
SoloHop.NAME)
parser = argparse.ArgumentParser(
description=descriptor.get_description(),
formatter_class=argparse.RawDescriptionHelpFormatter,
prog="%s %s" % (sys.argv[0], SoloHop.NAME))
parser.add_argument(
"branch", metavar="<branch>", help=_("branch"))
return parser
示例11: _get_parser
def _get_parser(self):
"""
Overridden from SoloCommand.
"""
descriptor = SoloCommandDescriptor.obtain_descriptor(
SoloUpdate.NAME)
parser = argparse.ArgumentParser(
description=descriptor.get_description(),
formatter_class=argparse.RawDescriptionHelpFormatter,
prog="%s %s" % (sys.argv[0], SoloUpdate.NAME))
parser.add_argument("repo", nargs='*', default=None,
metavar="<repo>", help=_("repository"))
parser.add_argument("--force", action="store_true",
default=self._force,
help=_("force update"))
return parser
示例12: _get_parser
def _get_parser(self):
"""
Overridden from SoloCommand.
"""
descriptor = SoloCommandDescriptor.obtain_descriptor(
SoloLibtest.NAME)
parser = argparse.ArgumentParser(
description=descriptor.get_description(),
formatter_class=argparse.RawDescriptionHelpFormatter,
prog="%s %s" % (sys.argv[0], SoloLibtest.NAME))
_commands = []
parser.add_argument("--ask", "-a", action="store_true",
default=False,
help=_("ask before making any changes"))
_commands.append("--ask")
_commands.append("-a")
parser.add_argument("--quiet", "-q", action="store_true",
default=False,
help=_("show less details "
"(useful for scripting)"))
_commands.append("--quiet")
_commands.append("-q")
parser.add_argument("--pretend", "-p", action="store_true",
default=False,
help=_("just show what would be done"))
_commands.append("--pretend")
_commands.append("-p")
parser.add_argument("--listfiles", action="store_true",
default=False,
help=_("print broken files to stdout"))
_commands.append("--listfiles")
parser.add_argument("--dump", action="store_true",
default=False,
help=_("dump results to files"))
_commands.append("--dump")
self._commands = _commands
return parser
示例13: _get_parser
def _get_parser(self):
"""
Overridden from SoloCommand.
"""
_commands = {}
descriptor = SoloCommandDescriptor.obtain_descriptor(
SoloConfig.NAME)
parser = argparse.ArgumentParser(
description=descriptor.get_description(),
formatter_class=argparse.RawDescriptionHelpFormatter,
prog="%s %s" % (sys.argv[0], SoloConfig.NAME))
parser.set_defaults(func=self._config)
parser.add_argument(
"packages", nargs='+',
metavar="<package>", help=_("package name"))
mg_group = parser.add_mutually_exclusive_group()
mg_group.add_argument(
"--ask", "-a", action="store_true",
default=False,
help=_("ask before making any changes"))
_commands["--ask"] = {}
_commands["-a"] = {}
mg_group.add_argument(
"--pretend", "-p", action="store_true",
default=False,
help=_("show what would be done"))
_commands["--pretend"] = {}
_commands["-p"] = {}
parser.add_argument(
"--verbose", "-v", action="store_true",
default=False,
help=_("verbose output"))
_commands["--verbose"] = {}
_commands["-v"] = {}
self._commands = _commands
return parser
示例14: _get_parser
def _get_parser(self):
"""
Overridden from SoloCommand.
"""
descriptor = SoloCommandDescriptor.obtain_descriptor(
SoloDeptest.NAME)
parser = argparse.ArgumentParser(
description=descriptor.get_description(),
formatter_class=argparse.RawDescriptionHelpFormatter,
prog="%s %s" % (sys.argv[0], SoloDeptest.NAME))
parser.add_argument("--ask", "-a", action="store_true",
default=self._ask,
help=_("ask before making any changes"))
parser.add_argument("--quiet", "-q", action="store_true",
default=self._quiet,
help=_("show less details (useful for scripting)"))
parser.add_argument("--pretend", "-p", action="store_true",
default=self._pretend,
help=_("just show what would be done"))
return parser
示例15: _get_parser
def _get_parser(self):
"""
Overridden from SoloCommand.
"""
descriptor = SoloCommandDescriptor.obtain_descriptor(
self.NAME)
parser = argparse.ArgumentParser(
description=descriptor.get_description(),
formatter_class=argparse.RawDescriptionHelpFormatter,
prog="%s %s" % (sys.argv[0], self.NAME))
parser.add_argument("packages", nargs='+',
metavar="<package>", help=_("package name"))
group = parser.add_mutually_exclusive_group()
group.add_argument("--ask", "-a", action="store_true",
default=self._ask,
help=_('ask before making any changes'))
group.add_argument("--pretend", "-p", action="store_true",
default=self._pretend,
help=_('only show what would be done'))
return parser