From 9365b2d71e8687b79745f0eaf9826e8603c2cd4b Mon Sep 17 00:00:00 2001 From: mistangl Date: Thu, 25 Sep 2025 16:57:38 +0200 Subject: [PATCH] missing dists, sensors attributs nur schreiben wenn wirklich etwas fehlt. --- lib/getpositions.py | 10 +++++++--- lib/routing.py | 13 ++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/getpositions.py b/lib/getpositions.py index e54af1e..caf34d0 100644 --- a/lib/getpositions.py +++ b/lib/getpositions.py @@ -810,20 +810,24 @@ def check_file_in_work(work_dir: Path, filename: Path) -> tuple[Path, bool]: def check_existance(res_mappings: dict, res_dist: dict, res_pos: dict, res_tunnel: dict) -> dict: ret = dict() - ret["missing_distributors"] = list() - ret["missing_sensors"] = list() - ret["missing_tunnel"] = list() + for dname in res_mappings.keys(): if dname not in res_dist: + if "missing_distributors" not in ret: + ret["missing_distributors"] = list() ret["missing_distributors"].append(dname) for sname, lofsensors in res_mappings.items(): for s in lofsensors: if s not in res_pos: + if "missing_sensors" not in ret: + ret["missing_sensors"] = list() ret['missing_sensors'].append(s) for tname in res_tunnel.keys(): if tname == "length": # dict enthält auch die Länge aller Tunnels in einem Key continue if len(res_tunnel[tname]) < 2 : + if "missing_tunnel" not in ret: + ret["missing_tunnel"] = list() ret["missing_tunnel"].append(tname) if len(res_tunnel[tname]) > 2 : if "overdefined_tunnel" not in ret: diff --git a/lib/routing.py b/lib/routing.py index 4bc4170..36acc25 100644 --- a/lib/routing.py +++ b/lib/routing.py @@ -150,9 +150,16 @@ def prepare_data(rawdata:dict): dtunlength = rawdata["tunnels"]["length"] # Fehler, welche im getpositions auftreten weiterführen: im Layout fehlende Dists / Sensoren / fehlende Attribute - errors_dists = rawdata["not_found"]["missing_distributors"] - errors_sensors = rawdata["not_found"]["missing_sensors"] - errors_attributes = rawdata["not_found"]["missing_attributes"] + errors_dists = list() + errors_sensors = list() + errors_attributes = dict() + if "not_found" in rawdata: + if "missing_distributors" in rawdata["not_found"]: + errors_dists = rawdata["not_found"]["missing_distributors"] + if "missing_sensors" in rawdata["not_found"]: + errors_sensors = rawdata["not_found"]["missing_sensors"] + if "missing_attributes" in rawdata["not_found"]: + errors_attributes = rawdata["not_found"]["missing_attributes"] return (dracks, dsensors, dsubdists, mapping, dtunnels, dtunlength, errors_dists, errors_sensors, errors_attributes)