mirror of
https://github.com/soulaklabs/bitoduc.fr.git
synced 2025-12-08 17:13:23 +00:00
Cela ajoute deux vérifications:
- que les données ont le bon format (anglais, français, classe - genre est
optionnel)
- que les données sont triées par "anglais"
25 lines
585 B
Python
25 lines
585 B
Python
import json
|
|
from jsonschema import validate as valide
|
|
|
|
|
|
def verifie_ordre(mots):
|
|
for (a, b) in zip(mots, mots[1:]):
|
|
mot_a = a['anglais'].lower()
|
|
mot_b = b['anglais'].lower()
|
|
msg = "%s et %s ne sont pas dans le bon ordre" % (mot_a, mot_b)
|
|
assert mot_a < mot_b, msg
|
|
|
|
|
|
def principal():
|
|
with open('traductions.json') as f:
|
|
d = json.load(f)
|
|
with open('schema.json') as f:
|
|
schema = json.load(f)
|
|
valide(d, schema)
|
|
verifie_ordre(d['faux mots'])
|
|
verifie_ordre(d['vrais mots'])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
principal()
|