change config structure

This commit is contained in:
2024-01-03 19:54:34 +01:00
parent 5d21b81530
commit 4da1a0e9b3
7 changed files with 194 additions and 99 deletions

View File

@@ -331,18 +331,17 @@ class Notify:
def __init__(self, cfg, local_addrs, debug):
self.cfg = cfg
self.logger = logging.getLogger(cfg["name"])
del cfg["name"]
self.logger.setLevel(cfg.get_loglevel(debug))
nodification_type = cfg["options"]["type"]
del cfg["options"]["type"]
cfg["options"]["pretend"] = cfg["pretend"]
self._notification = self.NOTIFICATION_TYPES[nodification_type](
**cfg["options"])
del cfg["loglevel"]
nodification_type = cfg["type"]
del cfg["type"]
self._notification = self.NOTIFICATION_TYPES[nodification_type](**cfg)
self._headersonly = self._notification._headersonly
def __str__(self):
cfg = []
for key, value in self.cfg["options"].items():
for key, value in self.cfg.items():
cfg.append(f"{key}={value}")
class_name = type(self._notification).__name__
return f"{class_name}(" + ", ".join(cfg) + ")"