aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/allure-python-commons/allure_commons/_core.py
blob: 40d9deafb78445bae193de0cb58997b7cc145784 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from pluggy import PluginManager
from allure_commons import _hooks


class MetaPluginManager(type):
    _plugin_manager: PluginManager = None

    @staticmethod
    def get_plugin_manager():
        if not MetaPluginManager._plugin_manager:
            MetaPluginManager._plugin_manager = PluginManager('allure')
            MetaPluginManager._plugin_manager.add_hookspecs(_hooks.AllureUserHooks)
            MetaPluginManager._plugin_manager.add_hookspecs(_hooks.AllureDeveloperHooks)

        return MetaPluginManager._plugin_manager

    def __getattr__(cls, attr):
        pm = MetaPluginManager.get_plugin_manager()
        return getattr(pm, attr)


class plugin_manager(metaclass=MetaPluginManager):
    pass