2021-09-23 12:31:42 +00:00
|
|
|
import json
|
|
|
|
import re
|
2021-10-13 12:13:06 +00:00
|
|
|
import sys
|
2021-09-23 12:31:42 +00:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
2021-10-13 12:13:06 +00:00
|
|
|
def validate_json(document):
|
|
|
|
universe_file = Path(document)
|
2021-09-23 12:31:42 +00: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 12:13:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
validate_json(str(sys.argv[1]))
|