Repository navigation
tex_export: report a bad index and an --out that is a file - #1632
Conversation
|
Tested ec5c4e9 on Linux 6.8 (Python 3.12.3, numpy 2.5.5, Pillow 13.0.0, CPU only): pass.
Two
Catching One note on the message: for a row without a key the line reads AI-assisted review. |
texs.sort() raised AttributeError on a non-list index and FileExistsError came from os.makedirs when --out was an existing file, both as tracebacks after argparse. Read the index as one ERROR line with exit 2 when its shape is wrong, and reject a file --out before creating anything. main() now returns 0 explicitly so the CLI contract is testable.
ec5c4e9 to
453798c
Compare
|
Thanks @josevictorp ??both follow-ups from your review are now in, on the rebased head
|
Validate --out right after parsing arguments: a file, a path under a file, a dangling symlink or an unmapped drive root is now one argparse error line with exit 2, instead of a FileExistsError/NotADirectoryError traceback, and before --merge or os.makedirs can write anything. Matches the guards in shader_disasm.py (#1607) and tex_export.py (#1632). Add subprocess tests for those paths and a control that a new output folder with missing parents still translates. CPU-only; no game data.
Claimed in the coordination issue as: #1548 (comment)
What and why
Tracebacks from user input in
tools/tex_export.pyon main (hand-built index and carve folder, CPU only, no game files):{"files": []}) ->AttributeError: 'dict' object has no attribute 'sort'attexs.sort(...); a row withoutarchive/gpufails the same way from the sort key;--outnaming an existing file ->FileExistsErrorfromos.makedirs(a.out, exist_ok=True)(the class shader_disasm.py: report an --out that is a file as one ERROR line #1607 fixed inshader_disasm.py).Fixes:
ERROR: cannot read <index>: ...line with exit 2 before any work ??non-list, a row withoutarchive/gpu(row has no 'archive'), and a non-string/non-int sort key;--outthat exists as a file is rejected before creating anything;os.makedirs()failures (a report path under an existing file, a dangling symlink) are oneERROR: cannot create <out>: ...line with exit 2 instead of a traceback.Rebased onto current
main(a0acd33d), which now contains #1615's line-ending change in this file and #1062's--pngoption; both are kept and their tests still pass.Tested
pytest tests/test_tex_export.py -q-> 120 passed, 1 skipped (the dangling-symlink test skips where symlinks cannot be created).maina0acd33din a separate worktree -> 4 failed, exactly the new guard cases.--outunder an existing file exits 2 with oneERROR: cannot create ...line; an empty-list index still exits 0 and writesexport_log.json.python -m compileall -q tools/tex_export.pyandgit diff --checkclean.CPU only, no game data.
AI-assisted.
Checklist
docs/design.md??not applicable.