How to use the pluggy.HookspecMarker function in pluggy

To help you get started, we’ve selected a few pluggy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pytest-dev / pluggy / docs / examples / eggsample / eggsample / hookspecs.py View on Github external
import pluggy

hookspec = pluggy.HookspecMarker("eggsample")


@hookspec
def eggsample_add_ingredients(ingredients: tuple):
    """Have a look at the ingredients and offer your own.

    :param ingredients: the ingredients, don't touch them!
    :return: a list of ingredients
    """


@hookspec
def eggsample_prep_condiments(condiments: dict):
    """Reorganize the condiments tray to your heart's content.
github pytest-dev / pluggy / testing / test_invocations.py View on Github external
import pytest
from pluggy import PluginValidationError, HookimplMarker, HookspecMarker


hookspec = HookspecMarker("example")
hookimpl = HookimplMarker("example")


def test_argmismatch(pm):
    class Api:
        @hookspec
        def hello(self, arg):
            "api hook 1"

    pm.add_hookspecs(Api)

    class Plugin:
        @hookimpl
        def hello(self, argwrong):
            pass
github pytest-dev / pluggy / testing / test_hookcaller.py View on Github external
import pytest

from pluggy import HookimplMarker, HookspecMarker, PluginValidationError
from pluggy.hooks import HookImpl

hookspec = HookspecMarker("example")
hookimpl = HookimplMarker("example")


@pytest.fixture
def hc(pm):
    class Hooks:
        @hookspec
        def he_method1(self, arg):
            pass

    pm.add_hookspecs(Hooks)
    return pm.hook.he_method1


@pytest.fixture
def addmeth(hc):
github pwwang / PyPPL / pyppl / runner.py View on Github external
"""
# pylint: disable=unused-argument,invalid-name
import sys
import pluggy
import psutil
from .exception import (RunnerNoSuchRunner, RunnerMorethanOneRunnerEnabled,
                        RunnerTypeError)

RMNAME = "pyppl_runner"
# save all runners ever registered
RUNNERS = {}
# poll interval to check job status
DEFAULT_POLL_INTERVAL = 1

hookimpl = pluggy.HookimplMarker(RMNAME)
hookspec = pluggy.HookspecMarker(RMNAME)


@hookspec
def runner_init(proc):
    """@API
    RUNNER API
    Initiate runner
    @params:
        proc (Proc): The Proc instance
    """


@hookspec(firstresult=True)
def isrunning(job):
    """@API
    RUNNER API
github devpi / devpi / web / devpi_web / hookspecs.py View on Github external
from pluggy import HookspecMarker

hookspec = HookspecMarker("devpiweb")


@hookspec
def devpiweb_get_status_info(request):
    """Called on every request to gather status information.

    Returns a list of dictionaries with keys ``status`` and ``msg``, where
    status is ``warn`` or ``fatal``.
    """


@hookspec
def devpiweb_indexer_backend():
    """ return dict containing indexer backend info.

    The following keys are defined:
github pyslackers / sir-bot-a-lot / sirbot / core / hookspecs.py View on Github external
"""
Hookspecs of the core plugins
"""

import pluggy

hookspec = pluggy.HookspecMarker('sirbot')


@hookspec
def plugins(loop):
    """
    Hook for registering a plugin.

    Args:
        loop (asyncio.AbstractEventLoop): Event loop

    Returns:
        sirbot.core.plugin.Plugin: A plugin instance
    """
    pass  # pragma: no cover
github SwissDataScienceCenter / renku-python / renku / core / plugins / process_run.py View on Github external
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Plugin hooks for ``ProcessRun`` customization."""
import pluggy

hookspec = pluggy.HookspecMarker('renku')


@hookspec
def process_run_annotations(run):
    """Plugin Hook to add ``Annotation`` entry list to a ``ProcessRun``.

    :param run: A ``ProcessRun`` object to get annotations for.
    :returns: A list of ``renku.core.models.provenance.activities.Annotation``
              objects.
    """
    pass


@hookspec
def cmdline_tool_annotations(tool):
    """Plugin Hook to add ``Annotation`` entry list to a ``WorkflowTool``.
github Crypto-toolbox / bitex / bitex / plugins / specs.py View on Github external
return constructed_url

Where `constructed_url` is obviously a dummy - it's the plugin writers responsibility
to construct an adequate url from the shorthand, factoring in any method, endpoint
and parameters given in it.

"""
# Built-in
from typing import Any, Dict, Mapping, Tuple, Type, Union

# Third-party
import pluggy
from requests import PreparedRequest, Response
from requests.auth import AuthBase

hookspec = pluggy.HookspecMarker("bitex")


@hookspec
def announce_plugin() -> Union[
    Tuple[str, Type[AuthBase], Type[PreparedRequest], Type[Response]], None
]:
    """Announce plugin classes to :mod:`bitex`.

    The function should return a tuple with the following items:

        * the exchange name this plugin is for
        * the auth class to use when generating authentication signatures for it
        * the prepared request class to use when prepping for transmission
        * the response class to use when generating a response from the exchange.
    """