Commit 582fd4c4 authored by Pierre Dittgen's avatar Pierre Dittgen
Browse files

Adapt to changes in frictionless report

parent 858e744b
......@@ -207,14 +207,14 @@ def create_validata_ui_report(rows_count: int, validata_core_report, schema_dict
- errors are separated into "structure" and "body"
- error messages are improved
"""
v_report = copy.deepcopy(validata_core_report)
v_report = copy.deepcopy(validata_core_report.to_dict())
# Create a new UI report from information picked in validata report
ui_report = {}
ui_report["table"] = {}
# source headers
headers = v_report.table["header"]
headers = v_report["tasks"][0]["resource"]["data"][0]
ui_report["table"]["header"] = headers
# source dimension
......@@ -235,9 +235,10 @@ def create_validata_ui_report(rows_count: int, validata_core_report, schema_dict
else "Cette colonne n'est pas définie dans le schema"
for h in headers
]
v_report_table = v_report["tasks"][0]
missing_headers = [
err["message-data"]["column-name"]
for err in v_report.table["errors"]
for err in v_report_table["errors"]
if err["code"] == "missing-header"
]
ui_report["table"]["cols_alert"] = [
......@@ -246,12 +247,12 @@ def create_validata_ui_report(rows_count: int, validata_core_report, schema_dict
]
# prepare error structure for UI needs
errors = build_ui_errors(v_report.table["errors"])
errors = build_ui_errors(v_report_table["errors"])
# Count errors and warnings
ui_report["error_count"] = len(errors)
ui_report["warn_count"] = len(v_report.table["structure_warnings"])
ui_report["warnings"] = v_report.table["structure_warnings"]
ui_report["warn_count"] = len(v_report_table["structure_warnings"])
ui_report["warnings"] = v_report_table["structure_warnings"]
# Then group them in 2 groups : structure and body
ui_report["table"]["errors"] = {"structure": [], "body": []}
......@@ -390,7 +391,7 @@ def validate(schema_instance: SchemaInstance, validata_resource: ValidataResourc
# Source error
source_errors = [
err
for err in validata_core_report["tables"][0]["errors"]
for err in validata_core_report["tasks"][0]["errors"]
if err["code"] in {"source-error", "unknown-csv-dialect"}
]
if source_errors:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment