Skip to content
Snippets Groups Projects

XLSX-Konverter: Bessere Fehlermeldung bei inkorrektem Typ in Spalte, zusätzlicher Spalte

Merged I. Nüske requested to merge f-xlsx-converter-error-messages into dev
All threads resolved!
2 files
+ 9
7
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -186,7 +186,8 @@ class XLSXConverter:
self._check_columns(fail_fast=strict)
except KeyError as e:
raise jsonschema.ValidationError(f"Malformed metadata: Cannot parse paths. "
f"Unknown path: {e}") from e
f"Unknown path: '{e.args[1]}' in sheet '{e.args[0]}'."
) from e
self._handled_sheets: set[str] = set()
self._result: dict = {}
self._errors: dict = {}
@@ -270,8 +271,11 @@ class XLSXConverter:
parents[xlsx_utils.p2s(col.path[:-1])] = col.path[:-1]
col_paths.append(col.path)
for path in parents.values():
subschema = xlsx_utils.get_subschema(path, self._schema)
try:
subschema = xlsx_utils.get_subschema(path, self._schema)
except KeyError as kerr:
kerr.args = (sheetname, *kerr.args)
raise
# Unfortunately, there are a lot of special cases to handle here.
if subschema.get("type") == "array":
subschema = subschema["items"]
@@ -544,9 +548,6 @@ def _group_foreign_paths(foreign: list[list], common: list[str]) -> list[SimpleN
last_level = len(elem.path)
resultlist.append(elem)
# from IPython import embed
# embed()
if last_level != len(common):
raise ValueError("Foreign keys must cover the complete `common` depth.")
return resultlist
Loading