code optimizations
This commit is contained in:
+15
-2
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user