Commit 2cd7cbd5 authored by Pierre Dittgen's avatar Pierre Dittgen
Browse files

Always display body errors

parent 078faddb
......@@ -22,7 +22,7 @@ from flask import abort, make_response, redirect, render_template, request, url_
import tabulator
from opendataschema import GitSchemaReference, by_commit_date
from validata_core import messages
from validata_core import messages, repair
from . import app, config, schema_catalog_registry, tableschema_from_url
from .ui_util import flash_error, flash_warning
......@@ -132,7 +132,7 @@ class SchemaInstance:
return None
def extract_source_data(source: ValidataResource, preview_rows_nb=5):
def extract_source_data(source: ValidataResource, schema_descriptor, preview_rows_nb=5):
""" Computes table preview """
def stringify(val):
......@@ -144,7 +144,8 @@ def extract_source_data(source: ValidataResource, preview_rows_nb=5):
nb_rows = 0
tabulator_source, tabulator_options = source.build_tabulator_stream_args()
with tabulator.Stream(tabulator_source, **tabulator_options) as stream:
fixed_source, _ = repair(tabulator_source, schema_descriptor, **tabulator_options)
with tabulator.Stream(fixed_source, {**tabulator_options, 'scheme': 'stream', 'format': 'inline'}) as stream:
for row in stream:
if header is None:
header = ['' if v is None else v for v in row]
......@@ -243,10 +244,10 @@ def create_validata_ui_report(validata_core_report, schema_dict):
# Checks if there are structure errors different to invalid-column-delimiter
structure_errors = report['table']['errors']['structure']
report['table']['do_display_body_errors'] = len(structure_errors) == 0 or \
all(err['code'] == 'invalid-column-delimiter' for err in structure_errors)
# Always displays body errors
report['table']['do_display_body_errors'] = True
# Checks if a column comparison is needed
header_errors = ('missing-headers', 'extra-headers', 'wrong-headers-order')
......@@ -381,7 +382,7 @@ def validate(schema_instance: SchemaInstance, source: ValidataResource):
flash_error('Erreur de source : {}'.format(msg))
return redirect(url_for('custom_validator'))
source_data = extract_source_data(source)
source_data = extract_source_data(source, schema_instance.schema.descriptor)
# handle report date
report_datetime = datetime.fromisoformat(validata_core_report['date']).astimezone()
Supports Markdown
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