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