本文整理匯總了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