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
a5effda7
Commit
a5effda7
authored
Jun 03, 2019
by
Pierre Dittgen
Browse files
Remove unused ValidatorHelper class
parent
bc267bff
Changes
3
Hide whitespace changes
Inline
Side-by-side
validata_ui/__init__.py
View file @
a5effda7
...
...
@@ -5,15 +5,9 @@ from urllib.parse import quote_plus
import
flask
import
jinja2
#import validata_core
# Let this import after app initialisation
from
.
import
config
#from .validate_helper import ValidatorHelper
# Schemas settings
# schemas_config = validata_core.get_schemas_config()
# ValidatorHelper.init(schemas_config)
# TODO: load config.toml
...
...
validata_ui/validate_helper.py
deleted
100644 → 0
View file @
bc267bff
""" Call validation code """
import
logging
import
validata_core
log
=
logging
.
getLogger
(
__name__
)
class
ValidatorHelper
:
""" Help validating tabular data """
schema_dict
=
{}
@
classmethod
def
init
(
cls
,
schemas_config
):
""" Register and download schema and custom_checks info """
cls
.
validator
=
validata_core
.
Validator
(
schemas_config
)
cls
.
schema_dict
=
{}
for
code
,
schema_config
in
schemas_config
.
items
():
schema
=
schema_config
[
'schema'
]
log
.
info
(
'Loading schema %r from %r'
,
code
,
schema
)
schema_instance
=
cls
.
validator
.
load_schema
(
schema
)
if
schema_instance
:
cls
.
schema_dict
[
code
]
=
{
**
schema_config
,
"schema_instance"
:
schema_instance
}
@
classmethod
def
schema_exist
(
cls
,
schema_code
):
""" Checks if schema exists """
return
schema_code
in
cls
.
schema_dict
@
classmethod
def
schema_info
(
cls
,
schema_code
):
""" Return schema info from code """
if
not
cls
.
schema_exist
(
schema_code
):
return
None
# First schema keys but 'fields'
d1
=
{
k
:
v
for
k
,
v
in
cls
.
schema
(
schema_code
).
descriptor
.
items
()
if
k
!=
'fields'
}
# All keys but schema* and custom_checks*
d2
=
{
k
:
v
for
k
,
v
in
cls
.
schema_dict
[
schema_code
].
items
()
if
not
k
.
startswith
(
'schema'
)}
return
{
**
d1
,
'code'
:
schema_code
,
**
d2
}
@
classmethod
def
schema
(
cls
,
schema_code
):
""" Return schema from schema code """
if
not
cls
.
schema_exist
(
schema_code
):
return
None
return
cls
.
schema_dict
[
schema_code
][
'schema_instance'
]
@
classmethod
def
schema_info_list
(
cls
):
""" Computes and return schema info list """
return
[
cls
.
schema_info
(
code
)
for
code
in
sorted
(
cls
.
schema_dict
.
keys
())]
@
classmethod
def
validate
(
cls
,
schema_url
,
**
options
):
"""Validate"""
return
cls
.
validator
.
validate
(
schema
=
schema_url
,
**
options
)
validata_ui/views.py
View file @
a5effda7
...
...
@@ -25,7 +25,6 @@ import tabulator
from
.
import
app
,
config
from
.ui_util
import
flash_error
,
flash_warning
from
.validata_util
import
ValidataSource
from
.validate_helper
import
ValidatorHelper
MonkeyPatch
.
patch_fromisoformat
()
...
...
@@ -326,7 +325,6 @@ def bytes_data(f):
@
app
.
route
(
'/'
)
def
home
():
""" Home page """
validators
=
ValidatorHelper
.
schema_info_list
()
external_validators
=
[
{
"title"
:
"INSPIRE"
,
...
...
@@ -345,7 +343,7 @@ def home():
},
]
flash_warning
(
'Ce service est fourni en mode beta - certains problèmes peuvent subsister - nous mettons tout en œuvre pour améliorer son fonctionnement en continu.'
)
return
render_template
(
'home.html'
,
title
=
'Accueil'
,
validators
=
validators
,
external_validators
=
external_validators
)
return
render_template
(
'home.html'
,
title
=
'Accueil'
,
validators
=
[]
,
external_validators
=
external_validators
)
@
app
.
route
(
'/validators'
)
...
...
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