feat: harden CAD showcase skill and delivery pipeline
This commit is contained in:
@@ -9,6 +9,8 @@ import shutil
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import showcase_schema
|
||||
|
||||
|
||||
def default_template() -> Path:
|
||||
return Path(__file__).resolve().parents[1] / "assets" / "web-showcase-template"
|
||||
@@ -63,6 +65,10 @@ def load_variants(manifest_path: Path | None) -> tuple[dict | None, list[dict]]:
|
||||
if not manifest_path.exists():
|
||||
raise SystemExit(f"Variants manifest not found: {manifest_path}")
|
||||
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
||||
try:
|
||||
showcase_schema.validate_manifest(manifest)
|
||||
except showcase_schema.ValidationFailure as exc:
|
||||
raise SystemExit(str(exc)) from exc
|
||||
variants = list(manifest.get("variants", []))
|
||||
if not variants:
|
||||
raise SystemExit(f"Variants manifest has no variants: {manifest_path}")
|
||||
@@ -101,7 +107,9 @@ def copy_variant_assets(manifest_path: Path | None, variants: list[dict], out_di
|
||||
return web_variants
|
||||
|
||||
|
||||
def inferred_default_glb(args_glb: str | None, manifest_path: Path | None, manifest: dict | None, variants: list[dict]) -> Path:
|
||||
def inferred_default_glb(
|
||||
args_glb: str | None, manifest_path: Path | None, manifest: dict | None, variants: list[dict]
|
||||
) -> Path:
|
||||
if args_glb:
|
||||
return Path(args_glb)
|
||||
variant = default_variant(manifest, variants)
|
||||
@@ -111,7 +119,9 @@ def inferred_default_glb(args_glb: str | None, manifest_path: Path | None, manif
|
||||
return resolve_manifest_path(manifest_path, source_value) if manifest_path else Path(source_value)
|
||||
|
||||
|
||||
def inferred_metadata(args_metadata: str | None, manifest_path: Path | None, manifest: dict | None, variants: list[dict]) -> Path:
|
||||
def inferred_metadata(
|
||||
args_metadata: str | None, manifest_path: Path | None, manifest: dict | None, variants: list[dict]
|
||||
) -> Path:
|
||||
if args_metadata:
|
||||
return Path(args_metadata)
|
||||
variant = default_variant(manifest, variants)
|
||||
@@ -131,16 +141,19 @@ def site_trees_from_spec(spec_path: Path | None) -> list[list[float]]:
|
||||
if not spec_path or not spec_path.exists():
|
||||
return []
|
||||
try:
|
||||
spec = json.loads(spec_path.read_text(encoding="utf-8"))
|
||||
spec = showcase_schema.normalize_spec(json.loads(spec_path.read_text(encoding="utf-8")))
|
||||
except (OSError, json.JSONDecodeError):
|
||||
return []
|
||||
showcase_schema.validate_spec(spec)
|
||||
trees = []
|
||||
for floor in spec.get("floors", {}).values():
|
||||
for seg in floor.get("segments", {}).get("trees", []):
|
||||
trees.append([
|
||||
round((seg["start"][0] + seg["end"][0]) / 2, 2),
|
||||
round((seg["start"][1] + seg["end"][1]) / 2, 2),
|
||||
])
|
||||
trees.append(
|
||||
[
|
||||
round((seg["start"][0] + seg["end"][0]) / 2, 2),
|
||||
round((seg["start"][1] + seg["end"][1]) / 2, 2),
|
||||
]
|
||||
)
|
||||
return trees
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user