File tree 4 files changed +39
-3
lines changed
4 files changed +39
-3
lines changed Original file line number Diff line number Diff line change 19
19
20
20
if [ -n " $TEST_STAGE " ]
21
21
then
22
- build-scripts/lint-json.sh
22
+ build-scripts/validate_json.py
23
23
make style-all-json-parallel RELEASE=1
24
24
25
25
tools/dialogue_validator.py data/json/npcs/* data/json/npcs/* /* data/json/npcs/* /* /*
Original file line number Diff line number Diff line change 19
19
20
20
if [ -n " $TEST_STAGE " ]
21
21
then
22
- build-scripts/lint-json.sh
22
+ build-scripts/validate_json.py
23
23
make style-all-json-parallel RELEASE=1
24
24
25
25
tools/dialogue_validator.py data/json/npcs/* data/json/npcs/* /* data/json/npcs/* /* /*
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+
3
+ # Validate that all JSON files are syntactically correct;
4
+ # does NOT check indentation styles.
5
+
6
+ import glob
7
+ import json
8
+ import sys
9
+
10
+
11
+ def main ():
12
+ json_files = glob .glob ('**/**.json' , recursive = True )
13
+ errors = 0
14
+ total = 0
15
+ for file_path in json_files :
16
+ if not file_path .startswith ("android/app/src/main/assets" ):
17
+ total += 1
18
+ try :
19
+ with open (file_path , encoding = "utf-8" ) as fp :
20
+ _ = json .load (fp )
21
+ except OSError as e :
22
+ print ("Error opening {}: {}" .format (file_path , e ))
23
+ errors += 1
24
+ except json .JSONDecodeError as e :
25
+ print ("Error parsing {}: {}" .format (file_path , e ))
26
+ errors += 1
27
+ if errors == 0 :
28
+ print ("All {} JSON files healthy." .format (total ))
29
+ return 0
30
+ else :
31
+ print ("Found {} erroneous files among {} JSON files in the repository."
32
+ .format (errors , total ))
33
+ return min (errors , 255 )
34
+
35
+
36
+ if __name__ == '__main__' :
37
+ sys .exit (main ())
You can’t perform that action at this time.
0 commit comments