1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2026-01-14 02:32:14 +01:00
lodel2_mirror/lodel/plugin/interface.py
Yann fdc985c732 Plugin discover & clear bugfixes
- Child classes where not cleared when Plugin.clear() was called. Now child classes implements a clear_cls() method to clear a Plugin child class
- When discovering plugins if during a is_plugin_dir() check we import two times in the same virtual module name, all non existing attributes values are taken from prvious imported file (the bug was on plugin_type when webui was imported just before dummy, then dummy was an interface)
2016-08-29 14:16:48 +02:00

36 lines
1,023 B
Python

from .plugins import Plugin
from .exceptions import *
from lodel.settings.validator import SettingValidator
_glob_typename = 'ui'
##@brief Handles interfaces plugin
#@note It's a singleton class. Only 1 interface allowed by instance.
class InterfacePlugin(Plugin):
##@brief Singleton instance storage
_instance = None
_plist_confspecs = {
'section': 'lodel2',
'key': 'interface',
'default': None,
'validator': SettingValidator(
'plugin', none_is_valid = True, ptype = _glob_typename)}
_type_conf_name = _glob_typename
def __init__(self, name):
if InterfacePlugin._instance is not None:
raise PluginError("Maximum one interface allowed")
super().__init__(name)
self._instance = self
##@brief Clear class
#@see plugins.Plugin::clear()
@classmethod
def clear_cls(cls):
if cls._instance is not None:
inst = cls._instance
cls._instance = None
del(inst)