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


Python EitCommandDescriptor.register方法代码示例

本文整理汇总了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"))
    )
开发者ID:B-Rich,项目名称:entropy,代码行数:31,代码来源:help.py

示例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'))
    )
开发者ID:B-Rich,项目名称:entropy,代码行数:32,代码来源:revgraph.py

示例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
开发者ID:B-Rich,项目名称:entropy,代码行数:34,代码来源:cleanup.py

示例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'))
    )
开发者ID:dMaggot,项目名称:entropy,代码行数:32,代码来源:own.py

示例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"))
    )
开发者ID:Heather,项目名称:entropy,代码行数:32,代码来源:status.py

示例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'))
    )
开发者ID:B-Rich,项目名称:entropy,代码行数:32,代码来源:add.py

示例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)"))
    )
开发者ID:dMaggot,项目名称:entropy,代码行数:31,代码来源:list.py

示例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'))
    )
开发者ID:B-Rich,项目名称:entropy,代码行数:32,代码来源:query.py

示例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'))
    )
开发者ID:dMaggot,项目名称:entropy,代码行数:32,代码来源:mv.py

示例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'))
    )
开发者ID:B-Rich,项目名称:entropy,代码行数:32,代码来源:notice.py

示例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'))
    )
开发者ID:B-Rich,项目名称:entropy,代码行数:32,代码来源:remove.py

示例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'))
    )
开发者ID:B-Rich,项目名称:entropy,代码行数:32,代码来源:checkout.py

示例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'))
    )
开发者ID:dMaggot,项目名称:entropy,代码行数:32,代码来源:test.py

示例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'))
    )
开发者ID:B-Rich,项目名称:entropy,代码行数:32,代码来源:bump.py

示例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"))
    )
开发者ID:dMaggot,项目名称:entropy,代码行数:32,代码来源:repo.py


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