gamedata_xml: write CSV/JSON reports atomically and sort walk subdirs #921
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/921"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by narekshaghoyandev on 2026-11-24T15:11:53Z.
Summary
--csvand--jsonreports intools/gamedata_xml.pyatomically via a staging temp file in the destination folder (file_mode.published_mode+replace_retry.replace), cleaning up staging files (including read-only ones) on failure so an existing report is never clobbered or truncated.write_json()withallow_nan=Falseand a trailing newline.dirsin place insidexml_files()so recursive directory walks visit subdirectories in deterministic order regardless of filesystemreaddirorder.argv=Noneparameter inmain(argv=None).Verification
python3 -I tests/test_gamedata_xml.py -v— 18/18 pass (4 new regression tests).main: all 4 new tests fail before the patch and pass after.python3 -I -m py_compile tools/gamedata_xml.py tests/test_gamedata_xml.py— pass.python3 -I scripts/check_no_game_data.py tools/gamedata_xml.py tests/test_gamedata_xml.py— clean.Claimed in the coordination issue as: BUILD-GAMEDATA-XML-ATOMIC-AND-ORDER
AI-assisted: yes (Gemini)
Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T21:25:52Z.
Reviewed
1fef9b9: staged atomic writes match the file_mode/replace_retry pattern of the other report writers, and os.fdopen names newline="" so BUILD-468 passes. I ran tests/test_gamedata_xml.py plus the report-path/line-ending suites on both trees: 18/18 on the PR; the 4 new tests fail on main, so they cover the fix. End-to-end probe: sorted walk and trailing JSON newline on the PR, raw readdir order and no LF on main; no .tmp leftovers, report mode preserved on both. No findings. AI-assisted review.Recommendation: Merge
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T22:08:33Z.
Native Windows 11 NTFS Verification (
1fef9b9f5c)Verified
1fef9b9f5c85d3dc702b83d09a24961c5dff1d30merged cleanly ontoorigin/main(c7753ed98a56677f10e34078b37eab0540e190ec,git merge-tree --write-treerc=0) on native Windows 11 (26200) + NTFS:origin/mainc7753ed98a):python -I tests/test_gamedata_xml.pyfailed (FAILED (failures=1, errors=3, skipped=1)out of18).origin/main + 1fef9b9f5c):python -I tests/test_gamedata_xml.py:18 ran, OK (skipped=1)(atomic CSV/JSON writes,allow_nan=Falserejection, trailing LF, in-placedirs.sort(), and explicitargvsupport).stat.S_IREADprobe: Rangamedata_xml.maintargeting read-onlyout.csvandout.json(stat.S_IREADon NTFS): both returnedrc=2with zero secondaryunlinkerrors (os.chmod(tmp_path, 0o600)clearedFILE_ATTRIBUTE_READONLYfirst), left0.gamedata_xml-*.tmpstaged files, and preserved both read-only files byte-for-byte.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T01:31:27Z.
Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main
53b77df14: red 1 failure + 3 errors (test_main_accepts_explicit_argv,test_write_csv_and_json_preserve_existing_on_replace_failure,test_write_json_rejects_nan_and_ends_with_newline,test_xml_files_sorts_subdirectories_in_place) / green 18 OK.1fef9b9f5,python -I tests/test_gamedata_xml.pyfrom the repository root.test_main_accepts_explicit_argv:TypeError: main() takes 0 positional arguments but 1 was given;test_write_csv_and_json_preserve_existing_on_replace_failure:AttributeError: ... no attribute 'replace_retry';test_write_json_rejects_nan_and_ends_with_newline:AttributeError: ... no attribute 'write_json';test_xml_files_sorts_subdirectories_in_place:AssertionError: Lists differ(subdirectories left unsorted). MEASURED, failing test(s) alone 3 runs, 3/3 fail.git merge --no-ffof this PR, no conflict): 18 run, OK, 0 skips. MEASURED, the same test(s) alone 3/3 pass.test_a_real_unlistable_folder_fails_the_scan(POSIX, non-root) runs and passes on both sides, and the PR's POSIXchmod 0o444blocks run on macOS.Red = main + only the test files from this PR (
git checkout pr-921 -- tests/test_gamedata_xml.py); green = main + the merged PR. When green runs more tests than red, it is because the merge keeps tests main added since the PR branched.AI-assisted: Claude Code (Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T01:35:58Z.
Merged after OreoFR's red/green check (check) (macOS 27.2.1, Apple M5, Python 3.12) and a local re-check here. Merged after local re-verification: this PR merged onto
mainecb0a4a49without conflict, and its test file(s) (tests/test_gamedata_xml.py) pass there. Earlier today the same tests failed onmainwithout the PR (red/green) and a bundle with other open PRs showed no new failures.check_no_game_data.pyis clean. Windows 11, Python 3.14; no GPU needed for these tests.AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.