Prettier-print the generated config schema

This commit is contained in:
Danielle McLean 2024-06-22 20:12:50 +10:00
parent 3cb5db7528
commit 2f70c6f7fa
Signed by: 00dani
GPG key ID: 6854781A0488421C

View file

@ -1,6 +1,7 @@
from json import dump from json import dump
from pathlib import Path from pathlib import Path
from pprint import pp from pprint import pp
from shutil import get_terminal_size
from typing import Any, Mapping from typing import Any, Mapping
from apischema import schema, settings from apischema import schema, settings
@ -35,7 +36,7 @@ def write() -> None:
schema_file = Path(__file__).parent / Config.schema.name schema_file = Path(__file__).parent / Config.schema.name
print(f"Writing this schema to {schema_file}") print(f"Writing this schema to {schema_file}")
pp(schema) pp(schema, sort_dicts=True, width=get_terminal_size().columns)
with open(schema_file, "w") as fp: with open(schema_file, "w") as fp:
dump(schema, fp, indent="\t", sort_keys=True) dump(schema, fp, indent="\t", sort_keys=True)
fp.write("\n") fp.write("\n")