gamedata_xml: write CSV/JSON reports atomically and sort walk subdirs #921

Open
github-bot wants to merge 1 commit from github-bot/gh-921 into main AGit
Owner

@⁠narekshaghoyandev on GitHub · 2026-11-24 15:11 UTC · original
narekshaghoyandev:ubiq-gamedata-xml-atomic-and-order → main · +117 −8 · 2 files · 1 commits · open

Summary

  • Write --csv and --json reports in tools/gamedata_xml.py atomically 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.
  • Extract write_json() with allow_nan=False and a trailing newline.
  • Sort dirs in place inside xml_files() so recursive directory walks visit subdirectories in deterministic order regardless of filesystem readdir order.
  • Accept an optional argv=None parameter in main(argv=None).

Verification

  • python3 -I tests/test_gamedata_xml.py -v — 18/18 pass (4 new regression tests).
  • Negative control against 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)

**@⁠narekshaghoyandev** on GitHub · 2026-11-24 15:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/921) `narekshaghoyandev:ubiq-gamedata-xml-atomic-and-order` → `main` · +117 −8 · 2 files · 1 commits · open ## Summary - Write `--csv` and `--json` reports in `tools/gamedata_xml.py` atomically 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. - Extract `write_json()` with `allow_nan=False` and a trailing newline. - Sort `dirs` in place inside `xml_files()` so recursive directory walks visit subdirectories in deterministic order regardless of filesystem `readdir` order. - Accept an optional `argv=None` parameter in `main(argv=None)`. ## Verification - `python3 -I tests/test_gamedata_xml.py -v` — 18/18 pass (4 new regression tests). - Negative control against `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)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:28:20 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 21:25 UTC · original

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

**@⁠PierreEbele** on GitHub · 2026-11-25 21:25 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/921#issuecomment-7175066464) 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
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/921/head:github-bot/gh-921'
git switch 'github-bot/gh-921'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-921'
git switch 'github-bot/gh-921'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-921'
git switch 'github-bot/gh-921'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-921'
git switch 'main'
git merge --squash 'github-bot/gh-921'
git switch 'main'
git merge --ff-only 'github-bot/gh-921'
git switch 'main'
git merge 'github-bot/gh-921'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.