def create_card(self, data): data = json.loads(data) card = Card() card.set = data['set'] card.question = data['question'] card.hint = data['hint'] card.answer = data['answer'] d_set = self.__find_set(card.set) if d_set is None: d_set = CardSet(card.set) self.sets.append(d_set) max_id = 0 for c in d_set.cards: if int(c.id) >= int(max_id): max_id = int(c.id) + 1 card.id = str(max_id) card.save(self.config) d_set.cards.append(card) return card.id
#f.write("}\n") # # #Generating card JSON Objects # # for cards in root.findall('cards'): for card in cards.findall('card'): temp_card = Card() temp_card.id = card.find('id').text temp_card.name = card.find('name').text temp_card.set = card.find('set').text temp_card.type = card.find('type').text temp_card.rarity = card.find('rarity').text temp_card.manacost = card.find('manacost').text or "Default" temp_card.converted_manacost = card.find('converted_manacost').text or "Default" temp_card.power = card.find('power').text or "Default" temp_card.toughness = card.find('toughness').text or "Default" temp_card.loyalty = card.find('loyalty').text or "Default" temp_card.ability = card.find('ability').text or "Default" #temp_card.flavor = card.find('flavor').text or "Default" if temp_card.id == 74256: temp_card.flavor = "Default" else: temp_card.flavor = card.find('flavor').text or "Default"