Add a script to fetch schemas from mozilla-central
This commit is contained in:
Родитель
afada3f499
Коммит
855e9b11fd
|
@ -2,3 +2,4 @@ jsonschema==3.2.0
|
|||
PyYAML==5.4
|
||||
yamllint==1.21.0
|
||||
pyjexl==0.3.0
|
||||
requests>=2.27.1,<2.28.0
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
#!/usr/bin/env python3
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import requests
|
||||
|
||||
URL_BASE = "https://hg.mozilla.org/mozilla-central/raw-file/tip/"
|
||||
|
||||
SCHEMAS = {
|
||||
# The combined FxMS Mega schema
|
||||
"MessagingExperiment.schema.json": (
|
||||
"browser/components/newtab/content-src/asrouter/schemas/"
|
||||
"MessagingExperiment.schema.json"
|
||||
),
|
||||
# The Nimbus recipe schema
|
||||
"NimbusExperiment.schema.json": (
|
||||
"toolkit/components/nimbus/schemas/NimbusExperiment.schema.json"
|
||||
),
|
||||
# Non-message schemas
|
||||
"SpecialMessageActionSchemas.json": (
|
||||
"toolkit/components/messaging-system/schemas/"
|
||||
"SpecialMessageActionSchemas/SpecialMessageActionSchemas.json"
|
||||
),
|
||||
"message-groups.schema.json": (
|
||||
"browser/components/newtab/content-src/asrouter/schemas/"
|
||||
"message-group.schema.json"
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
session = requests.session()
|
||||
|
||||
for schema, fragment in SCHEMAS.items():
|
||||
path = Path("schema") / schema
|
||||
url = URL_BASE + fragment
|
||||
|
||||
print(f"Fetching {schema} ...")
|
||||
|
||||
with path.open("w") as f, session.get(url) as req:
|
||||
f.write(req.text)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -4,7 +4,6 @@ import json
|
|||
import sys
|
||||
|
||||
import jsonschema
|
||||
|
||||
from jsonschema.exceptions import best_match, ValidationError
|
||||
from pyjexl.jexl import JEXL
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче