2021-09-23 15:31:42 +03:00
|
|
|
import json
|
|
|
|
import re
|
2021-10-13 15:13:06 +03:00
|
|
|
import sys
|
2021-09-23 15:31:42 +03:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
2021-10-13 15:13:06 +03:00
|
|
|
def validate_json(document):
|
|
|
|
universe_file = Path(document)
|
2021-09-23 15:31:42 +03:00
|
|
|
with universe_file.open() as f:
|
|
|
|
universe_data = json.load(f)
|
|
|
|
for entry in universe_data["resources"]:
|
|
|
|
if "github" in entry:
|
|
|
|
assert not re.match(
|
|
|
|
r"^(http:)|^(https:)", entry["github"]
|
|
|
|
), "Github field should be user/repo, not a url"
|
2021-10-13 15:13:06 +03:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
validate_json(str(sys.argv[1]))
|