2021-12-22 08:28:08 +01:00
|
|
|
class TLPStatusParser:
|
2021-12-11 11:59:41 +01:00
|
|
|
def __init__(self, tlp_stat_output):
|
|
|
|
self.data = {}
|
|
|
|
self._parse(tlp_stat_output)
|
|
|
|
|
|
|
|
def _parse(self, data):
|
|
|
|
for line in data.split("\n"):
|
|
|
|
key_val = line.split("=", 1)
|
2024-05-12 16:16:40 +02:00
|
|
|
if len(key_val) > 1: self.data[key_val[0].strip().lower()] = key_val[1].strip()
|
2021-12-11 11:59:41 +01:00
|
|
|
|
2024-05-12 16:16:40 +02:00
|
|
|
def _get_key(self, key): return self.data[key] if key in self.data else ""
|
2021-12-11 11:59:41 +01:00
|
|
|
|
2024-05-12 16:16:40 +02:00
|
|
|
def is_enabled(self): return self._get_key("state") == "enabled"
|