home · contact · privacy
De-hardcode -r output for design attributes.
authorPlom Heller <plom@plomlompom.com>
Sat, 13 Jun 2026 18:42:17 +0000 (20:42 +0200)
committerPlom Heller <plom@plomlompom.com>
Sat, 13 Jun 2026 18:42:17 +0000 (20:42 +0200)
bricksplom.py

index 0003d6fc57e3b611de713a71f79bff1359e0eeb3..7f4942d32ae69ebb3cb77c4e1ae566bb0f371648 100755 (executable)
@@ -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}')))