예제 #1
0
    def table_to_card_mapping(row: sqlite3.Row):
        """Return card object representation of a table row"""
        card = Card()
        card.multiverse_id = row["multiverseid"]
        tmp = row["name"]
        card.name = tmp
        card.layout = row["layout"]
        card.mana_cost = row["manacost"]
        card.cmc = row["cmc"]
        card.colors = row["colors"]
        card.type = row["type"]
        card.rarity = row["rarity"]
        card.text = row["text"]
        card.flavor = row["flavor"]
        card.artist = row["artist"]
        card.number = row["number"]
        card.power = row["power"]
        card.toughness = row["toughness"]
        card.loyalty = row["loyalty"]
        card.watermark = row["watermark"]
        card.border = row["border"]
        card.hand = row["hand"]
        card.life = row["life"]
        card.release_date = row["releaseDate"]
        card.starter = row["starter"]
        card.original_text = row["originalText"]
        card.original_type = row["originalType"]
        card.source = row["source"]
        card.image_url = row["imageUrl"]
        card.set = row["set"]
        card.set_name = row["setName"]
        card.id = row["id"]

        # Bool attributes
        card.timeshifted = ast.literal_eval(row["timeshifted"])

        # List attributes
        card.names = ast.literal_eval(row["names"])
        card.supertypes = ast.literal_eval(row["supertypes"])
        card.subtypes = ast.literal_eval(row["subtypes"])
        card.types = ast.literal_eval(row["types"])
        card.printings = ast.literal_eval(row["printings"])
        card.variations = ast.literal_eval(row["variations"])

        # Dict attributes
        card.legalities = ast.literal_eval(row["legalities"])
        card.rulings = ast.literal_eval(row["rulings"])
        card.foreign_names = ast.literal_eval(row["foreignNames"])

        return card