2025-01-24 10:03:53 +01:00
|
|
|
from typing import Tuple
|
|
|
|
|
|
|
|
# Some table aliases to make it look cleaner (id: (name, icon))
|
|
|
|
ALIASES: dict[str, Tuple[str, str]] = {
|
2025-01-27 18:39:35 +01:00
|
|
|
'bricktracker_minifigures': ('Bricktracker minifigures', 'group-line'),
|
2025-01-27 18:41:44 +01:00
|
|
|
'bricktracker_set_checkboxes': ('Bricktracker set checkboxes', 'checkbox-line'), # noqa: E501
|
2025-01-24 10:03:53 +01:00
|
|
|
'bricktracker_set_statuses': ('Bricktracker sets status', 'checkbox-line'),
|
|
|
|
'bricktracker_sets': ('Bricktracker sets', 'hashtag'),
|
|
|
|
'bricktracker_wishes': ('Bricktracker wishes', 'gift-line'),
|
|
|
|
'inventory': ('Parts', 'shapes-line'),
|
|
|
|
'minifigures': ('Minifigures', 'group-line'),
|
2025-01-27 18:39:35 +01:00
|
|
|
'minifigures_old': ('Minifigures (legacy)', 'group-line'),
|
2025-01-24 10:03:53 +01:00
|
|
|
'missing': ('Missing', 'error-warning-line'),
|
2025-01-27 18:39:35 +01:00
|
|
|
'rebrickable_minifigures': ('Rebrickable minifigures', 'group-line'),
|
2025-01-24 10:03:53 +01:00
|
|
|
'rebrickable_sets': ('Rebrickable sets', 'hashtag'),
|
|
|
|
'sets': ('Sets', 'hashtag'),
|
|
|
|
'sets_old': ('Sets (legacy)', 'hashtag'),
|
|
|
|
'wishlist': ('Wishlist', 'gift-line'),
|
|
|
|
'wishlist_old': ('Wishlist (legacy)', 'gift-line'),
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2025-01-20 16:36:31 +01:00
|
|
|
class BrickCounter(object):
|
|
|
|
name: str
|
|
|
|
table: str
|
|
|
|
icon: str
|
|
|
|
count: int
|
2025-01-26 10:29:33 +01:00
|
|
|
legacy: bool
|
2025-01-20 16:36:31 +01:00
|
|
|
|
2025-01-24 10:03:53 +01:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
table: str,
|
|
|
|
/,
|
|
|
|
*,
|
|
|
|
name: str | None = None,
|
|
|
|
icon: str = 'question-line'
|
|
|
|
):
|
2025-01-20 16:36:31 +01:00
|
|
|
self.table = table
|
2025-01-24 10:03:53 +01:00
|
|
|
|
|
|
|
# Check if there is an alias
|
|
|
|
if table in ALIASES:
|
|
|
|
self.name = ALIASES[table][0]
|
|
|
|
self.icon = ALIASES[table][1]
|
|
|
|
else:
|
|
|
|
if name is None:
|
|
|
|
self.name = table
|
|
|
|
else:
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
self.icon = icon
|
2025-01-26 10:29:33 +01:00
|
|
|
|
|
|
|
self.legacy = '(legacy)' in self.name
|