Commit Graph

19 Commits

Author SHA1 Message Date
1fef9b9f5c gamedata_xml: write CSV/JSON reports atomically and sort walk subdirs 2026-11-24 15:11:09 +00:00
271a3adc88 gamedata_xml: group well-formed documents by their parsed roots (#6880)
Squash-merged after diff review of PR #6880 - gamedata_xml: group valid XML by the root the parser read
2026-11-23 09:47:59 -06:00
9f2078f831 Merge pull request #4370 from DoubleD17
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:14:06 -05:00
329375d5a6 gamedata_xml: exercise the unlistable folder on a real filesystem
The mocked walk test only shows that main's tool never receives onerror. This
adds a POSIX-only test that makes an empty sub-folder mode 000 and runs the scan
as an unprivileged user, so the listing really fails: on WSL2 Ubuntu as nobody
(uid 65534) it fails on main's tool (exit 0, expected 2) and passes with the fix
(13 tests OK). Windows skips it, since a mode change cannot make a folder
unlistable there. Synthetic XML only, no game files.

AI-assisted.
2026-11-22 19:22:20 -06:00
ad4cdaa381 tools: respect markup boundaries in malformed XML comment counts 2026-11-23 01:05:18 +00:00
df4dca0980 gamedata_xml: a folder that cannot be listed fails the scan
xml_files walked a directory of XML documents with os.walk and no onerror, so
an unlistable sub-folder was silently skipped: the scan printed its summary and
exited 0 with fewer documents, and the report-collision check could not see
those files either. Raise the listing error; main already prints one
`ERROR: cannot read ...` line and exits 2 for an OSError.

The new test on main's tool fails (os.walk receives no onerror); with the fix,
tests/test_gamedata_xml.py runs 12 tests, OK. CPU only, synthetic XML, no game
files.

AI-assisted.
2026-11-22 18:31:55 -06:00
2b53a241b1 Merge pull request #3262 from Kacper Serewis 2026-11-22 15:16:17 -05:00
80d6e66cf6 Merge pull request #3179 from Leo Leahy 2026-11-22 15:15:29 -05:00
9f67a32f81 Preserve XML tails cut inside comments and CDATA 2026-11-22 21:00:48 +01:00
d57f1f1d09 gamedata_xml: report crossed tags as malformed in standalone files 2026-11-22 20:56:17 +01:00
e4d9c1387c gamedata_xml: keep opening root on end-truncated XML documents 2026-11-22 16:36:01 -03:00
31fa07db91 Merge pull request #2381 from Vonsek 2026-11-22 13:14:26 -05:00
33636697a0 fix(tools): classify complete headerless carved XML correctly
The lack of an XML declaration is only a heuristic when parsing fails. A successful parse confirms a complete document, including a self-closing root.
2026-11-22 17:51:41 +01:00
b2beba78e7 Merge pull request #2214 from Rafael 2026-11-22 11:42:57 -05:00
c950b735e4 gamedata_xml: count the comments of a document the parser cannot finish
Since 93211578 comments are counted from iterparse "comment" events, which is right for a well-formed
document (comment-like text in CDATA is not a comment). But a truncated or tail-only document stops the
parser at the error, and the comments after it were never counted. When parsing fails, the comment starts
are now counted in the bytes, skipping CDATA sections (an unclosed one runs to the end).

Real data (counts only), the common.rpf carve: --check reports 507 comment starts (412 in 257
declaration-bearing documents), as docs/gamedata.md:471 says; main reported 412 (412). The 95 missing
ones were in 2 truncated tail-only documents.

Tests: test_comments_in_a_document_that_does_not_parse_are_counted (unclosed root, tail-only document,
CDATA closed and cut off; main: the tail-only case gives 0).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:19:36 -03:00
21a0a790ae gamedata_xml.py: catch OSError when writing --csv or --json outputs 2026-11-22 16:35:41 +01:00
937c44407f gamedata_xml.py: tail references survive the parser's buffer boundary, and an unknown encoding is malformed
scan_xml() read each element's tail at its "end" event and then cleared the
element, but iterparse can deliver the end event before the parser has read
the tail, so a $(...) reference after a close tag at a 16 KiB boundary was
lost. The tail is now read at the next event (or after the loop), before the
element is cleared.

An encoding declaration Python doesn't know raised LookupError out of
scan_xml() and ended --check in a traceback. It is now recorded as the
document's error, so the file counts as malformed like any other parse error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 06:35:21 +01:00
9321157890 gamedata_xml.py: count comments from XML parser events 2026-11-22 00:59:52 +01:00
43daf286dc Tools: catalog the common.rpf XML documents 2026-11-21 20:55:43 +00:00