1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-30 08:57:00 +02:00
vcmi/CI/validate_json.py
Ivan Savenko ecf063cd1c Reorganized layout of CI directory, move all before_install files into
common directory, remove copy-pasted files
2024-10-14 13:05:10 +00:00

29 lines
661 B
Python
Executable File

#!/usr/bin/env python3
import re
import sys
from pathlib import Path
from pprint import pprint
# VCMI supports JSON with comments, but not JSON5
import jstyleson
validation_failed = False
for path in sorted(Path(".").glob("**/*.json"), key=lambda path: str(path).lower()):
# because path is an object and not a string
path_str = str(path)
if path_str.startswith("."):
continue
try:
with open(path_str, "r") as file:
jstyleson.load(file)
print(f"{path_str}")
except Exception as exc:
print(f"{path_str}: {exc}")
validation_failed = True
if validation_failed:
sys.exit(1)