From: Plom Heller Date: Sat, 13 Jun 2026 18:42:17 +0000 (+0200) Subject: De-hardcode -r output for design attributes. X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/te%22st.html?a=commitdiff_plain;h=852ec4ccaf9735c68faa6b3d1f91286c489e8e3f;p=bricksplom De-hardcode -r output for design attributes. --- diff --git a/bricksplom.py b/bricksplom.py index 0003d6f..7f4942d 100755 --- a/bricksplom.py +++ b/bricksplom.py @@ -30,7 +30,7 @@ CHAR_COL_SOLID = '+' CHAR_COL_TRANSPARENT = '-' BOX_PREFIX = 'box:' -PARAM_Q_ID = 'id=' +PARAM_Q_ID = f'id{CHAR_ATTR_EQ}' PARAM_Q_TEXT = 'text:' TOK_SORT_BOX = 'box' TOK_SORT_ID = 'id' @@ -229,7 +229,7 @@ class BrickColor(Textfiled, Lookupable): class BrickDesignData: 'Lookupables for BrickDesign besides .id.' n_studs: int = -1 - description: str = '' + description: str = '?' class BrickDesign(Textfiled, Lookupable): @@ -278,7 +278,7 @@ class BrickDesign(Textfiled, Lookupable): return getattr(self, attr_name) == int(q_body) return match return super().matchers | { - f'{attr_name}=': attr_matcher(attr_name) + f'{attr_name}{CHAR_ATTR_EQ}': attr_matcher(attr_name) for attr_name, attr_type in BrickDesignData.__annotations__.items() if attr_type is int} @@ -343,8 +343,10 @@ class BrickDesign(Textfiled, Lookupable): return ( f'{self.id_indented()} ' + (f'{CHAR_DESIGN_ALT}{self.alternate_to.id_}' if self.alternate_to - else (('' if self.n_studs < 0 - else f'n_studs{CHAR_ATTR_EQ}{self.n_studs}') + else ('|'.join( + [f'{k}{CHAR_ATTR_EQ}{getattr(self, k)}' + for k in BrickDesignData.__annotations__ + if k != 'description']) + f'{SEP_DESIGN_DESC}{self.description}')))