) -> tuple[Self, ...]:
remains = list(pre_sorted)
items: list[Self] = []
- for box in sorted(db.boxes().values(),
+ for box in sorted(db.boxes.values(),
key=lambda box: box.id_indented()):
for item_id in [t[1] for t in box.brick_listings_flat()]:
if to_id_of:
color = str(self._db.colors[self._db.bricks[brick_id].color_id]
).lstrip().split(CHAR_SEP_TOKEN, maxsplit=1)[1]
box: Optional[Box] = None
- for i_box in self._db.boxes().values():
+ for i_box in self._db.boxes.values():
for idx_in_box in [
idx for idx, d_to_ls
in enumerate(i_box.designs_to_listings)
if box:
break
if not box:
- for i_box in self._db.boxes().values():
+ for i_box in self._db.boxes.values():
for idx_in_box in [
idx for idx, t
in enumerate(i_box.designs_to_listings)
class BricksDb:
'Collection of all the tables enabling their combined processing.'
- lookupable = frozenset(
- {'boxes', 'designs', 'sets', 'colors', 'bricks'})
+ lookupable = frozenset({'boxes', 'bricks', 'colors', 'designs', 'sets'})
def __init__(
self,
design.direct_attrs.ldraw = filename
self._check_consistencies(verify_ldraw='verify' in self._ldraw_mode)
+ @property
def boxes(
self
) -> dict[str, Box]:
sort_by: str
) -> str:
'Return result of inquiry on table of table_name.'
- assert table_name in self.lookupable
- maybe_dict = getattr(self, table_name)
- table = maybe_dict if isinstance(maybe_dict, dict) else maybe_dict()
+ assert hasattr(self, table_name) and table_name in self.lookupable
+ table = getattr(self, table_name)
if item_id:
match_by = PARAM_Q_ID + item_id
items = tuple(table.values())