# Path: grappa/log.py

# 
# Path: grappa/engine.py
# class Engine(object):
#     """
#     Engine implements the test engine responsible of registering, storing and
#     running test operators.
#     """
# 
#     # globally store test operators by name
#     operators = {}
# 
#     def __init__(self):
#         self.keywords = []
#         self.assertions = []
# 
#     @staticmethod
#     def register(*operators):
#         """
#         Registers one or multiple operators in the test engine.
#         """
#         register_operators(*operators)
# 
#     @property
#     def empty(self):
#         return len(self.assertions) == 0
# 
#     def add_assertion(self, assertion):
#         self.assertions.append(assertion)
# 
#     def add_keyword(self, keyword):
#         self.keywords.append(keyword)
# 
#     def reverse(self):
#         self.assertions.reverse()
# 
#     def find_operator(self, name):
#         return self.operators.get(name)
# 
#     def run(self, ctx):
#         return Runner(self).run(ctx)
# 
#     def reset(self):
#         self.__init__()
# 
#     def reset_keywords(self):
#         self.keywords = []
# 
#     def clone(self):
#         engine = Engine()
#         engine.keywords = self.keywords[:]
#         engine.assertions = self.assertions[:]
#         return engine


import inspect
from .log import log
from .engine import Engine
    """
    Register plugin in grappa.

    `plugin` argument can be a function or a object that implement `register`
    method, which should accept one argument: `grappa.Engine` instance.

    Arguments:
        plugin (function|module): grappa plugin object to register.

    Raises:
        ValueError: if `plugin` is not a valid interface.

    Example::

        import grappa

        class MyOperator(grappa.Operator):
            pass

        def my_plugin(engine):
            engine.register(MyOperator)

        grappa.use(my_plugin)
    """
    log.debug('register new plugin: {}'.format(plugin))

    if inspect.isfunction(plugin):
        return plugin(Engine)

    if plugin and hasattr(plugin, 'register'):

# Path: grappa/log.py

# 
# Path: grappa/engine.py
# class Engine(object):
#     """
#     Engine implements the test engine responsible of registering, storing and
#     running test operators.
#     """
# 
#     # globally store test operators by name
#     operators = {}
# 
#     def __init__(self):
#         self.keywords = []
#         self.assertions = []
# 
#     @staticmethod
#     def register(*operators):
#         """
#         Registers one or multiple operators in the test engine.
#         """
#         register_operators(*operators)
# 
#     @property
#     def empty(self):
#         return len(self.assertions) == 0
# 
#     def add_assertion(self, assertion):
#         self.assertions.append(assertion)
# 
#     def add_keyword(self, keyword):
#         self.keywords.append(keyword)
# 
#     def reverse(self):
#         self.assertions.reverse()
# 
#     def find_operator(self, name):
#         return self.operators.get(name)
# 
#     def run(self, ctx):
#         return Runner(self).run(ctx)
# 
#     def reset(self):
#         self.__init__()
# 
#     def reset_keywords(self):
#         self.keywords = []
# 
#     def clone(self):
#         engine = Engine()
#         engine.keywords = self.keywords[:]
#         engine.assertions = self.assertions[:]
#         return engine


# Path: grappa/plugin.py
import inspect
from .log import log
from .engine import Engine

    """
    Register plugin in grappa.

    `plugin` argument can be a function or a object that implement `register`
    method, which should accept one argument: `grappa.Engine` instance.

    Arguments:
        plugin (function|module): grappa plugin object to register.

    Raises:
        ValueError: if `plugin` is not a valid interface.

    Example::

        import grappa

        class MyOperator(grappa.Operator):
            pass

        def my_plugin(engine):
            engine.register(MyOperator)

        grappa.use(my_plugin)
    """
    log.debug('register new plugin: {}'.format(plugin))

    if inspect.isfunction(plugin):
        return plugin(Engine)

    if plugin and hasattr(plugin, 'register'):

        return plugin.register(Engine)