當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。