Esempio n. 1
0
def get_card_event(soup: BeautifulSoup,
                   support_card: SupportCard,
                   update: bool = False):
    choice_tables = soup.find_all('div', {"class": "uma_choice_table"})
    for choice_table in choice_tables:
        title = choice_table.find_previous_sibling('h3').text
        card_event = CardEvent(title=title,
                               title_kr=title,
                               support_card=support_card)
        event_from_db = db_session.query(CardEvent).filter_by(
            support_card_id=card_event.support_card_id,
            title=card_event.title).first()

        if event_from_db and update:
            card_event = event_from_db

        get_card_event_choice(choice_table, card_event, update)
        db_session.add(card_event)