Improve json_verifier script

This commit is contained in:
Tad Hardesty
2019-07-03 02:01:29 -07:00
parent 504b5e61ed
commit b57eff9ecc
2 changed files with 11 additions and 10 deletions

View File

@@ -4,16 +4,17 @@ import json
if len(sys.argv) <= 1:
exit(1)
files = filter(len, sys.argv[1].split('\n'))
msg = []
for file in files:
status = 0
for file in sys.argv[1:]:
with open(file, encoding="ISO-8859-1") as f:
try:
json.load(f)
except ValueError as exception:
msg.append("JSON synxtax error on file: {}".format(file))
msg.append(str(exception))
if msg:
print("\n".join(msg))
exit(1)
exit(0)
print("JSON error in {}".format(file))
print(exception)
status = 1
else:
print("Valid {}".format(file))
exit(status)

View File

@@ -6,6 +6,6 @@ python3 tools/ss13_genchangelog.py html/changelog.html html/changelogs
find . -name "*.php" -print0 | xargs -0 -n1 php -l
find . -name "*.json" -not -path "./tgui/node_modules/*" | xargs -0 python3 ./tools/json_verifier.py
find . -name "*.json" -not -path "./tgui/node_modules/*" -print0 | xargs -0 python3 ./tools/json_verifier.py
(cd tgui && source ~/.nvm/nvm.sh && npm ci && node node_modules/gulp/bin/gulp.js --min)