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


Python pkg_resources.get_entry_map方法代码示例

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


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

示例1: get_themes

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_entry_map [as 别名]
def get_themes():
    """ Return a dict of all installed themes as (name, entry point) pairs. """

    themes = {}
    builtins = pkg_resources.get_entry_map(dist='mkdocs', group='mkdocs.themes')

    for theme in pkg_resources.iter_entry_points(group='mkdocs.themes'):

        if theme.name in builtins and theme.dist.key != 'mkdocs':
            raise exceptions.ConfigurationError(
                "The theme {} is a builtin theme but {} provides a theme "
                "with the same name".format(theme.name, theme.dist.key))

        elif theme.name in themes:
            multiple_packages = [themes[theme.name].dist.key, theme.dist.key]
            log.warning("The theme %s is provided by the Python packages "
                        "'%s'. The one in %s will be used.",
                        theme.name, ','.join(multiple_packages), theme.dist.key)

        themes[theme.name] = theme

    return themes 
开发者ID:mkdocs,项目名称:mkdocs,代码行数:24,代码来源:__init__.py

示例2: dump_cache

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_entry_map [as 别名]
def dump_cache(cache_file, distributions):
    """Write entry points in the distributions to the cache."""
    import pkg_resources

    cache = {}
    for dist in distributions:
        for section, entries in pkg_resources.get_entry_map(dist).items():
            if section not in cache:
                cache[section] = {}

            for name, entry in entries.items():
                cache[section][name] = {
                    'module': entry.module_name,
                    'attrs': list(entry.attrs)
                }

    with io.open(cache_file, 'w') as f:
        f.write(json.dumps(cache)) 
开发者ID:Morgan-Stanley,项目名称:treadmill,代码行数:20,代码来源:plugin_manager.py

示例3: cli_commands

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_entry_map [as 别名]
def cli_commands():
    commands = set(pkg_resources.get_entry_map(
        'brozzler')['console_scripts'].keys())
    commands.remove('brozzler-wayback')
    try:
        import gunicorn
    except ImportError:
        commands.remove('brozzler-dashboard')
    try:
        import pywb
    except ImportError:
        commands.remove('brozzler-easy')
    return commands 
开发者ID:internetarchive,项目名称:brozzler,代码行数:15,代码来源:test_cli.py

示例4: test_call_entrypoint

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_entry_map [as 别名]
def test_call_entrypoint(capsys, cmd):
    entrypoint = pkg_resources.get_entry_map(
            'brozzler')['console_scripts'][cmd]
    callable = entrypoint.resolve()
    with pytest.raises(SystemExit):
        callable(['/whatever/bin/%s' % cmd, '--version'])
    out, err = capsys.readouterr()
    assert out == 'brozzler %s - %s\n' % (brozzler.__version__, cmd)
    assert err == '' 
开发者ID:internetarchive,项目名称:brozzler,代码行数:11,代码来源:test_cli.py

示例5: get_config_data

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_entry_map [as 别名]
def get_config_data(package):
    """Read the default configuration-data section from the given package"""
    data = None
    try:
        dist = pkg_resources.get_distribution(package)
        entries = pkg_resources.get_entry_map(dist, "resilient.circuits.configsection")
        if entries:
            entry = next(iter(entries))
            func = entries[entry].load()
            data = func()
    except pkg_resources.DistributionNotFound:
        pass
    return data or "" 
开发者ID:ibmresilient,项目名称:resilient-python-api,代码行数:15,代码来源:resilient_config.py

示例6: get_customization_definitions

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_entry_map [as 别名]
def get_customization_definitions(package):
    """Read the default configuration-data section from the given package"""
    data = None
    try:
        dist = pkg_resources.get_distribution(package)
        entries = pkg_resources.get_entry_map(dist, "resilient.circuits.customize")
        if entries:
            for entry in iter(entries):
                func = entries[entry].load()
                data = func(client=None)
    except pkg_resources.DistributionNotFound:
        pass
    return data or [] 
开发者ID:ibmresilient,项目名称:resilient-python-api,代码行数:15,代码来源:resilient_customize.py

示例7: get_installed_tools

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import get_entry_map [as 别名]
def get_installed_tools():
    """Get list of installed scripts via ``pkg-resources``.

    See http://peak.telecommunity.com/DevCenter/PkgResources#convenience-api

    TODO: not sure if this will be useful ... maybe to check if the list
    of installed packages matches the available scripts somehow?
    """
    from pkg_resources import get_entry_map

    console_tools = get_entry_map("ctapipe")["console_scripts"]
    return console_tools 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:14,代码来源:utils.py


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