bvh_groups: use shared same_report_path and catch --json write OSError #274

Closed
Andretuta wants to merge 1 commit from upstream-pr/274 into main
Andretuta commented 2026-11-24 02:57:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:57:13Z.


Carried over from old PR 10006 by EspadaHD in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/10006, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
EspadaHD: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Claimed in the coordination issue as: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116977803

What and why

tools/bvh_groups.py checked --json against the input archive with a private os.path.exists(...) and os.path.samefile(...) check instead of tools/report_paths.same_report_path (CONTRIBUTING.md), and called write_json_report() in main() without catching OSError (so passing a directory or unwritable path to --json raised an uncaught PermissionError / IsADirectoryError / FileNotFoundError traceback with exit code 1 instead of printing one bvh_groups: error line to stderr and returning exit code 2).

  • Use report_paths.same_report_path(a.json, a.archive) to guard the archive input.
  • Catch OSError around write_json_report() in main(), print bvh_groups: <error> to stderr, and return 2.
  • Add unit tests in tests/test_bvh_groups.py covering same_report_path delegation and --json write OSError handling.

Tested

  • python -I tests/test_bvh_groups.py -v: 16/16 passed (OK)
  • python -I tests/test_report_paths.py: 22 tests (21 passed, 1 skipped: OK (skipped=1))
  • python -m compileall -q tools/bvh_groups.py tests/test_bvh_groups.py: exit 0
  • python -I scripts/check_no_game_data.py tools/bvh_groups.py tests/test_bvh_groups.py: exit 0
  • Environment: Windows, CPU-only standard library tests, no game data, no GPU used.

AI-assisted: yes

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5465223662 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/274). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:57:13Z. --- > Carried over from **old PR 10006** by `EspadaHD` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/10006`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `EspadaHD`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Claimed in the coordination issue as: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116977803 ### What and why `tools/bvh_groups.py` checked `--json` against the input archive with a private `os.path.exists(...) and os.path.samefile(...)` check instead of `tools/report_paths.same_report_path` (CONTRIBUTING.md), and called `write_json_report()` in `main()` without catching `OSError` (so passing a directory or unwritable path to `--json` raised an uncaught `PermissionError` / `IsADirectoryError` / `FileNotFoundError` traceback with exit code 1 instead of printing one `bvh_groups:` error line to `stderr` and returning exit code 2). - Use `report_paths.same_report_path(a.json, a.archive)` to guard the archive input. - Catch `OSError` around `write_json_report()` in `main()`, print `bvh_groups: <error>` to `stderr`, and return `2`. - Add unit tests in `tests/test_bvh_groups.py` covering `same_report_path` delegation and `--json` write `OSError` handling. ### Tested - `python -I tests/test_bvh_groups.py -v`: 16/16 passed (`OK`) - `python -I tests/test_report_paths.py`: 22 tests (`21` passed, `1` skipped: `OK (skipped=1)`) - `python -m compileall -q tools/bvh_groups.py tests/test_bvh_groups.py`: exit 0 - `python -I scripts/check_no_game_data.py tools/bvh_groups.py tests/test_bvh_groups.py`: exit 0 - Environment: Windows, CPU-only standard library tests, no game data, no GPU used. AI-assisted: yes ### Checklist - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
aslan2142 commented 2026-11-24 19:18:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-24T19:18:23Z.


This carry-over of old upstream PR 10006 has been taken over in #931, so I'm closing this draft as #17 describes. The branch old-pr/10006 stays.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7141902991 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/274#issuecomment-7141902991). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-24T19:18:23Z. --- This carry-over of old upstream PR 10006 has been taken over in #931, so I'm closing this draft as #17 describes. The branch `old-pr/10006` stays. AI-assisted (Claude Code, Claude Opus 5.5).

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!274
No description provided.