From 3f6594065dfd55f7cc4556facf737a82016c4b13 Mon Sep 17 00:00:00 2001 From: lertlmaier Date: Tue, 1 Jul 2025 16:02:21 +0200 Subject: [PATCH] =?UTF-8?q?Dict=20f=C3=BC=20Dubletten=20angelegt.=20Error?= =?UTF-8?q?=20message=20angepasst.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/getpositions.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/getpositions.py b/lib/getpositions.py index 4a02d71..92af40b 100644 --- a/lib/getpositions.py +++ b/lib/getpositions.py @@ -147,14 +147,11 @@ def check_double_ids(ld, id, allSensors): return True return False - - - def extract_input_positions(insert_iterable) -> tuple: allSensors = dict() allCables = dict() allunknowns = dict() - doubleIds = list() + doubleIds = dict() allSchaltschrank = dict() for insert in insert_iterable: @@ -171,11 +168,13 @@ def extract_input_positions(insert_iterable) -> tuple: allSensors[id] = merge_two_dicts(allSensors[id], ld) #Kombiniert alle infos aus dxf und "pos" else: # gib aus wo sich beide gleichlautenden Elemente auf der Zeichnung befinden - doubleIds.append((id, allSensors[id]["pos"]) ) - doubleIds.append((id, ld["pos"]) ) - + if id not in doubleIds: + doubleIds[id] = [] + doubleIds[id].append(allSensors[id]["pos"]) # erste Position + doubleIds[id].append(ld["pos"]) # zweite Position else: allSensors[id] = ld + elif typ == "Kabel": allCables[id] = ld elif typ == "Schaltschrankelement": @@ -478,7 +477,7 @@ def dxf_is_binary(dxf_path): def validate_configs(): errors= [] - print("Validating given configs: Checking for inconsistency.") + print("\nValidating given configs: Checking for inconsistency.") # 1. Alle Prefixes aus Routing_include müssen in Cable_Mapping stehen (nur BMK.cfg) if config_BMK.has_section("Routing-Include") and config_BMK.has_section("Cable-Mapping"): @@ -508,9 +507,9 @@ def validate_configs(): print("Inconsistencies found:") for e in errors: print(f"- {e}") - print("continuing") + print("\ncontinuing with routing process") else: - print ("No inconsistencies found") + print ("No inconsistencies found. Continuing with routing process.") def check_environment_var(env_str:str) -> Path: out_path = os.environ.get(env_str) @@ -592,9 +591,8 @@ if __name__ == '__main__': res_sens, res_double = get_input_positions(msp) if args.errors and len(res_double) > 0: - err_ids = set() - for item in res_double: - err_ids.add(item[0]) + print("Duplicate blocks found. Writing errors-file.") + err_ids = list(res_double.keys()) write_results(to_json(list(err_ids)), work_dir, args.errors)