MTGProxyPrinter

Check-in [639a73228d]
Login

Check-in [639a73228d]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:MagicWorkstationDeckListParser: Improve parser compatibility, by also allowing single space characters between the sideboard note and the number of copies. Ensures compatibility with mwDeck files obtained from [https://mtgen.net]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 639a73228db1baf4750a33fbddd27b63b30bbbf2d1c579fee5c9767038b59c36
User & Date: thomas 2025-03-23 16:02:49
Original Comment: MagicWorkstationDeckListParser: Improve parser compatibility, by also allowing single space characters between the sideboard note and the number of copies. Ensures compatibility with mwDeck files obtained from [mtgen.net](https://mtgen.net)
Context
2025-03-28
14:48
Extracted the page card table view into a dedicated class. This moves most of the logic out of CentralWidget, as most of the present logic dealt with the table custom context menu. Leaf check-in: 67360d8140 user: thomas tags: trunk
2025-03-27
22:13
Extract the PageCardTableView as a dedicated class. Most of the CentralWidget logic is related to setting up the page card table view, and its custom context menu. Encapsulate all that in a dedicated class. check-in: 436980c684 user: thomas tags: extract_page_card_table_view_class
2025-03-23
16:02
MagicWorkstationDeckListParser: Improve parser compatibility, by also allowing single space characters between the sideboard note and the number of copies. Ensures compatibility with mwDeck files obtained from [https://mtgen.net] check-in: 639a73228d user: thomas tags: trunk
15:45
README: Fix link to the XMage homepage, as the project switched the domain check-in: 9ac5254edf user: thomas tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to mtg_proxy_printer/decklist_parser/re_parsers.py.

179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
                "MagicWorkstationDeckDataFormatParser", "Magic Workstation Deck Data Format"): ["mwDeck"],
        }
    PREFIXES_TO_SKIP = frozenset({"//"})

    def __init__(self, card_db: CardDatabase, image_db: ImageDatabase, parent: QObject = None):
        super().__init__(
            card_db, image_db,
            re.compile(r"(SB: {2})?(?P<copies>\d+) \[(?P<set_code>\w+)?] (?P<name>.+)"), parent
        )


class MTGArenaParser(GenericRegularExpressionDeckParser):
    """
    A parser for MTG Arena deck lists (file extension .mtga). moxfield.com uses this format to export deck lists.
    """







|







179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
                "MagicWorkstationDeckDataFormatParser", "Magic Workstation Deck Data Format"): ["mwDeck"],
        }
    PREFIXES_TO_SKIP = frozenset({"//"})

    def __init__(self, card_db: CardDatabase, image_db: ImageDatabase, parent: QObject = None):
        super().__init__(
            card_db, image_db,
            re.compile(r"(SB: {1,2})?(?P<copies>\d+) \[(?P<set_code>\w+)?] (?P<name>.+)"), parent
        )


class MTGArenaParser(GenericRegularExpressionDeckParser):
    """
    A parser for MTG Arena deck lists (file extension .mtga). moxfield.com uses this format to export deck lists.
    """

Changes to tests/decklist_parser/test_mwdeck_re_parser.py.

26
27
28
29
30
31
32


33
34
35
36
37
38
39

@pytest.mark.parametrize("deck, count, card_data", [
    # Card with spaces in name
    ("7 [] Fury Sliver", 7, CardIdentificationData(name="Fury Sliver")),
    ("6 [TSP] Fury Sliver", 6, CardIdentificationData(name="Fury Sliver", set_code="TSP")),
    ("SB:  5 [] Fury Sliver", 5, CardIdentificationData(name="Fury Sliver")),
    ("SB:  4 [TSP] Fury Sliver", 4, CardIdentificationData(name="Fury Sliver", set_code="TSP")),


])
def test_magic_workstation_deck_list_all_variants_work(
        card_db: CardDatabase, deck: str, count: int, card_data: CardIdentificationData):
    image_db = unittest.mock.MagicMock()
    image_db.filter_already_downloaded.return_value = []
    parser = MagicWorkstationDeckDataFormatParser(card_db, image_db)
    assert_that(







>
>







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

@pytest.mark.parametrize("deck, count, card_data", [
    # Card with spaces in name
    ("7 [] Fury Sliver", 7, CardIdentificationData(name="Fury Sliver")),
    ("6 [TSP] Fury Sliver", 6, CardIdentificationData(name="Fury Sliver", set_code="TSP")),
    ("SB:  5 [] Fury Sliver", 5, CardIdentificationData(name="Fury Sliver")),
    ("SB:  4 [TSP] Fury Sliver", 4, CardIdentificationData(name="Fury Sliver", set_code="TSP")),
    ("SB: 5 [] Fury Sliver", 5, CardIdentificationData(name="Fury Sliver")),
    ("SB: 4 [TSP] Fury Sliver", 4, CardIdentificationData(name="Fury Sliver", set_code="TSP")),
])
def test_magic_workstation_deck_list_all_variants_work(
        card_db: CardDatabase, deck: str, count: int, card_data: CardIdentificationData):
    image_db = unittest.mock.MagicMock()
    image_db.filter_already_downloaded.return_value = []
    parser = MagicWorkstationDeckDataFormatParser(card_db, image_db)
    assert_that(