Ingen beskrivning
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

interface.py 1023B

123456789101112131415161718192021222324252627282930313233343536
  1. from .plugins import Plugin
  2. from .exceptions import *
  3. from lodel.settings.validator import SettingValidator
  4. _glob_typename = 'ui'
  5. ##@brief Handles interfaces plugin
  6. #@note It's a singleton class. Only 1 interface allowed by instance.
  7. class InterfacePlugin(Plugin):
  8. ##@brief Singleton instance storage
  9. _instance = None
  10. _plist_confspecs = {
  11. 'section': 'lodel2',
  12. 'key': 'interface',
  13. 'default': None,
  14. 'validator': SettingValidator(
  15. 'plugin', none_is_valid = True, ptype = _glob_typename)}
  16. _type_conf_name = _glob_typename
  17. def __init__(self, name):
  18. if InterfacePlugin._instance is not None:
  19. raise PluginError("Maximum one interface allowed")
  20. super().__init__(name)
  21. self._instance = self
  22. ##@brief Clear class
  23. #@see plugins.Plugin::clear()
  24. @classmethod
  25. def clear_cls(cls):
  26. if cls._instance is not None:
  27. inst = cls._instance
  28. cls._instance = None
  29. del(inst)