home · contact · privacy
Print newlines between multi-line collections listings.
authorPlom Heller <plom@plomlompom.com>
Sat, 30 May 2026 00:38:15 +0000 (02:38 +0200)
committerPlom Heller <plom@plomlompom.com>
Sat, 30 May 2026 00:38:15 +0000 (02:38 +0200)
bricksplom.py

index aa714490ea2e56208f95a9dffb64cbd74260cda8..b5c9f35c961fe326320d1ea8cdd50f6abc336f24 100755 (executable)
@@ -330,7 +330,7 @@ class Collection(Textfiled, WithDb, Lookupable):
     def raw(
             self
             ) -> str:
-        return (f'{self.id_} {self._is_in_str}{self.description}\n'
+        return (f'{self.id_} {self._is_in_str}{self.description}{CHAR_NEWLINE}'
                 + self._format_paginated(lambda count, p_id, comment:
                                          f' {count:2} {p_id:>7} {comment}'))
 
@@ -357,7 +357,7 @@ class Collection(Textfiled, WithDb, Lookupable):
                     lines += [' -']
                 for count, piece_id, comment in column:
                     lines += [format_line(count, piece_id, comment)]
-        return '\n'.join(lines)
+        return CHAR_NEWLINE.join(lines) + CHAR_NEWLINE
 
     def piece_listings_flat(self) -> tuple[PieceListing, ...]:
         'Flattened variant of .piece_listings, no division into pages/cols.'
@@ -402,7 +402,7 @@ class Collection(Textfiled, WithDb, Lookupable):
                     f'{color} {self._db.designs[design_id].description}'
                     f'{tail_comment}')
 
-        return f'{self}\n\n{self._format_paginated(format_line)}'
+        return f'{self}{CHAR_NEWLINE}{self._format_paginated(format_line)}'
 
 
 class Box(WithDb, Lookupable):
@@ -447,7 +447,7 @@ class Box(WithDb, Lookupable):
             for count, piece_id, comment in listings:
                 color = self._db.colors[self._db.pieces[piece_id].color_id]
                 lines += [f'{count:>2}× {piece_id:>7} / {color} # {comment}']
-        return '\n'.join(lines)
+        return CHAR_NEWLINE.join(lines)
 
     def raw(
             self
@@ -583,7 +583,7 @@ def main(
     parser.add_argument('inquiry', nargs='?', default=CHAR_INQUIRY)
     parser.add_argument('--raw', action='store_true')
     args = parser.parse_args()
-    print(db.lookup(args.table, args.inquiry, args.raw))
+    print(db.lookup(args.table, args.inquiry, args.raw).rstrip())
 
 
 main()