Rule each dimension in the paired ruling, and count a better ruling as worse when a dimension it rules fallen is under the floor
This commit is contained in:
+15
-11
@@ -8,6 +8,7 @@ from markdown_sections import sections
|
||||
|
||||
DATED = re.compile(r"^[0-9]{4}-[0-9]{2}-[0-9]{2}(?:T[0-9]{2}:[0-9]{2}:[0-9]{2}Z)?, ")
|
||||
DECIDED_BY = "decided by"
|
||||
FELL = re.compile(r"^Fell: (.+)$", re.M)
|
||||
HARDEST_FIRST = "hardest first"
|
||||
HEADING = re.compile(r"^([^,]+), (.+) at ([0-9a-f]{7,40})(?:, against ([0-9a-f]{7,40}))?$")
|
||||
# `path:line` or `:line`, then the unit's name where one follows.
|
||||
@@ -27,12 +28,13 @@ class Place:
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Entry:
|
||||
"""One paired ruling, which names the commit it was against and its ruling, or one scoring run, which names neither."""
|
||||
"""One paired ruling, which names the commit it was against, its ruling and the dimensions that fell when it is better, or one scoring run, which names none of them."""
|
||||
heading: str
|
||||
time: str
|
||||
commit: str
|
||||
against: str | None
|
||||
ruling: str | None
|
||||
fell: list[str]
|
||||
places: list[Place]
|
||||
|
||||
@property
|
||||
@@ -62,7 +64,8 @@ def entries(history: str) -> list[Entry]:
|
||||
if named := HEADING.match(heading):
|
||||
body = "\n".join(bodies)
|
||||
ruling = RULING.search(body)
|
||||
found.append(Entry(heading, named.group(1), named.group(3), named.group(4), ruling.group(1) if ruling else None, seat_places(body)))
|
||||
fell = FELL.search(body)
|
||||
found.append(Entry(heading, named.group(1), named.group(3), named.group(4), ruling.group(1) if ruling else None, fell.group(1).split(", ") if fell else [], seat_places(body)))
|
||||
return found
|
||||
|
||||
|
||||
@@ -108,21 +111,22 @@ def appended(history: str, entry: str) -> str:
|
||||
return f"{text}\n{entry}"
|
||||
|
||||
|
||||
def ruling_entry(title: str, seats: list[Seat], counted: dict[str, str], ruled: str) -> str:
|
||||
"""A paired ruling's entry; a seat's vote that counted as same for naming no place says so."""
|
||||
votes = [[seat.name, vote_text(seat, counted[seat.name])] for seat in seats]
|
||||
return entry_text(title, [f"Ruling: {ruled}"], [["Seat", "Vote"], *votes], [(f"{seat.name}, {DECIDED_BY}:", seat.places) for seat in seats])
|
||||
def ruling_entry(title: str, seats: list[Seat], said: dict[str, list[str]], counted: dict[str, list[str]], ruled: str, fell: list[str]) -> str:
|
||||
"""A paired ruling's entry, with a `Fell:` line when it is better and fell names dimensions; a seat's vote that counted as same for naming no place says so."""
|
||||
votes = [[seat.name, *map(vote_text, said[seat.name], counted[seat.name])] for seat in seats]
|
||||
lines = [f"Ruling: {ruled}"] + ([f"Fell: {', '.join(fell)}"] if ruled == "better" and fell else [])
|
||||
return entry_text(title, lines, [["Seat", *DIMENSIONS], *votes], [(f"{seat.name}, {DECIDED_BY}:", seat.places) for seat in seats])
|
||||
|
||||
|
||||
def vote_text(seat: Seat, counted: str) -> str:
|
||||
return counted if counted == seat.said else f"same (voted {seat.said}, naming no place)"
|
||||
def vote_text(said: str, counted: str) -> str:
|
||||
return counted if counted == said else f"same (voted {said}, naming no place)"
|
||||
|
||||
|
||||
def scoring_entry(title: str, seats: list[Seat], scores: dict[str, list[str]], means: list[str]) -> str:
|
||||
"""A scoring run's entry; a run moved from a decision entry has its means alone."""
|
||||
def scoring_entry(title: str, seats: list[Seat], scores: dict[str, list[str]], means: list[str], lines: list[str]) -> str:
|
||||
"""A scoring run's entry, with any lines such as a `Ratchet:` line; a run moved from a decision entry has its means alone."""
|
||||
rows = [[seat, *values] for seat, values in scores.items()] + [[MEAN, *means]]
|
||||
labels = [(f"{seat.name}, {RESTRUCTURE_FIRST if seat.name == ARCHITECT else HARDEST_FIRST}:", seat.places) for seat in seats]
|
||||
return entry_text(title, [], [["Seat", *DIMENSIONS], *rows], labels)
|
||||
return entry_text(title, lines, [["Seat", *DIMENSIONS], *rows], labels)
|
||||
|
||||
|
||||
def entry_text(title: str, lines: list[str], table: list[list[str]], seats: list[tuple[str, list[str]]]) -> str:
|
||||
|
||||
Reference in New Issue
Block a user