コード例 #1
0
ファイル: outputter.py プロジェクト: knguyen4221/mtgjson
def create_and_write_compiled_outputs() -> None:
    """
    This method class will create the combined output files
    (ex: AllSets.json, AllCards.json, Standard.json)
    """
    # Compiled output files

    # CompiledList.json -- do not include ReferralMap
    write_to_file(
        mtgjson4.COMPILED_LIST_OUTPUT,
        create_compiled_list(
            list(set(mtgjson4.OUTPUT_FILES) - {mtgjson4.REFERRAL_DB_OUTPUT})),
    )

    # Keywords.json
    key_words = wizards.compile_comp_output()
    write_to_file(mtgjson4.KEY_WORDS_OUTPUT, key_words)

    # CardTypes.json
    compiled_types = wizards.compile_comp_types_output()
    write_to_file(mtgjson4.CARD_TYPES_OUTPUT, compiled_types)

    # version.json
    version_info = get_version_info()
    write_to_file(mtgjson4.VERSION_OUTPUT, version_info)

    # SetList.json
    set_list_info = get_all_set_list(mtgjson4.OUTPUT_FILES)
    write_to_file(mtgjson4.SET_LIST_OUTPUT, set_list_info)

    # AllSets.json
    all_sets = create_all_sets(mtgjson4.OUTPUT_FILES)
    write_to_file(mtgjson4.ALL_SETS_OUTPUT, all_sets)

    create_set_centric_outputs(all_sets)

    # AllCards.json
    all_cards = create_all_cards(mtgjson4.OUTPUT_FILES)
    write_to_file(mtgjson4.ALL_CARDS_OUTPUT, all_cards)

    create_card_centric_outputs(all_cards)

    # decks/*.json
    deck_names = []
    for deck in magic_precons.build_and_write_decks(DECKS_URL):
        deck_name = util.capital_case_without_symbols(deck["name"])
        write_deck_to_file(f"{deck_name}_{deck['code']}", deck)
        deck_names.append({
            "code": deck["code"],
            "fileName": deck_name,
            "name": deck["name"],
            "releaseDate": deck["releaseDate"],
        })

    # DeckLists.json
    write_to_file(
        mtgjson4.DECK_LISTS_OUTPUT,
        create_deck_compiled_list(
            sorted(deck_names, key=lambda deck_obj: deck_obj["name"])),
    )
コード例 #2
0
def create_and_write_compiled_outputs() -> None:
    """
    This method class will create the combined output files
    (ex: AllSets.json, AllCards.json, Standard.json)
    """
    # Compiled output files
    files_to_ignore: List[str] = [
        mtgjson4.ALL_CARDS_OUTPUT,
        mtgjson4.ALL_DECKS_DIR_OUTPUT,
        mtgjson4.ALL_SETS_DIR_OUTPUT,
        mtgjson4.ALL_SETS_OUTPUT,
        mtgjson4.CARD_TYPES_OUTPUT,
        mtgjson4.COMPILED_LIST_OUTPUT,
        mtgjson4.DECK_LISTS_OUTPUT,
        mtgjson4.KEY_WORDS_OUTPUT,
        mtgjson4.MODERN_OUTPUT,
        mtgjson4.SET_LIST_OUTPUT,
        mtgjson4.STANDARD_OUTPUT,
        mtgjson4.VERSION_OUTPUT,
        mtgjson4.VINTAGE_OUTPUT,
    ]

    # CompiledList.json -- do not include ReferralMap
    write_to_file(mtgjson4.COMPILED_LIST_OUTPUT,
                  create_compiled_list(sorted(files_to_ignore)))

    # File that should be also ignored -- must be added AFTER CompiledList.json
    files_to_ignore.append(mtgjson4.REFERRAL_DB_OUTPUT)

    # Keywords.json
    key_words = wizards.compile_comp_output()
    write_to_file(mtgjson4.KEY_WORDS_OUTPUT, key_words)

    # CardTypes.json
    compiled_types = wizards.compile_comp_types_output()
    write_to_file(mtgjson4.CARD_TYPES_OUTPUT, compiled_types)

    # version.json
    version_info = get_version_info()
    write_to_file(mtgjson4.VERSION_OUTPUT, version_info)

    # SetList.json
    set_list_info = get_all_set_list(files_to_ignore)
    write_to_file(mtgjson4.SET_LIST_OUTPUT, set_list_info)

    # AllSets.json
    all_sets = create_all_sets(files_to_ignore)
    write_to_file(mtgjson4.ALL_SETS_OUTPUT, all_sets)

    # AllCards.json
    all_cards = create_all_cards(files_to_ignore)
    write_to_file(mtgjson4.ALL_CARDS_OUTPUT, all_cards)

    # Standard.json
    write_to_file(mtgjson4.STANDARD_OUTPUT, create_standard_only_output())

    # Modern.json
    write_to_file(mtgjson4.MODERN_OUTPUT, create_modern_only_output())

    # Vintage.json
    all_sets_no_fun = create_vintage_only_output(files_to_ignore)
    write_to_file(mtgjson4.VINTAGE_OUTPUT, all_sets_no_fun)

    # decks/*.json
    deck_names = []
    for deck in magic_precons.build_and_write_decks(DECKS_URL):
        deck_name = util.capital_case_without_symbols(deck["name"])
        write_deck_to_file(deck_name, deck)
        deck_names.append({
            "fileName": deck_name,
            "name": deck["name"],
            "code": deck["code"]
        })

    # DeckLists.json
    write_to_file(
        mtgjson4.DECK_LISTS_OUTPUT,
        create_deck_compiled_list(
            sorted(deck_names, key=lambda deck_obj: deck_obj["name"])),
    )
コード例 #3
0
ファイル: outputter.py プロジェクト: mtgjson/mtgjson
def create_and_write_compiled_outputs() -> None:
    """
    This method class will create the combined output files
    (ex: AllSets.json, AllCards.json, Standard.json)
    """
    # Compiled output files

    # CompiledList.json -- do not include ReferralMap
    write_to_file(
        mtgjson4.COMPILED_LIST_OUTPUT,
        create_compiled_list(
            list(set(mtgjson4.OUTPUT_FILES) - {mtgjson4.REFERRAL_DB_OUTPUT})
        ),
    )

    # Keywords.json
    key_words = wizards.compile_comp_output()
    write_to_file(mtgjson4.KEY_WORDS_OUTPUT, key_words)

    # CardTypes.json
    compiled_types = wizards.compile_comp_types_output()
    write_to_file(mtgjson4.CARD_TYPES_OUTPUT, compiled_types)

    # version.json
    version_info = get_version_info()
    write_to_file(mtgjson4.VERSION_OUTPUT, version_info)

    # SetList.json
    set_list_info = get_all_set_list(mtgjson4.OUTPUT_FILES)
    write_to_file(mtgjson4.SET_LIST_OUTPUT, set_list_info)

    # AllSets.json
    all_sets = create_all_sets(mtgjson4.OUTPUT_FILES)
    write_to_file(mtgjson4.ALL_SETS_OUTPUT, all_sets)

    # AllCards.json
    all_cards = create_all_cards(mtgjson4.OUTPUT_FILES)
    write_to_file(mtgjson4.ALL_CARDS_OUTPUT, all_cards)

    # Standard.json
    write_to_file(mtgjson4.STANDARD_OUTPUT, create_standard_only_output())

    # Modern.json
    write_to_file(mtgjson4.MODERN_OUTPUT, create_modern_only_output())

    # Vintage.json
    all_sets_no_fun = create_vintage_only_output(mtgjson4.OUTPUT_FILES)
    write_to_file(mtgjson4.VINTAGE_OUTPUT, all_sets_no_fun)

    # decks/*.json
    deck_names = []
    for deck in magic_precons.build_and_write_decks(DECKS_URL):
        deck_name = util.capital_case_without_symbols(deck["name"])
        write_deck_to_file(deck_name, deck)
        deck_names.append(
            {
                "code": deck["code"],
                "fileName": deck_name,
                "name": deck["name"],
                "releaseDate": deck["releaseDate"],
            }
        )

    # DeckLists.json
    write_to_file(
        mtgjson4.DECK_LISTS_OUTPUT,
        create_deck_compiled_list(
            sorted(deck_names, key=lambda deck_obj: deck_obj["name"])
        ),
    )