spaCy/.github/validate_universe_json.py
Jette16 78365452d3
Moved test for universe into .github folder (#9447)
* Moved universe-test into .github folder

* Cleaned code

* CHanged a file name
2021-10-13 14:13:06 +02:00

20 lines
506 B
Python

import json
import re
import sys
from pathlib import Path
def validate_json(document):
universe_file = Path(document)
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"
if __name__ == "__main__":
validate_json(str(sys.argv[1]))