2023-09-16 11:18:09 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2023-09-15 23:52:04 +00:00
|
|
|
import re
|
2023-10-27 13:33:38 +00:00
|
|
|
import sys
|
2023-09-15 20:55:48 +00:00
|
|
|
from pathlib import Path
|
|
|
|
from pprint import pprint
|
2023-09-15 23:52:04 +00:00
|
|
|
|
2024-02-08 22:57:26 +01:00
|
|
|
# VCMI supports JSON with comments, but not JSON5
|
|
|
|
import jstyleson
|
2023-09-15 23:31:43 +00:00
|
|
|
|
2024-02-08 19:07:15 +01:00
|
|
|
validation_failed = False
|
2023-09-15 20:55:48 +00:00
|
|
|
|
2024-02-08 19:07:15 +01:00
|
|
|
for path in sorted(Path(".").glob("**/*.json"), key=lambda path: str(path).lower()):
|
2023-09-15 20:55:48 +00:00
|
|
|
# because path is an object and not a string
|
|
|
|
path_str = str(path)
|
2024-02-08 19:07:15 +01:00
|
|
|
if path_str.startswith("."):
|
|
|
|
continue
|
|
|
|
|
2023-09-15 20:55:48 +00:00
|
|
|
try:
|
2023-10-27 13:30:35 +00:00
|
|
|
with open(path_str, "r") as file:
|
2024-02-08 22:57:26 +01:00
|
|
|
jstyleson.load(file)
|
2024-02-08 19:07:15 +01:00
|
|
|
print(f"✅ {path_str}")
|
2023-09-15 20:55:48 +00:00
|
|
|
except Exception as exc:
|
2024-02-08 22:57:26 +01:00
|
|
|
print(f"❌ {path_str}: {exc}")
|
2024-02-08 19:07:15 +01:00
|
|
|
validation_failed = True
|
2023-09-15 20:55:48 +00:00
|
|
|
|
2024-02-08 19:07:15 +01:00
|
|
|
if validation_failed:
|
2023-10-27 13:33:38 +00:00
|
|
|
sys.exit(1)
|