# Path: pipelines/plugin/base_plugin.py
# class BasePlugin(object):
#     name = 'undefined'
#     hooks = []
#     dry_run = False
# 
#     @classmethod
#     def from_dict(cls, conf_dict, event_mgr=None):
#         return cls()
# 
# Path: pipelines/plugin/exceptions.py
# class PluginError(RuntimeError):
#     pass
# 
# Path: pipelines/plugin/utils.py
# def class_name(obj):
#     if isinstance(obj, type):
#         return obj.__name__
# 
#     if hasattr(obj, '__class__') and hasattr(obj.__class__, '__name__'):
#         return obj.__class__.__name__
# 
#     return str(obj)


import logging
from pipelines.plugin.base_plugin import BasePlugin
from pipelines.plugin.exceptions import PluginError
from pipelines.plugin.utils import class_name
    from pipelineplugins.dummy_executor import DummyExecutor
    from pipelineplugins.stdout_logger import StdoutLogger
        self.plugins = {}

    def get_plugin(self, name):
        return self.plugins.get(name)

    def trigger(self, event_name, *args):
        callbacks = self.plugins.get(event_name, [])
        results = []
        for cb in callbacks:
            try:
                ret = cb(*args)
                results.append(ret)
            except Exception:
                log.error('Unknown error running callback {} hook {}, aborting.'.format(
                    cb.__name__, event_name)
                )
                raise
        return results

    def get_plugin_count(self, hook_name=None):
        if hook_name is None:
            return reduce(lambda counter, p: counter + len(p), self.plugins.values(), 0)

        if hook_name in self.plugins:
            return len(self.plugins[hook_name])
        return 0

    def register_plugin(self, plugin_class, conf_dict):
        if not issubclass(plugin_class, BasePlugin):
            raise PluginError('Trying to register plugin that is not extending BasePlugin: {}'.format(

# Path: pipelines/plugin/base_plugin.py
# class BasePlugin(object):
#     name = 'undefined'
#     hooks = []
#     dry_run = False
# 
#     @classmethod
#     def from_dict(cls, conf_dict, event_mgr=None):
#         return cls()
# 
# Path: pipelines/plugin/exceptions.py
# class PluginError(RuntimeError):
#     pass
# 
# Path: pipelines/plugin/utils.py
# def class_name(obj):
#     if isinstance(obj, type):
#         return obj.__name__
# 
#     if hasattr(obj, '__class__') and hasattr(obj.__class__, '__name__'):
#         return obj.__class__.__name__
# 
#     return str(obj)


# Path: pipelines/plugin/manager.py
import logging
from pipelines.plugin.base_plugin import BasePlugin
from pipelines.plugin.exceptions import PluginError
from pipelines.plugin.utils import class_name
    from pipelineplugins.dummy_executor import DummyExecutor
    from pipelineplugins.stdout_logger import StdoutLogger

        self.plugins = {}

    def get_plugin(self, name):
        return self.plugins.get(name)

    def trigger(self, event_name, *args):
        callbacks = self.plugins.get(event_name, [])
        results = []
        for cb in callbacks:
            try:
                ret = cb(*args)
                results.append(ret)
            except Exception:
                log.error('Unknown error running callback {} hook {}, aborting.'.format(
                    cb.__name__, event_name)
                )
                raise
        return results

    def get_plugin_count(self, hook_name=None):
        if hook_name is None:
            return reduce(lambda counter, p: counter + len(p), self.plugins.values(), 0)

        if hook_name in self.plugins:
            return len(self.plugins[hook_name])
        return 0

    def register_plugin(self, plugin_class, conf_dict):
        if not issubclass(plugin_class, BasePlugin):
            raise PluginError('Trying to register plugin that is not extending BasePlugin: {}'.format(

                class_name(plugin_class))