File tree 2 files changed +17
-8
lines changed
2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change 10
10
import numbers
11
11
import re
12
12
import sys
13
+ import json
13
14
14
15
import jsonschema
15
16
import intervals as I
@@ -332,3 +333,16 @@ def are_intervals_mergable(i1, i2):
332
333
return i1 .overlaps (i2 ) \
333
334
or (is_num (i1 .lower ) and is_num (i2 .upper ) and i1 .lower - i2 .upper == 1 ) \
334
335
or (is_num (i2 .lower ) and is_num (i1 .upper ) and i2 .lower - i1 .upper == 1 )
336
+
337
+
338
+ def load_json_file (path , msg = None ):
339
+ with open (path , "r" ) as fh :
340
+ try :
341
+ return json .load (fh )
342
+ except Exception as e :
343
+ if msg :
344
+ print (msg , e )
345
+ sys .exit (1 )
346
+ else :
347
+ print (e )
348
+ sys .exit (1 )
Original file line number Diff line number Diff line change 3
3
@author: Andrew Habib
4
4
'''
5
5
6
- import json
7
- import jsonref
8
6
import sys
9
7
8
+ from jsonsubschema ._utils import load_json_file
10
9
from jsonsubschema .api import isSubschema
11
10
12
11
@@ -18,12 +17,8 @@ def main():
18
17
s1_file = sys .argv [1 ]
19
18
s2_file = sys .argv [2 ]
20
19
21
- with open (s1_file , 'r' ) as f1 :
22
- s1 = json .load (f1 )
23
- # s1 = jsonref.load(f1)
24
- with open (s2_file , 'r' ) as f2 :
25
- s2 = json .load (f2 )
26
- # s2 = jsonref.load(f2)
20
+ s1 = load_json_file (s1_file , "LHS file:" )
21
+ s2 = load_json_file (s2_file , "RHS file:" )
27
22
28
23
print ("LHS <: RHS" , isSubschema (s1 , s2 ))
29
24
print ("RHS <: LHS" , isSubschema (s2 , s1 ))
You can’t perform that action at this time.
0 commit comments