How to use the domdiv.main.read_card_data function in domdiv

To help you get started, we’ve selected a few domdiv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sumpfork / dominiontabs / tests / carddb_tests.py View on Github external
# in alphabetical order, like they are printed,
    # and that accents don't matter
    options = main.parse_opts(
        [
            "--expansions",
            "Hinterlands",
            "--expansion-dividers",
            "--language",
            "fr",
            "--only-type-any",
            "Expansion",
        ]
    )
    options = main.clean_opts(options)
    options.data_path = "."
    cards = main.read_card_data(options)
    cards = main.filter_sort_cards(cards, options)
    card_names = [c.strip() for c in cards[0].description.split("|")]
    # The 26 french card names of the Hinterlands expansion should be sorted as if no accent
    assert len(card_names) == 26
    assert card_names == sorted(
        card_names,
        key=lambda s: "".join(
            c
            for c in unicodedata.normalize("NFD", s)
            if unicodedata.category(c) != "Mn"
        ),
github sumpfork / dominiontabs / tests / carddb_tests.py View on Github external
"--expansions",
            "base",
            "alchemy",
            "--include-blanks",
            "5",
            "--only-type-any",
            "blank",
            "curse",
            "--only-type-all",
            "attack",
            "action",
        ]
    )
    options = main.clean_opts(options)
    options.data_path = "."
    cards = main.read_card_data(options)
    cards = main.filter_sort_cards(cards, options)
    # Total 8 from
    #      Blank:         +5 added in options
    #      Curse:         +1 from base
    #      Action Attack: +2 from Alchemy
    assert len(cards) == 8
github sumpfork / dominiontabs / tests / carddb_tests.py View on Github external
u"renaissance",
        u"menagerie",
        u"extras",
        u"animals",
    }
    for c in cards:
        assert isinstance(c, domdiv_cards.Card)
        assert c.cardset_tag in valid_cardsets

    # Option modified card count
    options = main.parse_opts(
        ["--no-trash", "--curse10", "--start-decks", "--include-blanks", "7"]
    )
    options = main.clean_opts(options)
    options.data_path = "."
    cards = main.read_card_data(options)
    # Total delta cards is +28 from
    #      Trash:       -1 * 3 sets = -3
    #      Curse:       +2 * 4 sets = +8
    #      Start Decks: +4 * 4 sets = +16
    #      Blanks:      +7          = +7
    assert len(cards) == num_cards_expected + 28
github sumpfork / dominiontabs / tests / carddb_tests.py View on Github external
def test_cardread():
    num_cards_expected = 647

    options = main.parse_opts([])
    options.data_path = "."
    cards = main.read_card_data(options)
    assert len(cards) == num_cards_expected
    valid_cardsets = {
        u"base",
        u"dominion1stEdition",
        u"dominion2ndEdition",
        u"dominion2ndEditionUpgrade",
        u"intrigue1stEdition",
        u"intrigue2ndEdition",
        u"intrigue2ndEditionUpgrade",
        u"seaside",
        u"alchemy",
        u"prosperity",
        u"cornucopia extras",
        u"cornucopia",
        u"hinterlands",
        u"dark ages",
github sumpfork / dominiontabs / tests / carddb_tests.py View on Github external
options = main.parse_opts(
        [
            "--expansions",
            "adventures",
            "dominion*",
            "intrigue*",
            "--exclude-expansions",
            "dominiOn1stEditIon",
            "intrigue 2nd*",
            "--exclude-expansion",
            "dominion 2nd edition",
        ]
    )
    options = main.clean_opts(options)
    options.data_path = "."
    cards = main.read_card_data(options)
    cards = main.filter_sort_cards(cards, options)
    card_sets = set(x.cardset.lower() for x in cards)
    assert card_sets == {
        "adventures",
        "dominion 2nd edition upgrade",
        "intrigue 1st edition",
    }
github sumpfork / dominiontabs / tests / carddb_tests.py View on Github external
def test_languages():
    languages = main.get_languages("card_db")
    for lang in languages:
        print("checking " + lang)
        # for now, just test that they load
        options = main.parse_opts(["--language", lang])
        options.data_path = "."
        cards = main.read_card_data(options)
        assert cards, '"{}" cards did not read properly'.format(lang)
        cards = main.add_card_text(cards, "en_us")
        cards = main.add_card_text(cards, lang)
        if lang == "it":
            assert "Maledizione" in [card.name for card in cards]
        elif lang == "de":
            assert "Fluch" in [card.name for card in cards]
github sumpfork / dominiontabs / tests / carddb_tests.py View on Github external
# --expansions, that we can have multiple
    # items with a single flag, that * syntax
    # works, that we can use either the
    # cardset tag or name, and that capitalization
    # doesn't matter
    options = main.parse_opts(
        [
            "--expansion",
            "advEntUres",
            "dominion 2nd*",
            "--expansions=intrigue1stEdition",
        ]
    )
    options = main.clean_opts(options)
    options.data_path = "."
    cards = main.read_card_data(options)
    cards = main.filter_sort_cards(cards, options)
    card_sets = set(x.cardset.lower() for x in cards)
    assert card_sets == {
        "adventures",
        "dominion 2nd edition",
        "dominion 2nd edition upgrade",
        "intrigue 1st edition",
    }