本文整理汇总了Python中eit.commands.descriptor.EitCommandDescriptor.register方法的典型用法代码示例。如果您正苦于以下问题:Python EitCommandDescriptor.register方法的具体用法?Python EitCommandDescriptor.register怎么用?Python EitCommandDescriptor.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eit.commands.descriptor.EitCommandDescriptor
的用法示例。
在下文中一共展示了EitCommandDescriptor.register方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _show_help
# 需要导入模块: from eit.commands.descriptor import EitCommandDescriptor [as 别名]
# 或者: from eit.commands.descriptor.EitCommandDescriptor import register [as 别名]
def _show_help(self, *args):
parser = argparse.ArgumentParser(
description=_("Entropy Infrastructure Toolkit"),
epilog="http://www.sabayon.org",
formatter_class=ColorfulFormatter)
descriptors = EitCommandDescriptor.obtain()
descriptors.sort(key = lambda x: x.get_name())
group = parser.add_argument_group("command", "available commands")
for descriptor in descriptors:
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
EitCommandDescriptor.register(
EitCommandDescriptor(
EitHelp,
EitHelp.NAME,
_("this help"))
)
示例2: _revgraph
# 需要导入模块: from eit.commands.descriptor import EitCommandDescriptor [as 别名]
# 或者: from eit.commands.descriptor.EitCommandDescriptor import register [as 别名]
nsargs = parser.parse_args(self._args)
except IOError:
return parser.print_help, []
self._quiet = nsargs.quiet
self._packages += nsargs.packages
self._complete = nsargs.complete
self._repository_id = nsargs.inrepo
return self._call_shared, [self._revgraph, self._repository_id]
def _revgraph(self, entropy_server):
"""
Actual Eit revgraph code.
"""
if self._repository_id is None:
repository_ids = entropy_server.repositories()
else:
repository_ids = [self._repository_id]
return revgraph_packages(
self._packages, entropy_server,
complete = self._complete,
repository_ids = repository_ids, quiet = self._quiet)
EitCommandDescriptor.register(
EitCommandDescriptor(
EitRevgraph,
EitRevgraph.NAME,
_('show reverse dependency graph for packages'))
)
示例3: purple
# 需要导入模块: from eit.commands.descriptor import EitCommandDescriptor [as 别名]
# 或者: from eit.commands.descriptor.EitCommandDescriptor import register [as 别名]
level="warning")
entropy_server.output(
purple(_("Users with older repositories will have to update")),
importance=1,
level="warning")
entropy_server.output("", level="warning")
repository_id = entropy_server.repository()
entropy_server.Mirrors.tidy_mirrors(
repository_id, ask = self._ask,
pretend = self._pretend, expiration_days = self._days)
return 0
EitCommandDescriptor.register(
EitCommandDescriptor(
EitCleanup,
EitCleanup.NAME,
_('clean expired packages from a repository'))
)
class EitVacuum(EitCleanup):
"""
Main Eit vacuum command (kept for backward compat).
"""
NAME = "vacuum"
ALIASES = []
def __init__(self, args):
EitCleanup.__init__(self, args)
# default is 0 here
self._days = 0
示例4: sorted
# 需要导入模块: from eit.commands.descriptor import EitCommandDescriptor [as 别名]
# 或者: from eit.commands.descriptor.EitCommandDescriptor import register [as 别名]
result = results[result]
for pkg_id in sorted(result, key = key_sorter):
if self._quiet:
entropy_server.output(
repo.retrieveAtom(pkg_id),
level="generic")
else:
print_package_info(pkg_id, entropy_server,
repo, installed_search = True,
extended = self._verbose,
quiet = self._quiet)
if not self._quiet:
entropy_server.output(
"[%s] %s: %s %s" % (
purple(repository_id),
darkgreen(xfile),
bold(str(len(result))),
teal(_("packages found"))))
return 0
EitCommandDescriptor.register(
EitCommandDescriptor(
EitOwn,
EitOwn.NAME,
_('search packages owning paths'))
)
示例5: teal
# 需要导入模块: from eit.commands.descriptor import EitCommandDescriptor [as 别名]
# 或者: from eit.commands.descriptor.EitCommandDescriptor import register [as 别名]
if pkg_id != -1:
etp_repo = entropy_server.open_repository(
repo_id).retrieveSpmRepository(pkg_id)
if etp_repo != spm_repo:
pkg_str += " [%s=>%s]" % (
etp_repo, spm_repo,)
toc.append((" %s:" % (purple(_("add")),), teal(pkg_str)))
for package_id, repo_id in sorted(to_be_removed, key = key_sorter):
pkg_atom = entropy_server.open_repository(
repo_id).retrieveAtom(package_id)
toc.append((" %s:" % (darkred(_("remove")),),
brown(pkg_atom)))
for package_id, repo_id in sorted(to_be_injected,
key = key_sorter):
pkg_atom = entropy_server.open_repository(
repo_id).retrieveAtom( package_id)
toc.append((" %s:" % (bold(_("switch injected")),),
darkgreen(pkg_atom)))
print_table(entropy_server, toc)
return 0
EitCommandDescriptor.register(
EitCommandDescriptor(
EitStatus,
EitStatus.NAME,
_("show repository status"))
)
示例6: parse
# 需要导入模块: from eit.commands.descriptor import EitCommandDescriptor [as 别名]
# 或者: from eit.commands.descriptor.EitCommandDescriptor import register [as 别名]
"and slot updates"),
default=self._conservative)
parser.add_argument("--to", metavar="<repository>",
help=_("add to given repository"),
default=None)
parser.add_argument("--quick", action="store_true",
default=not self._ask,
help=_("no stupid questions"))
return parser
def parse(self):
""" Overridden from EitCommit """
parser = self._get_parser()
try:
nsargs = parser.parse_args(self._args)
except IOError as err:
return parser.print_help, []
# setup atoms variable before spawning commit
self._ask = not nsargs.quick
self._entropy_class()._inhibit_treeupdates = nsargs.conservative
self._packages = nsargs.packages[:]
return self._call_exclusive, [self._commit, nsargs.to]
EitCommandDescriptor.register(
EitCommandDescriptor(
EitAdd,
EitAdd.NAME,
_('commit to repository the provided packages'))
)
示例7: darkgreen
# 需要导入模块: from eit.commands.descriptor import EitCommandDescriptor [as 别名]
# 或者: from eit.commands.descriptor.EitCommandDescriptor import register [as 别名]
branchinfo = ""
sizeinfo = ""
if self._verbose:
branch = entropy_repository.retrieveBranch(pkg_id)
branchinfo = darkgreen("[")+teal(branch)+darkgreen("]")
mysize = entropy_repository.retrieveOnDiskSize(pkg_id)
mysize = entropy.tools.bytes_into_human(mysize)
sizeinfo = brown("[")+purple(mysize)+brown("]")
if not self._quiet:
entropy_server.output(
"%s %s %s" % (
atom, sizeinfo, branchinfo),
header="")
else:
entropy_server.output(atom, level="generic")
if not pkg_ids and not self._quiet:
entropy_server.output(
darkgreen(_("No packages")),
header=brown(" @@ "))
EitCommandDescriptor.register(
EitCommandDescriptor(
EitList,
EitList.NAME,
_("show repository content (packages)"))
)
示例8: sorted
# 需要导入模块: from eit.commands.descriptor import EitCommandDescriptor [as 别名]
# 或者: from eit.commands.descriptor.EitCommandDescriptor import register [as 别名]
repo = entropy_server.open_repository(repository_id)
key_sorter = lambda x: repo.retrieveAtom(x)
for desc in self._nsargs.descriptions:
pkg_ids = repo.searchDescription(desc, just_id = True)
for pkg_id in sorted(pkg_ids, key = key_sorter):
if self._quiet:
entropy_server.output(
repo.retrieveAtom(pkg_id), level="generic")
else:
print_package_info(pkg_id, entropy_server, repo,
extended = self._verbose,
strict_output = False,
quiet = False)
if not self._quiet:
entropy_server.output(
"[%s] %s %s" % (
darkgreen(desc),
bold(str(len(pkg_ids))),
teal(_("packages found"))))
return 0
EitCommandDescriptor.register(
EitCommandDescriptor(
EitQuery,
EitQuery.NAME,
_('miscellaneous package metadata queries'))
)
示例9: man
# 需要导入模块: from eit.commands.descriptor import EitCommandDescriptor [as 别名]
# 或者: from eit.commands.descriptor.EitCommandDescriptor import register [as 别名]
def man(self):
"""
Overridden from EitCommand.
"""
return self._man()
def parse(self):
parser = self._get_parser()
try:
nsargs = parser.parse_args(self._args)
except IOError as err:
sys.stderr.write("%s\n" % (err,))
return parser.print_help, []
self._source = nsargs.source
self._dest = nsargs.dest
self._deps = nsargs.deps
self._packages += nsargs.packages
self._copy = False
self._entropy_class()._inhibit_treeupdates = nsargs.conservative
return self._call_locked, [self._move_copy, self._source]
EitCommandDescriptor.register(
EitCommandDescriptor(
EitMv,
EitMv.NAME,
_('move packages from a repository to another'))
)
示例10: blue
# 需要导入模块: from eit.commands.descriptor import EitCommandDescriptor [as 别名]
# 或者: from eit.commands.descriptor.EitCommandDescriptor import register [as 别名]
entropy_server.output(mytxt)
entropy_server.output("")
mytxt = "[%s] %s" % (
blue("-1"),
darkred(_("Exit/Commit")),
)
entropy_server.output(mytxt)
def fake_callback(s):
return s
input_params = [
('id', blue(_('Choose one by typing its identifier')),
fake_callback, False)]
data = entropy_server.input_box(title, input_params,
cancel_button = True)
if not isinstance(data, dict):
return -1
try:
return int(data['id'])
except ValueError:
return -2
EitCommandDescriptor.register(
EitCommandDescriptor(
EitNotice,
EitNotice.NAME,
_('manage repository notice-board'))
)
示例11: purple
# 需要导入模块: from eit.commands.descriptor import EitCommandDescriptor [as 别名]
# 或者: from eit.commands.descriptor.EitCommandDescriptor import register [as 别名]
importance=1, header=brown(" @@ "))
repo_map = {}
for pkg_id, repo_id in pkg_matches:
repo = entropy_server.open_repository(repo_id)
pkgatom = repo.retrieveAtom(pkg_id)
entropy_server.output(
"[%s] %s" % (teal(repo_id), purple(pkgatom)),
header=brown(" # "))
obj = repo_map.setdefault(repo_id, [])
obj.append(pkg_id)
if self._ask:
resp = entropy_server.ask_question(
_("Would you like to continue ?"))
if resp == _("No"):
return 0
for repo_id, pkg_ids in repo_map.items():
entropy_server.remove_packages(repo_id, pkg_ids)
return 0
EitCommandDescriptor.register(
EitCommandDescriptor(
EitRemove,
EitRemove.NAME,
_('remove packages from repository'))
)
示例12: parse
# 需要导入模块: from eit.commands.descriptor import EitCommandDescriptor [as 别名]
# 或者: from eit.commands.descriptor.EitCommandDescriptor import register [as 别名]
"""
return self._man()
def parse(self):
""" Overridden from EitCommand """
parser = self._get_parser()
try:
nsargs = parser.parse_args(self._args)
except IOError as err:
return parser.print_help, []
return self._call_exclusive, [self._checkout, nsargs.repo]
def _checkout(self, entropy_server):
"""
Actual Entropy Repository checkout function
"""
repository_id = entropy_server.repository()
entropy_server.switch_default_repository(repository_id,
save = True)
# show interface info
entropy_server._show_interface_status()
return 0
EitCommandDescriptor.register(
EitCommandDescriptor(
EitCheckout,
EitCheckout.NAME,
_('switch from a repository to another'))
)
示例13: purple
# 需要导入模块: from eit.commands.descriptor import EitCommandDescriptor [as 别名]
# 或者: from eit.commands.descriptor.EitCommandDescriptor import register [as 别名]
repository_id = entropy_server.repository()
if repository_id not in entropy_server.repositories():
entropy_server.output(
"%s: %s" % (
purple(_("Invalid repository")),
teal(repository_id)),
importance=1, level="error")
return 1
fine, failed, dl_fine, dl_err = \
entropy_server._verify_local_packages(
repository_id, [], ask = not self._nsargs.quick)
if failed:
return 1
return 0
def _rem_pkgtest(self, entropy_server):
repository_id = self._nsargs.repo
if repository_id is None:
repository_id = entropy_server.repository()
entropy_server._verify_remote_packages(repository_id, [],
ask = self._ask)
return 0
EitCommandDescriptor.register(
EitCommandDescriptor(
EitTest,
EitTest.NAME,
_('run QA tests'))
)
示例14: parse
# 需要导入模块: from eit.commands.descriptor import EitCommandDescriptor [as 别名]
# 或者: from eit.commands.descriptor.EitCommandDescriptor import register [as 别名]
def parse(self):
""" Overridden from EitCommand """
parser = self._get_parser()
try:
nsargs = parser.parse_args(self._args)
except IOError as err:
sys.stderr.write("%s\n" % (err,))
return parser.print_help, []
self._sync = nsargs.sync
return self._call_exclusive, [self._bump, nsargs.repo]
def _bump(self, entropy_server):
"""
Actual Entropy Repository bump function
"""
entropy_server.output(darkgreen(" * ")+blue("%s..." % (
_("Bumping repository"),) ))
entropy_server._bump_database(entropy_server.repository())
if self._sync:
errors = entropy_server.Mirrors.sync_repository(
entropy_server.repository())
return 0
EitCommandDescriptor.register(
EitCommandDescriptor(
EitBump,
EitBump.NAME,
_('bump repository revision, force push'))
)
示例15: purple
# 需要导入模块: from eit.commands.descriptor import EitCommandDescriptor [as 别名]
# 或者: from eit.commands.descriptor.EitCommandDescriptor import register [as 别名]
purple(repository_id),
blue(_("repository not available")),),
level="warning", importance=1)
exit_st = 1
continue
parser = RepositoryConfigParser()
removed = parser.remove(repository_id)
if not removed:
exit_st = 1
entropy_server.output(
"[%s] %s" % (
purple(repository_id),
blue(_("cannot remove repository")),),
level="warning", importance=1)
else:
entropy_server.output(
"[%s] %s" % (
purple(repository_id),
blue(_("repository removed succesfully")),))
return exit_st
EitCommandDescriptor.register(
EitCommandDescriptor(
EitRepo,
EitRepo.NAME,
_("manage repositories"))
)