How to use the pluggy.HookimplMarker 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 web-platform-tests / wpt / tools / third_party / pluggy / testing / test_hookrelay.py View on Github external
import pytest
from pluggy import PluginValidationError, HookimplMarker, HookspecMarker


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


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

    pm.add_hookspecs(Api)
    hook = pm.hook
    assert hasattr(hook, 'hello')
    assert repr(hook.hello).find("hello") != -1

    class Plugin(object):
        @hookimpl
        def hello(self, arg):
github flaskbb / flaskbb / tests / unit / user / test_update_settings.py View on Github external
            @HookimplMarker("flaskbb")
            def flaskbb_settings_updated(self, user, settings_update):
                post_processor.post_process_changeset(
                    user=user, settings_update=settings_update
                )
github pwwang / PyPPL / pyppl / runner.py View on Github external
hookspec (pluggy.HookspecMarker): The marker for runner hooks
"""
# 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
github devpi / devpi / web / devpi_web / main.py View on Github external
from chameleon.config import AUTO_RELOAD
from devpi_common.metadata import get_latest_version
from devpi_web.config import get_pluginmanager
from devpi_web.doczip import remove_docs
from devpi_web.indexing import ProjectIndexingInfo
from devpi_server.log import threadlog
from devpi_server.main import fatal
from pkg_resources import resource_filename
from pluggy import HookimplMarker
from pyramid.renderers import get_renderer
from pyramid_chameleon.renderer import ChameleonRendererLookup
import os
import sys


hookimpl = HookimplMarker("devpiweb")
devpiserver_hookimpl = HookimplMarker("devpiserver")


def theme_static_url(request, path):
    return request.static_url(
        os.path.join(request.registry['theme_path'], 'static', path))


def macros(request):
    # returns macros which may partially be overwritten in a theme
    result = {}
    paths = [
        resource_filename('devpi_web', 'templates/macros.pt'),
        "templates/macros.pt"]
    for path in paths:
        renderer = get_renderer(path)
github tox-dev / tox / src / tox / __init__.py View on Github external
from .version import __version__

__all__ = (
    "__version__",  # tox version
    "cmdline",  # run tox as part of another program/IDE (same behaviour as called standalone)
    "hookimpl",  # Hook implementation marker to be imported by plugins
    "exception",  # tox specific exceptions
    # EXPERIMENTAL CONSTANTS API
    "PYTHON",
    "INFO",
    "PIP",
    # DEPRECATED - will be removed from API in tox 4
    "hookspec",
)

hookimpl = pluggy.HookimplMarker("tox")

# NOTE: must come last due to circular import
from .session import cmdline  # isort:skip
github ESSS / alfasim-sdk / alfasim_sdk / __init__.py View on Github external
# -*- coding: utf-8 -*-
"""Top-level package for alfasim-sdk."""
import pluggy

__author__ = """ESSS"""
__email__ = "foss@esss.co"
__version__ = "0.1.0"

hookimpl = pluggy.HookimplMarker("ALFAsim")


def get_alfasim_sdk_api_path():
    """
    Return the directory that contains the alfasim_sdk_api with the header files
    """
    from alfasim_sdk import hook_specs
    from pathlib import Path

    return str(Path(hook_specs.__file__).parents[1])
github CarveSystems / usbq / usbq / hookspec.py View on Github external
import attr
import pluggy

__all__ = ['hookimpl', 'USBQPluginDef']

USBQ_EP = 'usbq'

hookspec = pluggy.HookspecMarker('usbq')
hookimpl = pluggy.HookimplMarker('usbq')


@attr.s(frozen=True)
class USBQPluginDef:
    'Define a USBQ plugin.'

    #: Name of the plugin
    name = attr.ib(converter=str)

    #: Description
    desc = attr.ib(converter=str)

    #: Module name
    mod = attr.ib(converter=str)

    #: Class
github allure-framework / allure-python / allure-python-commons / src / _hooks.py View on Github external
from pluggy import HookspecMarker, HookimplMarker

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


class AllureUserHooks(object):

    @hookspec
    def decorate_as_title(self, test_title):
        """ title """

    @hookspec
    def add_title(self, test_title):
        """ title """

    @hookspec
    def decorate_as_description(self, test_description):
        """ description """
github aquasecurity / kube-hunter / kube_hunter / plugins / __init__.py View on Github external
import pluggy

from kube_hunter.plugins import hookspecs

hookimpl = pluggy.HookimplMarker("kube-hunter")


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)
github deltachat / deltabot / src / deltabot / hookspec.py View on Github external
import pluggy

spec_name = "deltabot"
deltabot_hookspec = pluggy.HookspecMarker(spec_name)
deltabot_hookimpl = pluggy.HookimplMarker(spec_name)


class DeltaBotSpecs:
    """ per DeltaBot instance hook specifications. """

    @deltabot_hookspec
    def deltabot_init_parser(self, parser):
        """ initialize the deltabot main parser with new options and subcommands.

        :param parser: a :class:`deltabot.parser.MyArgumentParser` instance where you can
                        call `add_subcommand(name, func)` to get a sub parser where you
                        can then add arguments.
        """

    @deltabot_hookspec(firstresult=True)
    def deltabot_get_logger(self, args):