Skip to content

Commit

Permalink
Merge branch 'CarlosBergillos:main' into hk/add-timeline-edits-schema
Browse files Browse the repository at this point in the history
  • Loading branch information
hossain-khan authored Mar 23, 2024
2 parents 57466af + 0863d2d commit 86c70f5
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 16 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Test Schemas

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python runtime
uses: actions/setup-python@v4
with:
python-version: 3.10.2

- name: Build and test
run: |
pip install -r requirements.txt
make clean
make build
4 changes: 2 additions & 2 deletions docs/guides/general-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ From here, the most relevant files and folders are:


[Google Takeout]: https://takeout.google.com/settings/takeout
[Raw Location History Data]: raw_location.md
[Semantic Location History Data]: semantic_location.md
[Raw Location History Data]: raw-location.md
[Semantic Location History Data]: semantic-location.md
[Records.json]: ../reference/records.md
[Settings.json]: ../reference/settings.md
2 changes: 1 addition & 1 deletion docs/guides/raw-location.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ From this, the most essential fields are:

For more information on the other possible fields see the full [format definition][Location Record].

[General Structure]: general_structure.md
[General Structure]: general-structure.md
[Location Record]: ../reference/records.md#location-record
[ISO 8601]: https://en.wikipedia.org/wiki/ISO_8601
[UTC]: https://en.wikipedia.org/wiki/Coordinated_Universal_Time
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
attrs==21.4.0
certifi==2022.12.7
certifi==2023.7.22
charset-normalizer==2.0.12
click==8.1.2
colorama==0.4.6
commonmark==0.9.1
ghp-import==2.0.2
gitdb==4.0.9
GitPython==3.1.31
GitPython==3.1.41
hypothesis==6.45.0
idna==3.4
importlib-metadata==4.11.3
Jinja2==3.0.3
Jinja2==3.1.3
json-source-map==1.0.1
Markdown==3.3.6
MarkupSafe==2.1.1
Expand All @@ -35,6 +35,6 @@ smmap==5.0.0
sortedcontainers==2.4.0
tabulate==0.8.9
termcolor==1.1.0
urllib3==1.26.15
urllib3==1.26.18
watchdog==2.1.7
zipp==3.8.0
7 changes: 5 additions & 2 deletions tools/jsonschema_to_md/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ def main():
JSONSchemaRenderer(logger=None).render_md(inp, out, title=title)
except (JSONSchemaError, ValidationError) as e:
logger.error(e)
return 1
except Exception as e:
logger.exception(e)

return 1
else:
return 0

if __name__ == "__main__":
main()
raise SystemExit(main())
13 changes: 6 additions & 7 deletions tools/jsonschema_to_md/schema_to_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,19 @@ def __init__(self, logger=None):
logging.basicConfig(level=logging.NOTSET, format="%(message)s", datefmt="[%X]")
self.logger = logging.getLogger(__name__)

def _validate_schema(self, schema):
required_fields = ["type", "title", "description"]

def _validate_schema(self, schema, required_fields=["type", "title", "description"]):
for field in required_fields:
if getattr(schema, field) is None:
raise ValidationError(field, schema)

if schema.type == "array":
if not schema.item_schema:
raise ValidationError("items", schema)

for field in required_fields:
if getattr(schema.item_schema, field) is None:
raise ValidationError(field, schema.item_schema)

if schema.item_schema.type == "object":
self._validate_schema(schema.item_schema)
else:
self._validate_schema(schema.item_schema, required_fields=["type"])

def _example_text(self, example, simple=False):
def json_text(d, simple):
Expand Down

0 comments on commit 86c70f5

Please sign in to comment.