Skip to content

Commit 99a0969

Browse files
authored
Fix schema_app forcing the creation of a schemas/ dir (#254)
Fix schema_app forcing the creation of a schemas/ dir when running any part of the app
1 parent 7974e79 commit 99a0969

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/techui_builder/schema_generator.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import logging
23
from pathlib import Path
34

45
import typer
@@ -9,7 +10,8 @@
910
)
1011

1112
SCHEMAS_DIR = Path("schemas")
12-
SCHEMAS_DIR.mkdir(exist_ok=True)
13+
14+
logger_ = logging.getLogger(__name__)
1315

1416
app = typer.Typer(context_settings={"allow_interspersed_args": True})
1517

@@ -26,6 +28,13 @@ def write_json_schema(model_name: str, schema_dict: dict) -> None:
2628
invoke_without_command=True,
2729
)
2830
def schema_generator() -> None:
31+
if not SCHEMAS_DIR.exists():
32+
try:
33+
SCHEMAS_DIR.mkdir()
34+
except OSError:
35+
logger_.critical("Unable to make schemas dir.")
36+
exit()
37+
2938
# techui
3039
tu = TechUi.model_json_schema()
3140
write_json_schema("techui", tu)

0 commit comments

Comments
 (0)