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

custom_checks -> goodtables_checks, rename validate.py

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