-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added translation file json schema and schema validation in workflow
- Loading branch information
1 parent
6b08799
commit 1e31a84
Showing
2 changed files
with
11 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
build-system.requires = ["python_version >= 3.11"] | ||
build-system.requires = ["jsonschema >= 4.20", "python_version >= 3.11"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
from glob import iglob | ||
from tomllib import load, TOMLDecodeError | ||
import tomllib | ||
from jsonschema import validate | ||
import json | ||
|
||
if __name__ == "__main__": | ||
for path in iglob("../../**/*.toml", recursive=True): | ||
with open(path, 'rb') as file: | ||
try: | ||
print(f"Checking {file.name}...") | ||
load(file) | ||
except TOMLDecodeError as e: | ||
data = tomllib.load(file) | ||
|
||
if "translations" in path: | ||
with open("../../schemas/translation.schema.json") as schema: | ||
print(f"Checking translation schema for {file.name}...") | ||
validate(data, json.load(schema)) | ||
except tomllib.TOMLDecodeError as e: | ||
print(e) |