From d1d8e75ea8177b742364054218e12ec3bc3aeb0d Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Mon, 19 May 2025 18:51:32 -0600 Subject: data.py: support card names containing their set --- scripts/data.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'scripts/data.py') diff --git a/scripts/data.py b/scripts/data.py index fadf9613..2eedb22e 100644 --- a/scripts/data.py +++ b/scripts/data.py @@ -16,6 +16,7 @@ def populate_lookup_dicts(): for card in set_dir.iterdir(): SETS_TO_CARDS[set_name].append(card.stem) CARDS_TO_SETS[card.stem] = set_name + CARDS_TO_SETS[f'{set_name}/{card.stem}'] = set_name def name2set(card: str) -> str: @@ -62,12 +63,14 @@ def name2cardlisting(card: str) -> str: The returned target can be used to directly navigate the card listing to the specific card. - Card listing targets are all lower case and use '-' instead of - whitespace. + Card listing targets are all lower case and use '-' instead of whitespace. Ending '!' are stripped from the card names. + If a path including the set is given only the card part is considered. :param card: the english name of a card :returns: the card listing target """ + if '/' in card: + card = card.split('/')[-1] return card.lower().replace(' ', '-').replace('!', '') -- cgit v1.2.3