|
4 | 4 | import importlib.metadata |
5 | 5 | import typing as t |
6 | 6 |
|
7 | | -from check_jsonschema.catalog import SCHEMA_CATALOG |
| 7 | +from check_jsonschema.catalog import CUSTOM_SCHEMA_CATALOG, SCHEMA_CATALOG |
8 | 8 |
|
9 | 9 | version = importlib.metadata.version("check_jsonschema") |
10 | 10 |
|
11 | 11 |
|
12 | 12 | def iter_catalog_hooks(): |
13 | | - for name in SCHEMA_CATALOG: |
14 | | - # copy config (new dict) |
15 | | - config = dict(SCHEMA_CATALOG[name]["hook_config"]) |
16 | | - # set computed attributes |
17 | | - config["schema_name"] = name |
18 | | - config["id"] = f"check-{name}" |
19 | | - config["description"] = ( |
20 | | - config.get("description") |
21 | | - or f"{config['name']} against the schema provided by SchemaStore" |
22 | | - ) |
23 | | - if "types" in config and isinstance(config["types"], str): |
24 | | - config["types"] = [config["types"]] |
25 | | - yield config |
| 13 | + catalogs = ( |
| 14 | + ("vendor", SCHEMA_CATALOG), |
| 15 | + ("custom", CUSTOM_SCHEMA_CATALOG), |
| 16 | + ) |
| 17 | + for schema_namespace, catalog in catalogs: |
| 18 | + for name in catalog: |
| 19 | + # copy config (new dict) |
| 20 | + config = dict(catalog[name]["hook_config"]) |
| 21 | + # set computed attributes |
| 22 | + config["schema_name"] = name |
| 23 | + config["schema_namespace"] = schema_namespace |
| 24 | + config["id"] = f"check-{name}" |
| 25 | + config["description"] = ( |
| 26 | + config.get("description") |
| 27 | + or f"{config['name']} against the schema provided by SchemaStore" |
| 28 | + ) |
| 29 | + if "types" in config and isinstance(config["types"], str): |
| 30 | + config["types"] = [config["types"]] |
| 31 | + yield config |
26 | 32 |
|
27 | 33 |
|
28 | 34 | def update_hook_config(new_config: str) -> None: |
@@ -54,7 +60,7 @@ def generate_hook_lines(config) -> t.Iterator[str]: |
54 | 60 | add_args = " " + add_args |
55 | 61 | yield ( |
56 | 62 | " entry: check-jsonschema --builtin-schema " |
57 | | - f"vendor.{config['schema_name']}{add_args}" |
| 63 | + f"{config['schema_namespace']}.{config['schema_name']}{add_args}" |
58 | 64 | ) |
59 | 65 |
|
60 | 66 | yield " language: python" |
|
0 commit comments