added trigger mapping

This commit is contained in:
2024-12-05 13:29:56 +01:00
parent 51b8647ded
commit 9623cfcf2c
6 changed files with 47 additions and 8 deletions
+21
View File
@@ -2,6 +2,11 @@ from pathlib import Path
from lxml import etree
from functools import cached_property
from arguments import ArgumentsParser
from typing import NamedTuple
class TriggerTuple(NamedTuple):
name: str
class Config:
@@ -20,3 +25,19 @@ class Config:
@cached_property
def loglevel(self) -> str:
return self.app_root.xpath('logLevel').pop().text
@cached_property
def testmode(self) -> bool:
value = self.app_root.xpath('testMode').pop().text.lower()
if value not in ['true', 'false']:
raise ValueError("testMode can only be 'true' or 'false")
return True if value == 'true' else False
@cached_property
def triggertuples(self) -> list[TriggerTuple]:
ret_val = []
_triggers = self.app_root.xpath('triggers/trigger')
for trigger in _triggers:
name = trigger.xpath('name').pop().text
ret_val.append(TriggerTuple(name=name))
return ret_val