File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import json
66import os
77import progressbar
8+ import sys
89
9- from jsonschema import validate
10+ from jsonschema import validate , ValidationError
1011
1112with open ("../game-schema-d4.json" ) as f :
1213 schema = json .load (f )
1314
1415path = "../entries/"
1516games_list = os .listdir (path )
1617n = 0
17-
18+ errors = 0
1819
1920for game in progressbar .progressbar (games_list , redirect_stdout = True ):
2021 n += 1
2122 print (f"Validating { game } .." )
2223 with open (f"../entries/{ game } /game.json" ) as f :
23- game = json .load (f )
24- validate (game , schema )
24+ game_metadata = json .load (f )
25+ try :
26+ validate (game_metadata , schema )
27+ except ValidationError as e :
28+ errors += 1
29+ print (f"Failed { game } : \n { e } " )
30+
31+ if errors > 0 :
32+ print (f"\n { errors } entrie(s) have failed validation" )
33+ sys .exit (1 )
You can’t perform that action at this time.
0 commit comments