本文整理汇总了Python中pluggy.PluginManager方法的典型用法代码示例。如果您正苦于以下问题:Python pluggy.PluginManager方法的具体用法?Python pluggy.PluginManager怎么用?Python pluggy.PluginManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pluggy
的用法示例。
在下文中一共展示了pluggy.PluginManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_plugin_manager
# 需要导入模块: import pluggy [as 别名]
# 或者: from pluggy import PluginManager [as 别名]
def get_plugin_manager(plugins=()):
# initialize plugin manager
import tox.venv
pm = pluggy.PluginManager("tox")
pm.add_hookspecs(tox.hookspecs)
pm.register(tox.config)
pm.register(tox.interpreters)
pm.register(tox.venv)
pm.register(tox.session)
from tox import package
pm.register(package)
pm.load_setuptools_entrypoints("tox")
for plugin in plugins:
pm.register(plugin)
pm.check_pending()
return pm
示例2: test_version_with_normal_plugin
# 需要导入模块: import pluggy [as 别名]
# 或者: from pluggy import PluginManager [as 别名]
def test_version_with_normal_plugin(self, monkeypatch):
def fake_normal_plugin_distinfo():
class MockModule:
__file__ = "some-file"
class MockEggInfo:
project_name = "some-project"
version = "1.0"
return [(MockModule, MockEggInfo)]
pm = PluginManager("fakeproject")
monkeypatch.setattr(pm, "list_plugin_distinfo", fake_normal_plugin_distinfo)
version_info = get_version_info(pm)
assert "registered plugins:" in version_info
assert "some-file" in version_info
assert "some-project" in version_info
assert "1.0" in version_info
示例3: test_version_with_fileless_module
# 需要导入模块: import pluggy [as 别名]
# 或者: from pluggy import PluginManager [as 别名]
def test_version_with_fileless_module(self, monkeypatch):
def fake_no_file_plugin_distinfo():
class MockModule:
def __repr__(self):
return "some-repr"
class MockEggInfo:
project_name = "some-project"
version = "1.0"
return [(MockModule(), MockEggInfo)]
pm = PluginManager("fakeproject")
monkeypatch.setattr(pm, "list_plugin_distinfo", fake_no_file_plugin_distinfo)
version_info = get_version_info(pm)
assert "registered plugins:" in version_info
assert "some-project" in version_info
assert "some-repr" in version_info
assert "1.0" in version_info
示例4: register_plugin_module
# 需要导入模块: import pluggy [as 别名]
# 或者: from pluggy import PluginManager [as 别名]
def register_plugin_module(module_path, required=True):
"""Register hooks in a module with the PluginManager by Python path.
Args:
module_path (str): A Python dotted import path.
required (bool, optional): If False, ignore ImportError.
Default: True.
Returns:
The imported module.
Raises:
ImportError: If `required` is True and the module cannot be imported.
"""
try:
module = importlib.import_module(module_path)
except ImportError:
if required:
raise
else:
manager.register(module)
return module
示例5: drivers
# 需要导入模块: import pluggy [as 别名]
# 或者: from pluggy import PluginManager [as 别名]
def drivers(config=None) -> UserListMap:
"""Return list of active drivers."""
plugins = UserListMap()
pm = pluggy.PluginManager("molecule.driver")
try:
pm.load_setuptools_entrypoints("molecule.driver")
except Exception:
# These are not fatal because a broken driver should not make the entire
# tool unusable.
LOG.error("Failed to load driver entry point %s", traceback.format_exc())
for p in pm.get_plugins():
try:
plugins.append(p(config))
except Exception as e:
LOG.error("Failed to load %s driver: %s", pm.get_name(p), str(e))
plugins.sort()
return plugins
示例6: verifiers
# 需要导入模块: import pluggy [as 别名]
# 或者: from pluggy import PluginManager [as 别名]
def verifiers(config=None) -> UserListMap:
"""Return list of active verifiers."""
plugins = UserListMap()
pm = pluggy.PluginManager("molecule.verifier")
try:
pm.load_setuptools_entrypoints("molecule.verifier")
except Exception:
# These are not fatal because a broken verifier should not make the entire
# tool unusable.
LOG.error("Failed to load verifier entry point %s", traceback.format_exc())
for p in pm.get_plugins():
try:
plugins.append(p(config))
except Exception as e:
LOG.error("Failed to load %s driver: %s", pm.get_name(p), str(e))
plugins.sort()
return plugins
示例7: initialize_plugin_manager
# 需要导入模块: import pluggy [as 别名]
# 或者: from pluggy import PluginManager [as 别名]
def initialize_plugin_manager():
"""
Initializes and loads all default and setup implementations for registered plugins
@return: initialized plugin manager
"""
pm = pluggy.PluginManager("kube-hunter")
pm.add_hookspecs(hookspecs)
pm.load_setuptools_entrypoints("kube_hunter")
# default registration of builtin implemented plugins
from kube_hunter.conf import parser
pm.register(parser)
return pm
示例8: test_version_no_plugins
# 需要导入模块: import pluggy [as 别名]
# 或者: from pluggy import PluginManager [as 别名]
def test_version_no_plugins(self):
pm = PluginManager("fakeprject")
version_info = get_version_info(pm)
assert "imported from" in version_info
assert "registered plugins:" not in version_info
示例9: get_plugin_manager
# 需要导入模块: import pluggy [as 别名]
# 或者: from pluggy import PluginManager [as 别名]
def get_plugin_manager():
pm = pluggy.PluginManager("zvt")
pm.add_hookspecs(specs)
pm.load_setuptools_entrypoints("zvt")
pm.register(impls)
return pm
示例10: setup_plugins
# 需要导入模块: import pluggy [as 别名]
# 或者: from pluggy import PluginManager [as 别名]
def setup_plugins(plugins=None):
"""
Install plugins & setup a pluginmanager
"""
# Install plugins
if plugins:
conda.ensure_pip_packages(HUB_ENV_PREFIX, plugins)
# Set up plugin infrastructure
pm = pluggy.PluginManager('tljh')
pm.add_hookspecs(hooks)
pm.load_setuptools_entrypoints('tljh')
return pm
示例11: get_plugin_manager
# 需要导入模块: import pluggy [as 别名]
# 或者: from pluggy import PluginManager [as 别名]
def get_plugin_manager():
"""
Return plugin manager instance
"""
# Set up plugin infrastructure
pm = pluggy.PluginManager('tljh')
pm.add_hookspecs(hooks)
pm.load_setuptools_entrypoints('tljh')
return pm
示例12: get_plugin_manager
# 需要导入模块: import pluggy [as 别名]
# 或者: from pluggy import PluginManager [as 别名]
def get_plugin_manager():
"""The ``pluggy`` plugin manager."""
pm = pluggy.PluginManager('renku')
pm.add_hookspecs(run_hook_specs)
pm.load_setuptools_entrypoints('renku')
for cls in default_implementations.__dict__.values():
if not isinstance(cls, type):
continue
pm.register(cls())
return pm
示例13: getDefaultPluginManager
# 需要导入模块: import pluggy [as 别名]
# 或者: from pluggy import PluginManager [as 别名]
def getDefaultPluginManager() -> pluggy.PluginManager:
"""
Return a plugin manager containing the default set of ARMI Framework plugins.
This is useful when using standalone facilities of ARMI without a specific
application.
"""
pm = plugins.getNewPluginManager()
for plugin in getDefaultPlugins():
pm.register(plugin)
return pm
示例14: getPluginManager
# 需要导入模块: import pluggy [as 别名]
# 或者: from pluggy import PluginManager [as 别名]
def getPluginManager() -> Optional[pluggy.PluginManager]:
"""
Return the plugin manager, if there is one.
"""
global _app
if _app is None:
return None
return _app.pluginManager
示例15: getPluginManagerOrFail
# 需要导入模块: import pluggy [as 别名]
# 或者: from pluggy import PluginManager [as 别名]
def getPluginManagerOrFail() -> pluggy.PluginManager:
"""
Return the plugin manager. Raise an error if there is none.
"""
global _app
assert _app is not None, (
"The ARMI plugin manager was requested, no App has been configured. Ensure "
"that `armi.configure()` has been called before attempting to interact with "
"the plugin manager."
)
return _app.pluginManager