home · contact · privacy
Explicitly auto-sort by ID.
authorPlom Heller <plom@plomlompom.com>
Sun, 4 Oct 2026 21:29:05 +0000 (23:29 +0200)
committerPlom Heller <plom@plomlompom.com>
Sun, 4 Oct 2026 21:29:05 +0000 (23:29 +0200)
src/bricksplom/misc.py
src/run.py

index 0091b0751145598ffe7c853ab91b8f1b9c6f1e08..5d8779453a1ceeb4ebdc7d824223dec36329cb51 100644 (file)
@@ -36,8 +36,8 @@ _MATCH_OPERATORS = {
         _CHAR_ATTR_LESS,
         _CHAR_ATTR_MORE
         }
-_TOK_SORT_BOX = 'box'
-_TOK_SORT_ID = 'id'
+_TOK_BOX = 'box'
+TOK_ID = 'id'
 
 _LDRAW_MODE_FILL_N_STUDS = 'fill_n_studs'
 _LDRAW_MODE_FILL_PATHS = 'fill_paths'
@@ -110,7 +110,7 @@ class _Lookupable:
             ) -> dict[str, tuple[str, dict[str, Callable[[Self, str], bool]]]]:
         'Available lookup matchers.'
         return {
-            _TOK_SORT_ID: (
+            TOK_ID: (
                 'ID of individual item',
                 {_CHAR_ATTR_EQ: (
                     lambda item, val: item.id_ == val)}
@@ -166,7 +166,7 @@ class _Lookupable:
                                                tuple[Self, ...]]]]:
         'Available sorters.'
         return {
-            _TOK_SORT_ID: (
+            TOK_ID: (
                 'by individual items\' IDs',
                 lambda _, pre_sorted:
                 tuple(sorted(pre_sorted,
@@ -261,7 +261,7 @@ class _BrickColor(_Textfiled, _Lookupable):
             ) -> dict[str, tuple[str,
                                  Callable[['BricksDb', tuple[Self, ...]],
                                           tuple[Self, ...]]]]:
-        return super().sorters() | {_TOK_SORT_BOX: cls._by_box_sorter('color')}
+        return super().sorters() | {_TOK_BOX: cls._by_box_sorter('color')}
 
     def show(
             self
@@ -495,7 +495,7 @@ class _BrickDesign(_Textfiled, _Lookupable):
                                     key=lambda item: getattr(item, attr_name)))
             return 'by ' + _BrickDesignData.usage(attr_name), f_sort
         return super().sorters()\
-            | {_TOK_SORT_BOX: cls._by_box_sorter('design')}\
+            | {_TOK_BOX: cls._by_box_sorter('design')}\
             | {attr_name: attr_sorter(attr_name)
                for attr_name in _BrickDesignData.sortables().keys()}
 
@@ -563,7 +563,7 @@ class _Brick(_Textfiled, _Lookupable):
             cls
             ) -> dict[str, tuple[str, Callable[['BricksDb', tuple[Self, ...]],
                                                tuple[Self, ...]]]]:
-        return super().sorters() | {_TOK_SORT_BOX: cls._by_box_sorter()}
+        return super().sorters() | {_TOK_BOX: cls._by_box_sorter()}
 
     @classmethod
     def from_textfile(
index 2296afe7ca3cbc57bc0dc7a685a7e1e99178b3d1..0a80abf37eba7b220c21b14bf25285133f4bc424 100755 (executable)
@@ -17,6 +17,7 @@ from bricksplom.misc import (
         CHAR_SEP_LDRAW_MODES,
         LDRAW_MODES,
         PARAM_Q_ID,
+        TOK_ID,
         )
 
 NAME_ENV_DIRNAME = 'BRICKSPLOM_DIR'
@@ -99,7 +100,7 @@ def main(
                 table_name=args.table,
                 formatter=args.format,
                 match_by=args.match or tuple(),
-                sort_by=args.sort or tuple()
+                sort_by=args.sort or (TOK_ID, )
             ).rstrip())