Python pkg_resources 模块,iter_entry_points() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用pkg_resources.iter_entry_points()

项目:python-    作者:secondtonone1    | 项目源码 | 文件源码
def finalize_options(self):
        _Distribution.finalize_options(self)
        if self.features:
            self._set_global_opts_from_features()

        for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
            value = getattr(self, ep.name, None)
            if value is not None:
                ep.require(installer=self.fetch_build_egg)
                ep.load()(self, ep.name, value)
        if getattr(self, 'convert_2to3_doctests', None):
            # XXX may convert to set here when we can rely on set being builtin
            self.convert_2to3_doctests = [
                os.path.abspath(p)
                for p in self.convert_2to3_doctests
            ]
        else:
            self.convert_2to3_doctests = []
项目:kas    作者:siemens    | 项目源码 | 文件源码
def kas_get_argparser():
    """
        Creates a argparser for kas with all plugins.
    """
    parser = argparse.ArgumentParser(description='kas - setup tool for '
                                     'bitbake based project')

    verstr = '%(prog)s {} (configuration format version {}, ' \
        'earliest compatible version {})'.format(__version__, __file_version__,
                                                 __compatible_file_version__)
    parser.add_argument('--version', action='version', version=verstr)

    parser.add_argument('-d', '--debug',
                        action='store_true',
                        help='Enable debug logging')

    subparser = parser.add_subparsers(help='sub command help', dest='cmd')
    for ext_plugin in pkg_resources.iter_entry_points('kas.plugins'):
        ext_plugin.load()

    for plugin in getattr(kasplugin, 'plugins', []):
        plugin.get_argparser(subparser)

    return parser
项目:my-first-blog    作者:AnkurBegining    | 项目源码 | 文件源码
def finalize_options(self):
        _Distribution.finalize_options(self)
        if self.features:
            self._set_global_opts_from_features()

        for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
            value = getattr(self, ep.name, None)
            if value is not None:
                ep.require(installer=self.fetch_build_egg)
                ep.load()(self, ep.name, value)
        if getattr(self, 'convert_2to3_doctests', None):
            # XXX may convert to set here when we can rely on set being builtin
            self.convert_2to3_doctests = [
                os.path.abspath(p)
                for p in self.convert_2to3_doctests
            ]
        else:
            self.convert_2to3_doctests = []
项目:segno    作者:heuer    | 项目源码 | 文件源码
def __getattr__(self, name):
        """\
        This is used to plug-in external serializers.

        When a "to_<name>" method is invoked, this method tries to find
        a ``segno.plugin.converter`` plugin with the provided ``<name>``.
        If such a plugin exists, a callable function is returned. The result
        of invoking the function depends on the plugin.
        """
        if name.startswith('to_'):
            from pkg_resources import iter_entry_points
            from functools import partial
            for ep in iter_entry_points(group='segno.plugin.converter',
                                        name=name[3:]):
                plugin = ep.load()
                return partial(plugin, self)
        raise AttributeError('{0} object has no attribute {1}'
                             .format(self.__class__, name))
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def load(self, name):
        if name in self.impls:
            return self.impls[name]()

        if self.auto_fn:
            loader = self.auto_fn(name)
            if loader:
                self.impls[name] = loader
                return loader()

        try:
            import pkg_resources
        except ImportError:
            pass
        else:
            for impl in pkg_resources.iter_entry_points(
                    self.group, name):
                self.impls[name] = impl.load
                return impl.load()

        raise exc.NoSuchModuleError(
            "Can't load plugin: %s:%s" %
            (self.group, name))
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def __init__(self, attrs=None):
        have_package_data = hasattr(self, "package_data")
        if not have_package_data:
            self.package_data = {}
        _attrs_dict = attrs or {}
        if 'features' in _attrs_dict or 'require_features' in _attrs_dict:
            Feature.warn_deprecated()
        self.require_features = []
        self.features = {}
        self.dist_files = []
        self.src_root = attrs and attrs.pop("src_root", None)
        self.patch_missing_pkg_info(attrs)
        # Make sure we have any eggs needed to interpret 'attrs'
        if attrs is not None:
            self.dependency_links = attrs.pop('dependency_links', [])
            assert_string_list(self,'dependency_links',self.dependency_links)
        if attrs and 'setup_requires' in attrs:
            self.fetch_build_eggs(attrs.pop('setup_requires'))
        for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
            if not hasattr(self,ep.name):
                setattr(self,ep.name,None)
        _Distribution.__init__(self,attrs)
        if isinstance(self.metadata.version, numeric_types):
            # Some people apparently take "version number" too literally :)
            self.metadata.version = str(self.metadata.version)
项目:jenkins-epo    作者:peopledoc    | 项目源码 | 文件源码
def __init__(self):
        self.extensions_map = {}
        for ep in pkg_resources.iter_entry_points(__name__ + '.extensions'):
            cls = ep.resolve()
            if not match(ep.name, self.ext_patterns):
                logger.debug("Filtered extension %s.", ep.name)
                continue
            ext = cls(ep.name, self)
            if not ext.is_enabled(SETTINGS):
                logger.debug("Disabled extension %s.", ext)
                continue
            self.extensions_map[ep.name] = ext
            SETTINGS.load(ext.SETTINGS)
            logger.debug("Loaded extension %s.", ext)

        self.extensions = sorted(
            self.extensions_map.values(), key=Extension.sort_key
        )
项目:aws-encryption-sdk-cli    作者:awslabs    | 项目源码 | 文件源码
def _discover_entry_points():
    # type: () -> None
    """Discover all registered entry points."""
    _LOGGER.debug('Discovering master key provider plugins')

    for entry_point in pkg_resources.iter_entry_points(MASTER_KEY_PROVIDERS_ENTRY_POINT):
        _LOGGER.info('Collecting plugin "%s" registered by "%s"', entry_point.name, entry_point.dist)
        _LOGGER.debug('Plugin details: %s', dict(
            name=entry_point.name,
            module_name=entry_point.module_name,
            attrs=entry_point.attrs,
            extras=entry_point.extras,
            dist=entry_point.dist
        ))

        if PLUGIN_NAMESPACE_DIVIDER in entry_point.name:
            _LOGGER.warning(
                'Invalid substring "%s" in discovered entry point "%s". It will not be usable.',
                PLUGIN_NAMESPACE_DIVIDER,
                entry_point.name
            )
            continue

        _ENTRY_POINTS[entry_point.name][entry_point.dist.project_name] = entry_point
项目:health-mosconi    作者:GNUHealth-Mosconi    | 项目源码 | 文件源码
def get(prop):
    db_type = name()
    modname = 'trytond.backend.%s' % db_type
    if modname not in sys.modules:
        try:
            __import__(modname)
        except ImportError:
            if not pkg_resources:
                raise
            ep, = pkg_resources.iter_entry_points('trytond.backend', db_type)
            mod_path = os.path.join(ep.dist.location,
                *ep.module_name.split('.')[:-1])
            fp, pathname, description = imp.find_module(db_type, [mod_path])
            imp.load_module(modname, fp, pathname, description)
    module = sys.modules[modname]
    return getattr(module, prop)
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
def finalize_options(self):
        _Distribution.finalize_options(self)
        if self.features:
            self._set_global_opts_from_features()

        for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
            value = getattr(self, ep.name, None)
            if value is not None:
                ep.require(installer=self.fetch_build_egg)
                ep.load()(self, ep.name, value)
        if getattr(self, 'convert_2to3_doctests', None):
            # XXX may convert to set here when we can rely on set being builtin
            self.convert_2to3_doctests = [
                os.path.abspath(p)
                for p in self.convert_2to3_doctests
            ]
        else:
            self.convert_2to3_doctests = []
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
def finalize_options(self):
        _Distribution.finalize_options(self)
        if self.features:
            self._set_global_opts_from_features()

        for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
            value = getattr(self, ep.name, None)
            if value is not None:
                ep.require(installer=self.fetch_build_egg)
                ep.load()(self, ep.name, value)
        if getattr(self, 'convert_2to3_doctests', None):
            # XXX may convert to set here when we can rely on set being builtin
            self.convert_2to3_doctests = [
                os.path.abspath(p)
                for p in self.convert_2to3_doctests
            ]
        else:
            self.convert_2to3_doctests = []
项目:QXSConsolas    作者:qxsch    | 项目源码 | 文件源码
def load(self, name):
        if name in self.impls:
            return self.impls[name]()

        if self.auto_fn:
            loader = self.auto_fn(name)
            if loader:
                self.impls[name] = loader
                return loader()

        try:
            import pkg_resources
        except ImportError:
            pass
        else:
            for impl in pkg_resources.iter_entry_points(
                    self.group, name):
                self.impls[name] = impl.load
                return impl.load()

        raise exc.NoSuchModuleError(
            "Can't load plugin: %s:%s" %
            (self.group, name))
项目:scarlett_os    作者:bossjones    | 项目源码 | 文件源码
def format_dependency_list(adapters=None):
    if adapters is None:
        dist_names = set([
            ep.dist.project_name for ep in
            pkg_resources.iter_entry_points('scarlett.automations')
            if ep.dist.project_name != PROJECT_NAME])
        dist_infos = [
            functools.partial(pkg_info, dist_name)
            for dist_name in dist_names]

        adapters = [
            executable_info,
            platform_info,
            python_info,
            functools.partial(pkg_info, PROJECT_NAME, True)
        ] + dist_infos + [
            gstreamer_info,
        ]

    return '\n'.join([_format_dependency(a()) for a in adapters])
项目:iotronic-lightning-rod    作者:openstack    | 项目源码 | 文件源码
def plug_and_play(self, new_module, new_class):
        LOG.info("LR modules loaded:\n\t" + new_module)

        # Updating entry_points
        with open(entry_points_name, 'a') as entry_points:
            entry_points.write(
                new_module +
                '= iotronic_lightningrod.modules.' + new_module + ':'
                + new_class
            )

            # Reload entry_points
            refresh_stevedore('s4t.modules')
            LOG.info("New entry_points loaded!")

        # Reading updated entry_points
        named_objects = {}
        for ep in pkg_resources.iter_entry_points(group='s4t.modules'):
            named_objects.update({ep.name: ep.load()})

        yield named_objects

        SESSION.disconnect()

        returnValue(str(named_objects))
项目:TCP-IP    作者:JackZ0    | 项目源码 | 文件源码
def find_all(cls):
        """Find plugins using setuptools entry points."""
        plugins = {}
        entry_points = itertools.chain(
            pkg_resources.iter_entry_points(
                constants.SETUPTOOLS_PLUGINS_ENTRY_POINT),
            pkg_resources.iter_entry_points(
                constants.OLD_SETUPTOOLS_PLUGINS_ENTRY_POINT),)
        for entry_point in entry_points:
            plugin_ep = PluginEntryPoint(entry_point)
            assert plugin_ep.name not in plugins, (
                "PREFIX_FREE_DISTRIBUTIONS messed up")
            # providedBy | pylint: disable=no-member
            if interfaces.IPluginFactory.providedBy(plugin_ep.plugin_cls):
                plugins[plugin_ep.name] = plugin_ep
            else:  # pragma: no cover
                logger.warning(
                    "%r does not provide IPluginFactory, skipping", plugin_ep)
        return cls(plugins)
项目:aws-cfn-plex    作者:lordmuffin    | 项目源码 | 文件源码
def _available_backends():
    global _available_backends_list

    if _available_backends_list is None:
        entry_point_backends = [
            # DeprecatedIn16
            # setuptools 11.3 deprecated support for the require parameter to
            # load(), and introduced the new resolve() method instead.
            # We previously removed this fallback, but users are having issues
            # where Python loads an older setuptools due to various syspath
            # weirdness.
            ep.resolve() if hasattr(ep, "resolve") else ep.load(require=False)
            for ep in pkg_resources.iter_entry_points(
                "cryptography.backends"
            )
        ]

        _available_backends_list = _backend_import_fallback(
            entry_point_backends
        )

    return _available_backends_list
项目:aws-cfn-plex    作者:lordmuffin    | 项目源码 | 文件源码
def _backend_import_fallback(backends):
    # If backends already exist just return them. This branch is here
    # to get full line coverage from our tests.
    if backends:
        return backends

    # if iter_entry_points fails to find any backends then manually try to
    # import our current backends as a workaround for issues with application
    # bundlers like pyinstaller, cx_freeze, etc

    # OpenSSL is guaranteed to be present until we unbundle the backends.
    from cryptography.hazmat.backends.openssl.backend import backend as be_ossl
    backends = [be_ossl]
    try:
        from cryptography.hazmat.backends.commoncrypto.backend import (
            backend as be_cc
        )
    except ImportError:
        pass
    else:
        backends.append(be_cc)

    return backends
项目:RPoint    作者:george17-meet    | 项目源码 | 文件源码
def finalize_options(self):
        _Distribution.finalize_options(self)
        if self.features:
            self._set_global_opts_from_features()

        for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
            value = getattr(self, ep.name, None)
            if value is not None:
                ep.require(installer=self.fetch_build_egg)
                ep.load()(self, ep.name, value)
        if getattr(self, 'convert_2to3_doctests', None):
            # XXX may convert to set here when we can rely on set being builtin
            self.convert_2to3_doctests = [
                os.path.abspath(p)
                for p in self.convert_2to3_doctests
            ]
        else:
            self.convert_2to3_doctests = []
项目:click-man    作者:click-contrib    | 项目源码 | 文件源码
def cli(target, name):
    """
    Generate man pages for the scripts defined in the ``console_acripts`` entry point.

    The cli application is gathered from entry points of installed packages.

    The generated man pages are written to files in the directory given
    by ``--target``.
    """
    console_scripts = [ep for ep in iter_entry_points('console_scripts', name=name)]
    if len(console_scripts) < 1:
        raise click.ClickException('"{0}" is not an installed console script.'.format(name))
    # Only generate man pages for first console script
    entry_point = console_scripts[0]

    # create target directory if it does not exist yet
    try:
        os.makedirs(target)
    except OSError:
        pass

    click.echo('Load entry point {0}'.format(name))
    cli = entry_point.resolve()
    click.echo('Generate man pages for {0} in {1}'.format(name, target))
    write_man_pages(name, cli, version=entry_point.dist.version, target_dir=target)
项目:AshsSDK    作者:thehappydinoa    | 项目源码 | 文件源码
def finalize_options(self):
        _Distribution.finalize_options(self)
        if self.features:
            self._set_global_opts_from_features()

        for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
            value = getattr(self, ep.name, None)
            if value is not None:
                ep.require(installer=self.fetch_build_egg)
                ep.load()(self, ep.name, value)
        if getattr(self, 'convert_2to3_doctests', None):
            # XXX may convert to set here when we can rely on set being builtin
            self.convert_2to3_doctests = [
                os.path.abspath(p)
                for p in self.convert_2to3_doctests
            ]
        else:
            self.convert_2to3_doctests = []
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def _available_backends():
    global _available_backends_list

    if _available_backends_list is None:
        _available_backends_list = [
            # setuptools 11.3 deprecated support for the require parameter to
            # load(), and introduced the new resolve() method instead.
            # This can be removed if/when we can assume setuptools>=11.3. At
            # some point we may wish to add a warning, to push people along,
            # but at present this would result in too many warnings.
            ep.resolve() if hasattr(ep, "resolve") else ep.load(require=False)
            for ep in pkg_resources.iter_entry_points(
                "cryptography.backends"
            )
        ]

    return _available_backends_list
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def load(self, name):
        if name in self.impls:
            return self.impls[name]()

        if self.auto_fn:
            loader = self.auto_fn(name)
            if loader:
                self.impls[name] = loader
                return loader()

        try:
            import pkg_resources
        except ImportError:
            pass
        else:
            for impl in pkg_resources.iter_entry_points(
                    self.group, name):
                self.impls[name] = impl.load
                return impl.load()

        raise exc.NoSuchModuleError(
            "Can't load plugin: %s:%s" %
            (self.group, name))
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def __init__(self, attrs=None):
        have_package_data = hasattr(self, "package_data")
        if not have_package_data:
            self.package_data = {}
        _attrs_dict = attrs or {}
        if 'features' in _attrs_dict or 'require_features' in _attrs_dict:
            Feature.warn_deprecated()
        self.require_features = []
        self.features = {}
        self.dist_files = []
        self.src_root = attrs and attrs.pop("src_root", None)
        self.patch_missing_pkg_info(attrs)
        # Make sure we have any eggs needed to interpret 'attrs'
        if attrs is not None:
            self.dependency_links = attrs.pop('dependency_links', [])
            assert_string_list(self,'dependency_links',self.dependency_links)
        if attrs and 'setup_requires' in attrs:
            self.fetch_build_eggs(attrs.pop('setup_requires'))
        for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
            if not hasattr(self,ep.name):
                setattr(self,ep.name,None)
        _Distribution.__init__(self,attrs)
        if isinstance(self.metadata.version, numeric_types):
            # Some people apparently take "version number" too literally :)
            self.metadata.version = str(self.metadata.version)
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def _available_backends():
    global _available_backends_list

    if _available_backends_list is None:
        _available_backends_list = [
            # setuptools 11.3 deprecated support for the require parameter to
            # load(), and introduced the new resolve() method instead.
            # This can be removed if/when we can assume setuptools>=11.3. At
            # some point we may wish to add a warning, to push people along,
            # but at present this would result in too many warnings.
            ep.resolve() if hasattr(ep, "resolve") else ep.load(require=False)
            for ep in pkg_resources.iter_entry_points(
                "cryptography.backends"
            )
        ]

    return _available_backends_list
项目:dati-ckan-docker    作者:italia    | 项目源码 | 文件源码
def _get_service(plugin_name):
    '''
    Return a service (ie an instance of a plugin class).

    :param plugin_name: the name of a plugin entry point
    :type plugin_name: string

    :return: the service object
    '''

    if isinstance(plugin_name, basestring):
        for group in GROUPS:
            iterator = iter_entry_points(
                group=group,
                name=plugin_name
            )
            plugin = next(iterator, None)
            if plugin:
                return plugin.load()(name=plugin_name)
        raise PluginNotFoundException(plugin_name)
    else:
        raise TypeError('Expected a plugin name', plugin_name)
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def load(self, name):
        if name in self.impls:
            return self.impls[name]()

        if self.auto_fn:
            loader = self.auto_fn(name)
            if loader:
                self.impls[name] = loader
                return loader()

        try:
            import pkg_resources
        except ImportError:
            pass
        else:
            for impl in pkg_resources.iter_entry_points(
                    self.group, name):
                self.impls[name] = impl.load
                return impl.load()

        raise exc.NoSuchModuleError(
            "Can't load plugin: %s:%s" %
            (self.group, name))
项目:pnet    作者:vodik    | 项目源码 | 文件源码
def get_parsers():
    entry_points = pkg_resources.iter_entry_points('pnet.packet')
    return {entry_point.name: entry_point.load()
            for entry_point in entry_points}
项目:python-    作者:secondtonone1    | 项目源码 | 文件源码
def get_command_class(self, command):
        """Pluggable version of get_command_class()"""
        if command in self.cmdclass:
            return self.cmdclass[command]

        eps = pkg_resources.iter_entry_points('distutils.commands', command)
        for ep in eps:
            ep.require(installer=self.fetch_build_egg)
            self.cmdclass[command] = cmdclass = ep.load()
            return cmdclass
        else:
            return _Distribution.get_command_class(self, command)
项目:python-    作者:secondtonone1    | 项目源码 | 文件源码
def print_commands(self):
        for ep in pkg_resources.iter_entry_points('distutils.commands'):
            if ep.name not in self.cmdclass:
                # don't require extras as the commands won't be invoked
                cmdclass = ep.resolve()
                self.cmdclass[ep.name] = cmdclass
        return _Distribution.print_commands(self)
项目:python-    作者:secondtonone1    | 项目源码 | 文件源码
def get_command_list(self):
        for ep in pkg_resources.iter_entry_points('distutils.commands'):
            if ep.name not in self.cmdclass:
                # don't require extras as the commands won't be invoked
                cmdclass = ep.resolve()
                self.cmdclass[ep.name] = cmdclass
        return _Distribution.get_command_list(self)
项目:python-    作者:secondtonone1    | 项目源码 | 文件源码
def has_sphinx(self):
        if self.upload_dir is None:
            for ep in iter_entry_points('distutils.commands', 'build_sphinx'):
                return True
项目:my-first-blog    作者:AnkurBegining    | 项目源码 | 文件源码
def get_command_class(self, command):
        """Pluggable version of get_command_class()"""
        if command in self.cmdclass:
            return self.cmdclass[command]

        eps = pkg_resources.iter_entry_points('distutils.commands', command)
        for ep in eps:
            ep.require(installer=self.fetch_build_egg)
            self.cmdclass[command] = cmdclass = ep.load()
            return cmdclass
        else:
            return _Distribution.get_command_class(self, command)
项目:my-first-blog    作者:AnkurBegining    | 项目源码 | 文件源码
def print_commands(self):
        for ep in pkg_resources.iter_entry_points('distutils.commands'):
            if ep.name not in self.cmdclass:
                # don't require extras as the commands won't be invoked
                cmdclass = ep.resolve()
                self.cmdclass[ep.name] = cmdclass
        return _Distribution.print_commands(self)
项目:my-first-blog    作者:AnkurBegining    | 项目源码 | 文件源码
def get_command_list(self):
        for ep in pkg_resources.iter_entry_points('distutils.commands'):
            if ep.name not in self.cmdclass:
                # don't require extras as the commands won't be invoked
                cmdclass = ep.resolve()
                self.cmdclass[ep.name] = cmdclass
        return _Distribution.get_command_list(self)
项目:my-first-blog    作者:AnkurBegining    | 项目源码 | 文件源码
def has_sphinx(self):
        if self.upload_dir is None:
            for ep in iter_entry_points('distutils.commands', 'build_sphinx'):
                return True
项目:concierge    作者:9seconds    | 项目源码 | 文件源码
def all_templaters():
    templaters = {"dummy": Templater}

    for plugin in pkg_resources.iter_entry_points(group=TEMPLATER_NAMESPACE):
        templaters[plugin.name] = plugin.load()

    return templaters
项目:deployfish    作者:caltechads    | 项目源码 | 文件源码
def load_local_click_modules():

    for point in pkg_resources.iter_entry_points(group='deployfish.command.plugins'):
        importlib.import_module(point.module_name)
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def load(self, name):
        if name in self.impls:
            return self.impls[name]()
        else:
            import pkg_resources
            for impl in pkg_resources.iter_entry_points(
                    self.group,
                    name):
                self.impls[name] = impl.load
                return impl.load()
            else:
                from mako import exceptions
                raise exceptions.RuntimeException(
                    "Can't load plugin %s %s" %
                    (self.group, name))
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def finalize_options(self):
        _Distribution.finalize_options(self)
        if self.features:
            self._set_global_opts_from_features()

        for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
            value = getattr(self,ep.name,None)
            if value is not None:
                ep.require(installer=self.fetch_build_egg)
                ep.load()(self, ep.name, value)
        if getattr(self, 'convert_2to3_doctests', None):
            # XXX may convert to set here when we can rely on set being builtin
            self.convert_2to3_doctests = [os.path.abspath(p) for p in self.convert_2to3_doctests]
        else:
            self.convert_2to3_doctests = []
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def get_command_class(self, command):
        """Pluggable version of get_command_class()"""
        if command in self.cmdclass:
            return self.cmdclass[command]

        for ep in pkg_resources.iter_entry_points('distutils.commands',command):
            ep.require(installer=self.fetch_build_egg)
            self.cmdclass[command] = cmdclass = ep.load()
            return cmdclass
        else:
            return _Distribution.get_command_class(self, command)
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def walk_revctrl(dirname=''):
    """Find all files under revision control"""
    for ep in pkg_resources.iter_entry_points('setuptools.file_finders'):
        for item in ep.load()(dirname):
            yield item


#TODO will need test case
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def has_sphinx(self):
        if self.upload_dir is None:
            for ep in iter_entry_points('distutils.commands', 'build_sphinx'):
                return True
项目:bob.bio.base    作者:bioidiap    | 项目源码 | 文件源码
def _get_entry_points(keyword, strip = [], package_prefix='bob.bio.'):
  """Returns the list of entry points for registered resources with the given keyword."""
  return  [entry_point for entry_point in pkg_resources.iter_entry_points(package_prefix + keyword) if not entry_point.name.startswith(tuple(strip))]
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
def _load_plugin_commands(self):
        if self._loaded_plugin_commands:
            return
        try:
            import pkg_resources
        except ImportError:
            self._loaded_plugin_commands = True
            return

        for ep in pkg_resources.iter_entry_points('flask.commands'):
            self.add_command(ep.load(), ep.name)
        self._loaded_plugin_commands = True
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
def finalize_options(self):
        _Distribution.finalize_options(self)
        if self.features:
            self._set_global_opts_from_features()

        for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
            value = getattr(self, ep.name, None)
            if value is not None:
                ep.require(installer=self.fetch_build_egg)
                ep.load()(self, ep.name, value)
        if getattr(self, 'convert_2to3_doctests', None):
            # XXX may convert to set here when we can rely on set being builtin
            self.convert_2to3_doctests = [os.path.abspath(p) for p in self.convert_2to3_doctests]
        else:
            self.convert_2to3_doctests = []
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
def get_command_class(self, command):
        """Pluggable version of get_command_class()"""
        if command in self.cmdclass:
            return self.cmdclass[command]

        for ep in pkg_resources.iter_entry_points('distutils.commands', command):
            ep.require(installer=self.fetch_build_egg)
            self.cmdclass[command] = cmdclass = ep.load()
            return cmdclass
        else:
            return _Distribution.get_command_class(self, command)
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
def print_commands(self):
        for ep in pkg_resources.iter_entry_points('distutils.commands'):
            if ep.name not in self.cmdclass:
                # don't require extras as the commands won't be invoked
                cmdclass = ep.resolve()
                self.cmdclass[ep.name] = cmdclass
        return _Distribution.print_commands(self)
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
def walk_revctrl(dirname=''):
    """Find all files under revision control"""
    for ep in pkg_resources.iter_entry_points('setuptools.file_finders'):
        for item in ep.load()(dirname):
            yield item
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
def has_sphinx(self):
        if self.upload_dir is None:
            for ep in iter_entry_points('distutils.commands', 'build_sphinx'):
                return True
项目:noc-orchestrator    作者:DirceuSilvaLabs    | 项目源码 | 文件源码
def finalize_options(self):
        _Distribution.finalize_options(self)
        if self.features:
            self._set_global_opts_from_features()

        for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
            value = getattr(self,ep.name,None)
            if value is not None:
                ep.require(installer=self.fetch_build_egg)
                ep.load()(self, ep.name, value)
        if getattr(self, 'convert_2to3_doctests', None):
            # XXX may convert to set here when we can rely on set being builtin
            self.convert_2to3_doctests = [os.path.abspath(p) for p in self.convert_2to3_doctests]
        else:
            self.convert_2to3_doctests = []