Skip to content
GitLab
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
da412dd8
Commit
da412dd8
authored
Jan 12, 2021
by
Pierre Dittgen
Browse files
Use black and fix flake8 issues
parent
315cb4cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
validata_ui/views.py
View file @
da412dd8
...
...
@@ -5,11 +5,8 @@ import copy
import
io
import
json
import
logging
import
subprocess
import
tempfile
from
collections
import
Counter
from
datetime
import
datetime
from
pathlib
import
Path
from
urllib.parse
import
urlencode
,
urljoin
import
frictionless
...
...
@@ -179,12 +176,12 @@ def build_ui_errors(errors):
# Context
update_keys
=
{
"context"
:
"body"
if
"row-number"
in
err
and
not
err
[
"row-number"
]
is
None
if
"row-number"
in
err
and
err
[
"row-number"
]
is
not
None
else
"table"
,
}
# Set title
if
not
"title"
in
err
:
if
"title"
not
in
err
:
update_keys
[
"title"
]
=
err
[
"name"
]
# Set content
...
...
@@ -201,13 +198,13 @@ def build_ui_errors(errors):
def
create_validata_ui_report
(
validata_core_report
,
schema_dict
):
"""
Creates an error report easier to handle and display in templates:
- only one table
- errors are contextualized
- error-counts is ok
- errors are grouped by lines
- errors are separated into "structure" and "body"
- error messages are improved
"""Creates an error report easier to handle and display in templates:
- only one table
- errors are contextualized
- error-counts is ok
- errors are grouped by lines
- errors are separated into "structure" and "body"
- error messages are improved
"""
v_report
=
copy
.
deepcopy
(
validata_core_report
)
...
...
@@ -267,7 +264,7 @@ def create_validata_ui_report(validata_core_report, schema_dict):
rows
=
[]
current_row_id
=
0
for
err
in
ui_report
[
"table"
][
"errors"
][
"body"
]:
if
not
"rowPosition"
in
err
:
if
"rowPosition"
not
in
err
:
continue
row_id
=
err
[
"rowPosition"
]
if
row_id
!=
current_row_id
:
...
...
@@ -404,7 +401,10 @@ def validate(schema_instance: SchemaInstance, validata_resource: ValidataResourc
if
isinstance
(
validata_resource
,
URLValidataResource
):
base_url
=
url_for
(
"pdf_report"
)
query_string
=
urlencode
(
{
**
schema_instance
.
request_parameters
(),
"url"
:
validata_resource
.
url
,}
{
**
schema_instance
.
request_parameters
(),
"url"
:
validata_resource
.
url
,
}
)
pdf_report_url
=
f
"
{
base_url
}
?
{
query_string
}
"
...
...
@@ -520,12 +520,7 @@ def home():
schema_info
[
"title"
]
=
f
"le format du schéma «
{
schema_info
[
'name'
]
}
» n'est pas reconnu"
except
datapackage
.
exceptions
.
ValidationError
:
schema_info
[
"err"
]
=
True
schema_info
[
"title"
]
=
f
"le schéma «
{
schema_info
[
'name'
]
}
» comporte des erreurs"
except
Exception
as
e
:
except
Exception
:
schema_info
[
"err"
]
=
True
schema_info
[
"title"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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