diff --git a/bin/comprehension_history.py b/bin/comprehension_history.py index c4ef5ac6..20dd2d79 100644 --- a/bin/comprehension_history.py +++ b/bin/comprehension_history.py @@ -104,7 +104,7 @@ def entries(history: str) -> list[Entry]: def latest_places(history: str) -> str | None: - """The places seats found hard from the newest entry, by time, that is a scoring run or holds scoring seats' places: in it and each later entry, each ruled place opening with a dimension its seat's vote counted as worse, and every scoring seat's place. Each entry's places come under its heading, oldest first; with no such entry, every ruling's places count. None when no place counts.""" + """The places seats found hard from the newest entry, by time, that is a scoring run or holds scoring seats' places: in it and each later entry, each ruled place opening with a dimension its seat's vote counted as worse, and every scoring seat's place. Each entry's places come under its heading, oldest first; with no such entry, it starts at the oldest entry. None when no place counts.""" found = sorted(entries(history), key=lambda entry: entry.time) newest = max((index for index, entry in enumerate(found) if not entry.paired or entry.scored_places), default=0) parts = [placed(entry, worse_places(entry) + labelled_bullets(entry.body, SCORED_PLACES)) for entry in found[newest:]] @@ -127,7 +127,9 @@ def worse_votes(body: str) -> dict[str, set[str]]: """Each seat's dimensions, Overall included, whose vote in the ruling's table counted as worse; `same (voted worse, …)` counted as same. The votes table comes first, so a seat's row in a later scores table is not its vote.""" found: dict[str, set[str]] = {} for line in body.splitlines(): - name, *votes = [cell.strip() for cell in line.strip("|").split("|")] if line.startswith("| ") else [""] + if not line.startswith("| "): + continue + name, *votes = [cell.strip() for cell in line.strip("|").split("|")] if len(votes) == len(DIMENSIONS): found.setdefault(name, {dimension for dimension, vote in zip(DIMENSIONS, votes) if vote == "worse"}) return found diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index 5af89112..c68a63c7 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -141,7 +141,7 @@ class History(unittest.TestCase): older = paired("2026-10-07T12:00:00Z", "worse") + "\n| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |\n|---|---|---|---|---|---|\n| Mid A | same | worse | same | same | worse |\n\nMid A, decided by:\n\n- Locality: `bin/e.py:1` `n`: old\n" self.assertIsNone(latest_places("")) self.assertIsNone(latest_places(appended("", paired("2026-10-07T12:00:00Z", "same")))) - self.assertIsNone(latest_places(appended("", paired("2026-10-07T12:00:00Z", "worse") + "\n| Seat | Vote |\n|---|---|\n| Mid A | worse |\n\n- Locality: `bin/k.py:1` `t`: before any label\n\nMid A, decided by:\n\n- Locality: `bin/e.py:1` `n`: old\n"))) + self.assertIsNone(latest_places(appended("", paired("2026-10-07T12:00:00Z", "worse") + "\n| Seat | Vote | Locality |\n|---|---|---|\n| Mid A | same | worse |\n\n- Locality: `bin/k.py:1` `t`: before any label\n\nMid A, decided by:\n\n- Locality: `bin/e.py:1` `n`: old\n"))) unscored = "## 2026-10-11T12:00:00Z, PR #4 at eeeeeee\n\n| Seat | Overall |\n|---|---|\n| Mean | 7.00 |\n" self.assertIsNone(latest_places(appended(appended("", scored), unscored))) hard_since = "## 2026-10-10T12:00:00Z, PR #2 at bbbbbbb, against aaaaaaa\n\nMid A, decided by:\n\n- Locality, Shape: `bin/a.py:3` `f`: held at once\n"