コード例 #1
0
def tournament(url, name):
    s = fetcher.internal.fetch(url, character_encoding='utf-8')

    # Tournament details
    soup = BeautifulSoup(s, 'html.parser')
    cell = soup.find('div', {'id': 'EventReport'}).find_all('td')[1]
    # Hack in the known start time because it's not in the page.
    start_time = '19:00'
    name = cell.find('a').string.strip()
    if 'Saturday' in name or 'Sunday' in name or 'PDS' in name:
        start_time = '13:30'
    date_s = cell.find('br').next.strip() + ' {start_time}'.format(
        start_time=start_time)
    if '-0001' in date_s:
        # Tournament has been incorrectly configured.
        return 0

    dt = dtutil.parse(date_s, '%d %B %Y %H:%M', dtutil.GATHERLING_TZ)
    competition_id = competition.get_or_insert_competition(
        dt, dt, name, 'Penny Dreadful {day}s'.format(
            day=dtutil.day_of_week(dt, dtutil.GATHERLING_TZ)), url)
    table = soup.find(text='Current Standings').find_parent('table')
    ranks = rankings(table)

    return add_decks(dt, competition_id, ranks, s)
コード例 #2
0
def get_dt_and_series(name: str, day_s: str) -> Tuple[datetime.datetime, str]:
    if 'APAC' in name:
        competition_series = 'APAC Penny Dreadful Sundays'
        start_time = '16:00'
        dt = get_dt(day_s, start_time, dtutil.APAC_SERIES_TZ)
    elif 'FNM' in name:
        competition_series = 'Penny Dreadful FNM'
        start_time = '19:00'
        dt = get_dt(day_s, start_time, dtutil.GATHERLING_TZ)
    else:
        if 'Saturday' in name or 'Sunday' in name or 'PDS' in name:
            start_time = '13:30'
        else:
            start_time = '19:00'
        dt = get_dt(day_s, start_time, dtutil.GATHERLING_TZ)
        competition_series = 'Penny Dreadful {day}s'.format(day=dtutil.day_of_week(dt, dtutil.GATHERLING_TZ))
    return (dt, competition_series)
コード例 #3
0
def get_dt_and_series(name: str, day_s: str) -> Tuple[datetime.datetime, str]:
    if 'APAC' in name:
        competition_series = 'APAC Penny Dreadful Sundays'
        start_time = '16:00'
        dt = get_dt(day_s, start_time, dtutil.APAC_SERIES_TZ)
    elif 'EU' in name:
        competition_series = 'Penny Dreadful FNM - EU'
        start_time = '13:30'
        dt = get_dt(day_s, start_time, dtutil.GATHERLING_TZ)
    elif 'FNM' in name:
        competition_series = 'Penny Dreadful FNM - EU' # Dubious but this is a couple of impromptu tournaments so let's not fret.
        start_time = '20:00'
        dt = get_dt(day_s, start_time, dtutil.GATHERLING_TZ)
    else:
        if 'Saturday' in name or 'Sunday' in name or 'PDS' in name:
            start_time = '13:30'
        else:
            start_time = '19:00'
        dt = get_dt(day_s, start_time, dtutil.GATHERLING_TZ)
        competition_series = 'Penny Dreadful {day}s'.format(day=dtutil.day_of_week(dt, dtutil.GATHERLING_TZ))
    return (dt, competition_series)