fix: Better validation for taxonomy files

pull/256/head
Jakub Onderka 2022-09-25 17:06:00 +02:00
parent c7a13ea0bc
commit ac93571dbc
2 changed files with 19 additions and 6 deletions

18
validate_all.py Normal file
View File

@ -0,0 +1,18 @@
import sys
import glob
import json
from jsonschema import validate
schema = json.load(open("schema.json", "r"))
for taxonomy_file in glob.glob('./*/machinetag.json'):
print("Checking {}".format(taxonomy_file))
taxonomy = json.load(open(taxonomy_file, "r"))
validate(instance=taxonomy, schema=schema)
if "values" in taxonomy:
predicates = [predicate["value"] for predicate in taxonomy["predicates"]]
for value in taxonomy["values"]:
if value["predicate"] not in predicates:
print("ERROR: Predicate `{}` is missing".format(value["predicate"]))
sys.exit(1)

View File

@ -20,11 +20,6 @@ if ! [ $((directories-2)) -eq $manifest_entries ]; then
exit 1 exit 1
fi fi
for dir in */machinetag.json python3 validate_all.py
do
echo -n "${dir}: "
jsonschema -i ${dir} schema.json
echo ''
done
jsonschema -i mapping/mapping.json schema_mapping.json jsonschema -i mapping/mapping.json schema_mapping.json