Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Validata
Validata UI
Commits
2cd7cbd5
Commit
2cd7cbd5
authored
Jul 23, 2019
by
Pierre Dittgen
Browse files
Always display body errors
parent
078faddb
Changes
1
Hide whitespace changes
Inline
Side-by-side
validata_ui/views.py
View file @
2cd7cbd5
...
...
@@ -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):
else
:
report
[
'table'
][
'errors'
][
'body'
].
append
(
err
)
# 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
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment