本文整理汇总了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
示例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))
示例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
示例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 == ''
示例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 ""
示例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 []
示例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