Skip to content

Commit

Permalink
Add support for urls/network documents
Browse files Browse the repository at this point in the history
  • Loading branch information
murithigeo committed Sep 21, 2024
1 parent 9c17b98 commit 8fa1b74
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
jsonschema
exhaust
pytest
pytest
requests
14 changes: 12 additions & 2 deletions tools/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,22 @@ def create_custom_validator(schema_id, schema_store=None):
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--source', type=str, choices=['url', 'file'], default='file', help='Source of the CoverageJSON document')
parser.add_argument('covjson_path', type=str,
help='Path to CoverageJSON document')

args = parser.parse_args()

with open(args.covjson_path, encoding="utf-8") as f:
obj = json.load(f)
if args.source == 'url':
import requests
# Get the file from the URL
response = requests.get(args.covjson_path)
response.raise_for_status() # Raise an exception if the request was unsuccessful
obj = response.json()
else:
# Assume the covjson_path is a local file
with open(args.covjson_path, encoding="utf-8") as f:
obj = json.load(f)

validator = create_custom_validator("/schemas/coveragejson")
validator.validate(obj)
Expand Down

0 comments on commit 8fa1b74

Please sign in to comment.