No Description
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 1.2KB

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