From: Plom Heller Date: Sun, 3 May 2026 18:42:04 +0000 (+0200) Subject: Guard against double entries in table Design, Color, Piece table files. X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/%7B%7Bdb.prefix%7D%7D/%7B%7Bprefix%7D%7D?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=bricksplom Guard against double entries in table Design, Color, Piece table files. --- diff --git a/bricksplom.py b/bricksplom.py index 8239f1a..e3379eb 100755 --- a/bricksplom.py +++ b/bricksplom.py @@ -107,6 +107,7 @@ class Color(Textfiled): ) -> dict[str, Self]: collected = {} for id_, desc in [cls.tokify(line, 2) for line in cls.lines_of(path)]: + assert id_ not in collected assert len(desc) > 1 assert desc[0] in {CHAR_COL_SOLID, CHAR_COL_TRANSPARENT} collected[id_] = cls(id_, desc[0] == CHAR_COL_SOLID, desc[1:]) @@ -142,6 +143,7 @@ class Design(Textfiled): alts: dict[str, set[str]] = {} for design_id, body in [cls.tokify(line, 2) for line in cls.lines_of(path)]: + assert design_id not in collected assert len(body) > 1 char_type, body = body[0], body[1:] assert char_type in {CHAR_DESIGN_ALT, CHAR_DESIGN_DESC} @@ -199,6 +201,7 @@ class Piece(Textfiled): collected = {} for toks in [cls.tokify(line, 3) for line in cls.lines_of(path)]: piece_id, design_id = toks[:2] + assert piece_id not in collected color_id, comment = (toks[-1].split(CHAR_SEP_TOKEN, maxsplit=1) + [''])[:2] collected[piece_id] = cls(piece_id, design_id, color_id, comment)