Answer architecture round 1: move the base fallback, heading check and seat names into the pure modules, move legacy scores through record-scoring, and read origin as last fetched when a fetch fails
This commit is contained in:
@@ -3,10 +3,15 @@ import re
|
||||
|
||||
from failure import Failure
|
||||
|
||||
ARCHITECT = "Inherited architect"
|
||||
DIMENSIONS = ("Navigation", "Locality", "Shape", "Self-sufficiency", "Overall")
|
||||
SCORING_SEATS = ("Junior A", "Mid A", "Maintainability senior", "Inherited architect")
|
||||
SEAT_LINE = re.compile(r"^(Junior A|Mid A|Maintainability senior|Inherited architect): (.+)$")
|
||||
FIRST_SEATS = ("Mid A", ARCHITECT)
|
||||
# A scoring run moved from a `comprehension floor:` decision entry kept only the seats' means.
|
||||
MEAN = "Mean"
|
||||
SCORES = re.compile(", ".join(rf"{name} ([0-9]+(?:\.[0-9]+)?)" for name in DIMENSIONS))
|
||||
SCORING_SEATS = ("Junior A", "Mid A", "Maintainability senior", ARCHITECT)
|
||||
SEAT_LINE = re.compile(rf"^({'|'.join((*SCORING_SEATS, MEAN))}): (.+)$")
|
||||
SPLIT_SEATS = ("Maintainability senior", "Junior A")
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@@ -43,9 +48,9 @@ def report(text: str) -> Report | Failure:
|
||||
|
||||
|
||||
def scores(seats: list[Seat]) -> dict[str, list[str]] | Failure:
|
||||
"""Each seat's five scores as written, in DIMENSIONS' order."""
|
||||
if [seat.name for seat in seats] != list(SCORING_SEATS):
|
||||
return Failure(f"a scoring run's seats are {', '.join(SCORING_SEATS)}, in that order; the file has {', '.join(seat.name for seat in seats) or 'none'}")
|
||||
"""Each seat's five scores as written, in DIMENSIONS' order: the four seats', or the Mean line's alone."""
|
||||
if [seat.name for seat in seats] not in (list(SCORING_SEATS), [MEAN]):
|
||||
return Failure(f"a scoring run's seats are {', '.join(SCORING_SEATS)}, in that order, or a {MEAN} line alone; the file has {', '.join(seat.name for seat in seats) or 'none'}")
|
||||
found = {}
|
||||
for seat in seats:
|
||||
if not (written := SCORES.fullmatch(seat.said)):
|
||||
|
||||
Reference in New Issue
Block a user