aboutsummaryrefslogtreecommitdiffstats
path: root/JSONSchema/validate.py
blob: 086abfa93bfa34ed355188f305639e925d125682 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#! /bin/env python

import glob, json, sys, jsonschema

with open('JSONSchema/schema.json') as schema_data:
    schema = json.load(schema_data)

#for filename in glob.glob('GeneralStateTests/*.json'):
#    print(filename)

while True:
    line = sys.stdin.readline()
    if not line:
        if success:
            sys.exit(0)
        else:
            sys.exit(-1)

    line = line.strip('\n')
    with open(line) as test_data:
        test = json.load(test_data)

        try:
            jsonschema.validate(test, schema)
        except jsonschema.exceptions.ValidationError as e:
            success = False
            print(line+':\n\n')
            print(e)
            print('\n')