[PR #1820] tools/psin_index: keep first LSNS section and match .bin case-insensitively #1831

Open
opened 2026-11-26 21:19:07 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1820
Author: @kirigayakazima
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/psin-index-lsns-and-case


📝 Commits (1)

  • f12a3f2 tools/psin_index: keep first LSNS section and match .bin case-insensitively

📊 Changes

2 files changed (+31 additions, -5 deletions)

View changed files

📝 tests/test_psin_index.py (+25 -0)
📝 tools/psin_index.py (+6 -5)

📄 Description

Claimed in the coordination issue as: PSIN-INDEX-DUPLICATE-LSNS-AND-CASE-BIN (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7162455934)

What and why

  • Guard duplicate LSNS sections in tools/psin_index.py parse() (lsns_seen) so only the first LSNS section is decoded and later duplicate LSNS sections cannot overwrite either an earlier LSNS error or the first section's block/record counts, matching the existing LSCH and LENM first-section-only handling.
  • Make directory .bin discovery in input_paths() case-insensitive (name.lower().endswith(".bin")) so .BIN / .Bin files are indexed consistently across filesystems.
  • Accept optional argv=None in main(argv=None) (ap.parse_args(argv)) to support direct in-process CLI testing while preserving CLI invocation behavior.
  • Add regression tests in tests/test_psin_index.py (test_first_lsns_error_is_not_overwritten_by_duplicate_section, test_duplicate_valid_lsns_keeps_first_and_consistent_summary, and test_uppercase_bin_extension_is_indexed).

Tested

  • python -I tests/test_psin_index.py -v -> Ran 36 tests in 0.688s, OK.
  • Baseline upstream/main (0d80bc5d) detached worktree with updated tests/test_psin_index.py -> Ran 36 tests in 0.680s, FAILED (failures=3) (fails on all 3 new regression tests before the fix).
  • python -I tests/test_ci_registration.py -v -> Ran 16 tests in 4.691s, OK.
  • python -I tests/test_text_write_line_endings.py -v -> Ran 3 tests in 12.308s, OK.
  • python -I scripts/check_no_game_data.py tools/psin_index.py tests/test_psin_index.py -> exit 0.
  • python -I -m compileall -q tools/psin_index.py tests/test_psin_index.py and git diff --check -> exit 0.

GPUs tested: n/a (CPU/stdlib Python tests on Windows 11 x64)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • 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. (n/a)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1820 **Author:** [@kirigayakazima](https://github.com/kirigayakazima) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/psin-index-lsns-and-case` --- ### 📝 Commits (1) - [`f12a3f2`](https://github.com/ubiquitarianism/leonida/commit/f12a3f298a914f8568c089cbdc5eddedd63bcce3) tools/psin_index: keep first LSNS section and match .bin case-insensitively ### 📊 Changes **2 files changed** (+31 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_psin_index.py` (+25 -0) 📝 `tools/psin_index.py` (+6 -5) </details> ### 📄 Description Claimed in the coordination issue as: PSIN-INDEX-DUPLICATE-LSNS-AND-CASE-BIN (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7162455934) ### What and why - Guard duplicate `LSNS` sections in `tools/psin_index.py` `parse()` (`lsns_seen`) so only the first `LSNS` section is decoded and later duplicate `LSNS` sections cannot overwrite either an earlier `LSNS` error or the first section's block/record counts, matching the existing `LSCH` and `LENM` first-section-only handling. - Make directory `.bin` discovery in `input_paths()` case-insensitive (`name.lower().endswith(".bin")`) so `.BIN` / `.Bin` files are indexed consistently across filesystems. - Accept optional `argv=None` in `main(argv=None)` (`ap.parse_args(argv)`) to support direct in-process CLI testing while preserving CLI invocation behavior. - Add regression tests in `tests/test_psin_index.py` (`test_first_lsns_error_is_not_overwritten_by_duplicate_section`, `test_duplicate_valid_lsns_keeps_first_and_consistent_summary`, and `test_uppercase_bin_extension_is_indexed`). ### Tested - `python -I tests/test_psin_index.py -v` -> `Ran 36 tests in 0.688s`, `OK`. - Baseline `upstream/main` (`0d80bc5d`) detached worktree with updated `tests/test_psin_index.py` -> `Ran 36 tests in 0.680s`, `FAILED (failures=3)` (fails on all 3 new regression tests before the fix). - `python -I tests/test_ci_registration.py -v` -> `Ran 16 tests in 4.691s`, `OK`. - `python -I tests/test_text_write_line_endings.py -v` -> `Ran 3 tests in 12.308s`, `OK`. - `python -I scripts/check_no_game_data.py tools/psin_index.py tests/test_psin_index.py` -> exit `0`. - `python -I -m compileall -q tools/psin_index.py tests/test_psin_index.py` and `git diff --check` -> exit `0`. GPUs tested: n/a (CPU/stdlib Python tests on Windows 11 x64) AI-assisted: yes ### Checklist - [x] Based on current main and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [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. (n/a) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1831
No description provided.