Commit 6fd32a87 authored by Pierre Dittgen's avatar Pierre Dittgen

custom_checks -> goodtables_checks, rename validate.py

parent 4a8efa2b
......@@ -3,13 +3,13 @@ from pathlib import Path
from flask import Flask
from validata_ui_next.validate import ValidatorHelper
from validata_ui_next.validate_helper import ValidatorHelper
# Schemas settings
schemas_config = {
"scdl-adresses": {
"schema_json_url": "https://git.opendatafrance.net/scdl/adresses/raw/master/schema-scdl-adresses.json",
"custom_checks_json_url": "https://git.opendatafrance.net/scdl/adresses/raw/master/goodtables-checks.json",
"goodtables_checks_json_url": "https://git.opendatafrance.net/scdl/adresses/raw/master/goodtables-checks.json",
"title": "Adresses locales",
"description": "Liste des adresses locales d'une collectivité",
"specurl": "http://www.opendatafrance.net/SCDL_Adresses_Locales",
......@@ -28,7 +28,7 @@ schemas_config = {
},
"scdl-deliberations": {
"schema_json_url": "https://git.opendatafrance.net/scdl/deliberations/raw/master/schema.json",
"custom_checks_json_url": "https://git.opendatafrance.net/scdl/deliberations/raw/master/goodtables-checks.json",
"goodtables_checks_json_url": "https://git.opendatafrance.net/scdl/deliberations/raw/master/goodtables-checks.json",
"title": "Délibérations",
"description": "Liste des délibérations adoptées par une assemblée locale",
"specurl": "http://www.opendatafrance.net/SCDL_Deliberations",
......@@ -47,7 +47,7 @@ schemas_config = {
},
"scdl-marches-publics": {
"schema_json_url": "https://git.opendatafrance.net/scdl/marches-publics/raw/v1.2/schema.json",
"custom_checks_json_url": "https://git.opendatafrance.net/scdl/marches-publics/raw/v1.2/goodtables-checks.json",
"goodtables_checks_json_url": "https://git.opendatafrance.net/scdl/marches-publics/raw/v1.2/goodtables-checks.json",
"title": "Marchés publics",
"description": "Liste des marchés publics attribués par une collectivité",
"specurl": "http://www.opendatafrance.net/SCDL_Marches_Publics",
......@@ -65,7 +65,7 @@ schemas_config = {
},
"scdl-prenoms": {
"schema_json_url": "https://github.com/Jailbreak-Paris/liste-prenoms-nouveaux-nes/raw/v1.1.3/prenom-schema.json",
"custom_checks_json_url": "https://github.com/Jailbreak-Paris/liste-prenoms-nouveaux-nes/raw/v1.1.3/goodtables-checks.json",
"goodtables_checks_json_url": "https://github.com/Jailbreak-Paris/liste-prenoms-nouveaux-nes/raw/v1.1.3/goodtables-checks.json",
"title": "Prénoms des nouveaux-nés",
"description": "Liste des prénoms des nouveaux-nés déclarés à l'état-civil",
"specurl": "https://docs.google.com/document/d/1Vk0kpBw3MIocai9JqovLK2HxcUA_3QHnZicqxuOpcQ8/edit?usp=sharing",
......@@ -83,7 +83,7 @@ schemas_config = {
},
"scdl-subventions": {
"schema_json_url": "https://git.opendatafrance.net/scdl/subventions/raw/master/schema.json",
"custom_checks_json_url": "https://git.opendatafrance.net/scdl/subventions/raw/master/goodtables-checks.json",
"goodtables_checks_json_url": "https://git.opendatafrance.net/scdl/subventions/raw/master/goodtables-checks.json",
"title": "Subventions",
"description": "Liste des subventions publiques attribuées par une collectivité",
"specurl": "http://www.opendatafrance.net/SCDL_Subventions",
......
......@@ -36,9 +36,9 @@ class ValidatorHelper:
'{}_schema.json'.format(code))
# custom_checks
if 'custom_checks_json_url' in schema:
schema['custom_checks'] = cls.json_download(schema['custom_checks_json_url'],
'{}_custom_checks.json'.format(code))
if 'goodtables_checks_json_url' in schema:
schema['goodtables_checks'] = cls.json_download(schema['goodtables_checks_json_url'],
'{}_goodtables_checks.json'.format(code))
cls.schema_dict[code] = schema
@classmethod
......@@ -74,7 +74,7 @@ class ValidatorHelper:
# 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') and not k.startswith('custom_checks')}
if not k.startswith('schema') and not k.startswith('goodtables_checks')}
return {**d1, 'code': schema_code, **d2}
......@@ -93,8 +93,8 @@ class ValidatorHelper:
# Build checks configuration
checks = ['structure', 'schema']
pre_checks_conf = None
if 'custom_checks' in sc_info:
c_checks = sc_info['custom_checks']
if 'goodtables_checks' in sc_info:
c_checks = sc_info['goodtables_checks']
if 'custom_checks' in c_checks:
for check_conf in c_checks['custom_checks']:
checks.append({check_conf['name']: check_conf['params']})
......
......@@ -9,7 +9,7 @@ from pathlib import Path
from validata_ui_next import app
from validata_ui_next.util import flash_error, flash_info, flash_success, flash_warning
from validata_ui_next.validate import ValidatorHelper
from validata_ui_next.validate_helper import ValidatorHelper
from flask import Flask, jsonify, redirect, render_template, request, url_for
import tabulator
......@@ -18,7 +18,6 @@ import tabulator
def compute_source_preview(source, max_rows=5):
""" Computes table preview """
header = None
nb_rows = 0
rows = []
with tabulator.Stream(source) as stream:
for row in stream:
......
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