- def piece_to_box_listing(
- self,
- piece_id: str,
- ) -> tuple[str, str]:
- 'For Piece of piece_id, print position in .boxes() and description.'
- design = self.designs[self.pieces[piece_id].design_id]
- owning_box: Optional[Box] = None
- for box in self.boxes().values():
- for idx_in_box in [
- idx for idx, d_to_ls in enumerate(box.designs_to_listings)
- if piece_id in [listing[1] for listing in d_to_ls[1]]]:
- owning_box = box
- break
- if owning_box:
- break
- if not owning_box:
- for box in self.boxes().values():
- for idx_in_box in [
- idx for idx, t in enumerate(box.designs_to_listings)
- if design.id_ in t[0].all_ids]:
- owning_box = box
- break
- if owning_box:
- break
- assert owning_box
- return f'{box.id_:>2}:{idx_in_box:>2}', design.description
-