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


Python pluggy.PluginManager方法代码示例

本文整理汇总了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 
开发者ID:tox-dev,项目名称:tox,代码行数:20,代码来源:__init__.py

示例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 
开发者ID:tox-dev,项目名称:tox,代码行数:20,代码来源:test_config.py

示例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 
开发者ID:tox-dev,项目名称:tox,代码行数:21,代码来源:test_config.py

示例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 
开发者ID:mintel,项目名称:pytest-localstack,代码行数:25,代码来源:plugin.py

示例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 
开发者ID:ansible-community,项目名称:molecule,代码行数:19,代码来源:api.py

示例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 
开发者ID:ansible-community,项目名称:molecule,代码行数:19,代码来源:api.py

示例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 
开发者ID:aquasecurity,项目名称:kube-hunter,代码行数:18,代码来源:__init__.py

示例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 
开发者ID:tox-dev,项目名称:tox,代码行数:7,代码来源:test_config.py

示例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 
开发者ID:zvtvz,项目名称:zvt,代码行数:8,代码来源:main.py

示例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 
开发者ID:jupyterhub,项目名称:the-littlest-jupyterhub,代码行数:16,代码来源:installer.py

示例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 
开发者ID:jupyterhub,项目名称:the-littlest-jupyterhub,代码行数:12,代码来源:utils.py

示例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 
开发者ID:SwissDataScienceCenter,项目名称:renku-python,代码行数:13,代码来源:pluginmanager.py

示例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 
开发者ID:terrapower,项目名称:armi,代码行数:14,代码来源:__init__.py

示例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 
开发者ID:terrapower,项目名称:armi,代码行数:10,代码来源:__init__.py

示例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 
开发者ID:terrapower,项目名称:armi,代码行数:14,代码来源:__init__.py


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