diff options
| author | Koro4e <96347170+Koro4e@users.noreply.github.com> | 2026-11-23 17:00:20 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-23 10:00:20 -0600 |
| commit | b66e184ebe9e6c12f6fa60faf2cf32e042d8cd2a (patch) | |
| tree | 104194338b1096e11ef9a680347b25f0204f4cb7 /tools/batch_glb.py | |
| parent | d8e8f23b975b6c7d383125ace7378cba3dbffe38 (diff) | |
batch_glb: --textures must name a directory (#6747)
Squash-merged after diff review of PR #6747 - batch_glb: --textures must name a directory
Diffstat (limited to 'tools/batch_glb.py')
| -rw-r--r-- | tools/batch_glb.py | 11 |
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 | |||
| 28 | import dds_png | 28 | import dds_png |
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | def _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 | |||
| 31 | def _build_texture_index(texture_dir: str | None) -> dict[str, str]: | 38 | def _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 | ) |