upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tools/batch_glb.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/batch_glb.py')
-rw-r--r--tools/batch_glb.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/batch_glb.py b/tools/batch_glb.py
index e19f21c66..12f1949a0 100644
--- a/tools/batch_glb.py
+++ b/tools/batch_glb.py
@@ -28,9 +28,16 @@ import glb_writer
28import dds_png 28import dds_png
29 29
30 30
31def _existing_texture_dir(value: str) -> str:
32 """--textures must name a directory: a typo otherwise silently embedded nothing and still exited 0."""
33 if not os.path.isdir(value):
34 raise argparse.ArgumentTypeError(f"not a directory: {value}")
35 return value
36
37
31def _build_texture_index(texture_dir: str | None) -> dict[str, str]: 38def _build_texture_index(texture_dir: str | None) -> dict[str, str]:
32 """Index available texture files (.png and .dds) by lowercase basename without extension.""" 39 """Index available texture files (.png and .dds) by lowercase basename without extension."""
33 if not texture_dir or not os.path.isdir(texture_dir): 40 if not texture_dir:
34 return {} 41 return {}
35 index: dict[str, str] = {} 42 index: dict[str, str] = {}
36 for entry in os.scandir(texture_dir): 43 for entry in os.scandir(texture_dir):
@@ -233,7 +240,7 @@ def main(argv: list[str] | None = None) -> int:
233 ) 240 )
234 parser.add_argument( 241 parser.add_argument(
235 "--textures", 242 "--textures",
236 type=str, 243 type=_existing_texture_dir,
237 default=None, 244 default=None,
238 help="Optional directory containing textures (.png or .dds) to link and embed", 245 help="Optional directory containing textures (.png or .dds) to link and embed",
239 ) 246 )