code optimizations

This commit is contained in:
2024-12-12 22:19:47 +01:00
parent 7e36084b0f
commit c638a0ddd6
8 changed files with 24 additions and 7 deletions
+15 -2
View File
@@ -1,11 +1,24 @@
from app_class import AppClass
from config import Config, TriggerTuple, MissingConfig
class TriggerImportError(Exception):
pass
class Trigger(AppClass):
def __init__(self, _config: Config) -> None:
super().__init__(_config)
self.name = "name has to be filled in inherited class and this name has to match the name from config file"
@property
def name(self) -> str:
if self.__module__ == 'trigger':
raise TriggerImportError(
"the Trigger class can't used directlty, but must be inhereted in a trigger specific class"
)
_ , _name = self.__module__.split('.')
return _name
@property
def config(self) -> TriggerTuple:
_config = self._config.get_trigger_by_name(self.name)