ErrorCollector standarisiert. Warnings werden von getpositions zur routing zu draw durchgereicht.

This commit is contained in:
2025-12-18 16:34:04 +01:00
parent a731889561
commit 9b9d3a8f7c
6 changed files with 235 additions and 28 deletions
+21 -1
View File
@@ -385,6 +385,12 @@ def model_from_json(json_file):
if error_fields['errors_missing_attributes']:
warnings_dict['missing_attributes'] = error_fields['errors_missing_attributes']
# Warnungen aus getpositions und routing übernehmen
if 'warnings' in data:
warnings_from_upstream = data.pop('warnings')
if isinstance(warnings_from_upstream, dict):
warnings_dict.update(warnings_from_upstream)
if errors_dict:
error_collector.add_errors(errors_dict)
if warnings_dict:
@@ -697,6 +703,20 @@ def _create_error_sheets(wb, error_collector: ErrorCollector = None):
for sname, err_msg in missing_attributes.items():
ws.append([sname, err_msg])
# Sheet: WARNINGS (für allgemeine Warnungen wie z-Koordinaten-Abweichungen)
general_warnings = {k: v for k, v in warnings.items() if k != 'missing_attributes'}
if general_warnings:
ws = wb.create_sheet("WARNINGS")
ws.append(["Warning Type", "Details"])
ws.column_dimensions['A'].width = 30
ws.column_dimensions['B'].width = 80
for warning_type, warning_msg in general_warnings.items():
# Formatiere den Warning Type lesbarer
readable_type = warning_type.replace('_', ' ').title()
ws.append([readable_type, str(warning_msg)])
def _create_bom_workbook(outpath, processed_data, bezeichner_cfg):
"""
Erstellt eine separate Excel-Arbeitsmappe für die Stückliste (BOM) und speichert sie ab.
@@ -927,7 +947,7 @@ if __name__ == '__main__':
parser.add_argument('-d', '--dxf', action='store', help='this dxf drawing will be copied and the new layer with the cables will be added. Original file must be added with --origin', metavar='myfile.dxf')
parser.add_argument('-n', '--new', action='store', help='create a new dxf file only with cables in it. Name is basename and a timestamp')
parser.add_argument('-x', '--excel', action='store', help='create a xlsx file with cables data', metavar='allCables.xls')
parser.add_argument('-o', '--origin', action='store', help='name of original .dxf file used by -d and -a', metavar='original.dxf')
parser.add_argument('-o', '--origin', action='store', help='name of original .dxf file used by -d', metavar='original.dxf')
parser.add_argument('-l', '--local', action='store_true', help='using only local data for naming of article numbers. If not set: fetching names from SIVAS.')
args = parser.parse_args()