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


Python pkg_resources.iter_entry_points方法代码示例

本文整理汇总了Python中pkg_resources.iter_entry_points方法的典型用法代码示例。如果您正苦于以下问题:Python pkg_resources.iter_entry_points方法的具体用法?Python pkg_resources.iter_entry_points怎么用?Python pkg_resources.iter_entry_points使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pkg_resources的用法示例。


在下文中一共展示了pkg_resources.iter_entry_points方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _load_plugin_class

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import iter_entry_points [as 别名]
def _load_plugin_class(menu, name):
    """Load Custodia plugin

    Entry points are preferred over dotted import path.
    """
    group = 'custodia.{}'.format(menu)
    eps = list(pkg_resources.iter_entry_points(group, name))
    if len(eps) > 1:
        raise ValueError(
            "Multiple entry points for {} {}: {}".format(menu, name, eps))
    elif len(eps) == 1:
        # backwards compatibility with old setuptools
        ep = eps[0]
        if hasattr(ep, 'resolve'):
            return ep.resolve()
        else:
            return ep.load(require=False)
    elif '.' in name:
        # fall back to old style dotted name
        module, classname = name.rsplit('.', 1)
        m = importlib.import_module(module)
        return getattr(m, classname)
    else:
        raise ValueError("{}: {} not found".format(menu, name)) 
开发者ID:latchset,项目名称:custodia,代码行数:26,代码来源:__init__.py

示例2: handle_plugins

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import iter_entry_points [as 别名]
def handle_plugins(args):
    result = []
    errmsg = "**ERR** {0} ({1.__class__.__name__}: {1})"
    for plugin in PLUGINS:
        result.append('[{}]'.format(plugin))
        eps = pkg_resources.iter_entry_points(plugin)
        eps = sorted(eps, key=operator.attrgetter('name'))
        for ep in eps:
            try:
                if hasattr(ep, 'resolve'):
                    ep.resolve()
                else:
                    ep.load(require=False)
            except Exception as e:  # pylint: disable=broad-except
                if args.verbose:
                    result.append(errmsg.format(ep, e))
            else:
                result.append(str(ep))
        result.append('')
    return result[:-1] 
开发者ID:latchset,项目名称:custodia,代码行数:22,代码来源:__init__.py

示例3: register_entrypoints

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import iter_entry_points [as 别名]
def register_entrypoints(self):
        """Look through the `setup_tools` `entry_points` and load all of
           the formats.
        """
        for spec in iter_entry_points(self.entry_point_group):
            format_properties = {"name": spec.name}
            try:
                format_properties.update(spec.load())
            except (DistributionNotFound, ImportError) as err:
                self.log.info(
                    "ipymd format {} could not be loaded: {}".format(
                        spec.name, err))
                continue

            self.register(**format_properties)

        return self 
开发者ID:rossant,项目名称:ipymd,代码行数:19,代码来源:format_manager.py

示例4: load

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import iter_entry_points [as 别名]
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)) 
开发者ID:jpush,项目名称:jbox,代码行数:25,代码来源:langhelpers.py

示例5: _load_jobs

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import iter_entry_points [as 别名]
def _load_jobs():
    path = os.getcwd()
    sys.path.append(path)

    # load builtin
    import_string('sea.cmds')

    # load lib jobs
    for ep in pkg_resources.iter_entry_points('sea.jobs'):
        try:
            ep.load()
        except Exception as e:
            logger = logging.getLogger('sea.cmd')
            logger.debug(
                'error has occurred during pkg loading: {}'.format(e))

    # load app jobs
    appjobs = os.path.join(path, 'jobs')
    if os.path.exists(appjobs):
        import_string('jobs')
        for m in os.listdir(appjobs):
            if m != '__init__.py' and m.endswith('.py'):
                import_string('jobs.{}'.format(m[:-3])) 
开发者ID:shanbay,项目名称:sea,代码行数:25,代码来源:cli.py

示例6: __init__

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import iter_entry_points [as 别名]
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) 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:27,代码来源:dist.py

示例7: finalize_options

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import iter_entry_points [as 别名]
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 = [] 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:20,代码来源:dist.py

示例8: _get_service

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import iter_entry_points [as 别名]
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) 
开发者ID:italia,项目名称:daf-recipes,代码行数:24,代码来源:core.py

示例9: get

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import iter_entry_points [as 别名]
def get(self, group, name):
        self.__plugins.setdefault(group, {})
        if name not in self.__plugins[group]:
            ep = next(iter_entry_points(group, name=name), None)
            if ep:
                self.__plugins[group][name] = ep.resolve()
        return self.__plugins[group].get(name, None) 
开发者ID:mme,项目名称:vergeml,代码行数:9,代码来源:plugins.py

示例10: keys

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import iter_entry_points [as 别名]
def keys(self, group):
        self.__plugins.setdefault(group, {})
        entry_points = list(iter_entry_points(group, name=None))
        ep_keys = set(map(lambda ep: ep.name, entry_points))
        return set(self.__plugins[group].keys()).union(ep_keys) 
开发者ID:mme,项目名称:vergeml,代码行数:7,代码来源:plugins.py

示例11: discover_post_import_hooks

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import iter_entry_points [as 别名]
def discover_post_import_hooks(group):
    try:
        import pkg_resources
    except ImportError:
        return

    for entrypoint in pkg_resources.iter_entry_points(group=group):
        callback = _create_import_hook_from_entrypoint(entrypoint)
        register_post_import_hook(callback, entrypoint.name)

# Indicate that a module has been loaded. Any post import hooks which
# were registered against the target module will be invoked. If an
# exception is raised in any of the post import hooks, that will cause
# the import of the target module to fail. 
开发者ID:danielecook,项目名称:gist-alfred,代码行数:16,代码来源:importer.py

示例12: load_entry_points

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import iter_entry_points [as 别名]
def load_entry_points(
    _entry_points=_ENTRY_POINTS,
    _iter_entry_points=pkg_resources.iter_entry_points,
):
    for name in _entry_points:
        plugins = {
            entry_point.name: entry_point.load()
            for entry_point in _iter_entry_points(name)
        }
        func = _entry_points[name]
        for value in plugins.values():
            func(value) 
开发者ID:prkumar,项目名称:uplink,代码行数:14,代码来源:_extras.py

示例13: get_entry_points

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import iter_entry_points [as 别名]
def get_entry_points(self, group):
        eps = []
        for e in pkg_resources.iter_entry_points(group):
            if e.dist.project_name != self.project_name:
                # only interested in our own entry points
                continue
            if not HAS_IPA and e.module_name.startswith('custodia.ipa'):
                # skip IPA plugins when ipaclient isn't installed
                continue
            eps.append(e)
        return eps 
开发者ID:latchset,项目名称:custodia,代码行数:13,代码来源:test_plugins.py

示例14: _get_entry_points

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import iter_entry_points [as 别名]
def _get_entry_points():
    import importlib

    class BasebandFormat:
        def __init__(self, name, value):
            self.name = name
            self.value = value

        def load(self):
            return importlib.import_module(self.value)

        def __repr__(self):
            return f"BasebandFormat('{self.name}', '{self.value}')"

    entries = {key: BasebandFormat(key, 'baseband.'+key) for key
               in ('dada', 'guppi', 'mark4', 'mark5b', 'vdif', 'gsb')}
    try:
        from entrypoints import get_group_all
    except ImportError:
        try:
            from pkg_resources import iter_entry_points as get_group_all
        except ImportError:
            return entries

    for entry_point in get_group_all('baseband.io'):
        entries.setdefault(entry_point.name, entry_point)

    return entries 
开发者ID:mhvk,项目名称:baseband,代码行数:30,代码来源:__init__.py

示例15: load

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import iter_entry_points [as 别名]
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)
                ) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:17,代码来源:util.py


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