From: Plom Heller Date: Wed, 29 Apr 2026 20:29:46 +0000 (+0200) Subject: Add by-pieces listings to Box. X-Git-Url: https://plomlompom.com/repos/booking/%22https:/validator.w3.org/foo.html?a=commitdiff_plain;h=d745d6b9ec6e53aa0257045027eb5689966a3c9f;p=bricksplom Add by-pieces listings to Box. --- diff --git a/bricksplom.py b/bricksplom.py index ccb17ef..fc1c2c7 100755 --- a/bricksplom.py +++ b/bricksplom.py @@ -44,14 +44,14 @@ class Textfiled(ABC): body: str, len_expected: int ) -> tuple[str, ...]: - 'Body parsd into left-stripped tokens of len_expected count.' + 'Body parsed into left-stripped tokens of len_expected count.' collected: list[str] = [] while len(collected) < len_expected: body = body.lstrip() if len(collected) == len_expected - 1: tok = body else: - assert CHAR_SPACE in body + assert CHAR_SPACE in body, body tok, body = body.split(CHAR_SPACE, maxsplit=1) collected += [tok] return tuple(collected) @@ -328,6 +328,27 @@ class Box(Textfiled): ) -> str: return f'{self.id_:>2} {",".join(self.designs)}' + def print_pieces( + self, + pieces: dict[str, 'Piece'], + designs: dict[str, 'Design'], + colors: dict[str, 'Color'], + collections: dict[str, 'Collections'] + ) -> None: + 'Print explanatory listings of pieces expected by .designs.' + for design_id in self.designs: + design = designs[design_id] + print(f'=== {design_id:>6}: {design.description} ===') + for piece in [p for p in pieces.values() + if p.design_id in {design.id_} | design.alternates]: + count_pieces = 0 + color = colors[piece.color_id] + for listings in [c.piece_listings_flat() + for c in collections.values()]: + for count in [t[0] for t in listings if t[1] == piece.id_]: + count_pieces += count + print(f'{count_pieces:>2}× {piece.id_:>7} / {color}') + def check_consistencies_between_tables( colors: dict[str, Color], @@ -358,7 +379,7 @@ def check_consistencies_between_tables( # check all pieces' designs recorded in designs for design_id in [piece.design_id for piece in pieces.values()]: - assert Design.possibly_by_alt(design_id, designs) is not None + assert Design.possibly_by_alt(design_id, designs), design_id # check all recorded designs have matching pieces (at least via alts) for design_id, alts in [(k, v.alternates) for k, v in designs.items()]: