Warnungen werden jetzt immer als ganze Sektion auch in die .json von getpositions mit rausgeschrieben
This commit is contained in:
+23
-14
@@ -583,49 +583,57 @@ def get_subdistributor_positions_from_symbols(all_inserts:list, all_positions:li
|
||||
return ret
|
||||
|
||||
|
||||
def get_tunnel_positions_from_symbols(all_inserts: list, all_positions: list) -> dict:
|
||||
def get_tunnel_positions_from_symbols(all_inserts: list, all_positions: list, error_collector: ErrorCollector = None) -> dict:
|
||||
"""Ermittelt Tunnel-Positionen aus allen Symbolen
|
||||
|
||||
|
||||
Args:
|
||||
all_inserts: Liste von Dictionaries mit Attribut-Tags und deren Textwerten
|
||||
all_positions: Liste von Dictionaries mit Attribut-Tags und deren (x, y, z)-Positionen
|
||||
|
||||
error_collector: ErrorCollector instance to collect errors and warnings
|
||||
|
||||
Returns:
|
||||
Dictionary mit Tunnelnamen als Keys und Listen von Positionen als Values
|
||||
Format: {'Tunnel1': [(x1, y1), (x2, y2)], ..., 'length': {'Tunnel1': 'laenge_wert', ...}}
|
||||
"""
|
||||
ret = {}
|
||||
tunnel_length = {}
|
||||
tunnel_missing_length = {}
|
||||
default_length = "5" # Default-Länge in Metern
|
||||
|
||||
|
||||
for insert, pos in zip(all_inserts, all_positions):
|
||||
if "NAME" not in insert: # Tunnel haben immer einen eindeutigen Namen
|
||||
continue
|
||||
|
||||
|
||||
ld, id_ = get_tunnel_position_of_symbol(insert, pos)
|
||||
if not ld or not id_:
|
||||
continue
|
||||
|
||||
|
||||
# Check if id_ matches Tunnel-Pattern from BMK.cfg
|
||||
if not matches_tunnel_pattern(id_):
|
||||
continue
|
||||
|
||||
|
||||
# Sammle alle Positionen für den gleichen Tunnelnamen
|
||||
if id_ not in ret:
|
||||
ret[id_] = []
|
||||
ret[id_].append(ld["pos"])
|
||||
|
||||
|
||||
# Sammle Längeninformation falls vorhanden, sonst Default verwenden
|
||||
if "laenge" in ld and ld["laenge"]:
|
||||
tunnel_length[id_] = ld["laenge"]
|
||||
else:
|
||||
print(f"WARNUNG: Tunnel '{id_}' hat keine LAENGE-Angabe. Verwende Default-Länge: {default_length}m")
|
||||
warning_msg = f"Tunnel '{id_}' hat keine LAENGE-Angabe. Verwende Default-Länge: {default_length}m"
|
||||
print(f"WARNUNG: {warning_msg}")
|
||||
tunnel_missing_length[id_] = warning_msg
|
||||
tunnel_length[id_] = default_length
|
||||
|
||||
|
||||
# Warnings zum ErrorCollector hinzufügen
|
||||
if error_collector and tunnel_missing_length:
|
||||
error_collector.add_warnings({"tunnel_missing_length": tunnel_missing_length})
|
||||
|
||||
# Füge Längeninformation hinzu, falls Tunnel gefunden wurden
|
||||
if len(tunnel_length) > 0:
|
||||
ret['length'] = tunnel_length
|
||||
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
@@ -995,7 +1003,7 @@ if __name__ == '__main__':
|
||||
# die Infos aus den Texten (alter Stil)
|
||||
res_tunnel = get_tunnel_positions_from_entities(t_entities)
|
||||
# die Infos aus den Blöcken (neuer Stil)
|
||||
symbol_tunnels = get_tunnel_positions_from_symbols(all_inserts, all_positions)
|
||||
symbol_tunnels = get_tunnel_positions_from_symbols(all_inserts, all_positions, error_collector)
|
||||
res_tunnel = merge_two_dicts(res_tunnel, symbol_tunnels)
|
||||
output_results['tunnels'] = res_tunnel
|
||||
if args.console:
|
||||
@@ -1021,6 +1029,9 @@ if __name__ == '__main__':
|
||||
# Alle weiteren Fehler zum ErrorCollector hinzufügen
|
||||
error_collector.add_errors(res_not_found)
|
||||
|
||||
# Warnings immer in output_results schreiben (auch wenn leer)
|
||||
output_results["warnings"] = error_collector.warnings if error_collector.warnings else {}
|
||||
|
||||
# ErrorCollector schreibt Datei nur wenn Fehler/Warnungen vorhanden
|
||||
if args.errors:
|
||||
error_collector.write_errorfile(work_dir, args.errors)
|
||||
@@ -1031,8 +1042,6 @@ if __name__ == '__main__':
|
||||
output_results["not_found"] = all_issues["errors"].get("not_found", {})
|
||||
if "double_ids" in all_issues["errors"]:
|
||||
output_results["double_ids"] = all_issues["errors"]["double_ids"]
|
||||
if "missing_attributes" in all_issues.get("warnings", {}):
|
||||
output_results["not_found"]["missing_attributes"] = all_issues["warnings"]["missing_attributes"]
|
||||
|
||||
|
||||
write_results(to_json(output_results), work_dir, f"{basename}.json")
|
||||
|
||||
Reference in New Issue
Block a user