Ejemplo n.º 1
0
def parse(sem, year):
    """Parses the files downloaded by :func:`get`."""

    # Make sure the time is valid, but don't do anything with the
    # return values.
    parse_time(sem, year)

    ct_parse.main(sem, year)
    scg_parse.main(sem, year)
    st_parse.main(sem, year)
    xl_parse.main(sem, year)
Ejemplo n.º 2
0
def parse(sem, year):
    """Parses the files downloaded by :func:`get`."""

    # Make sure the time is valid, but don't do anything with the
    # return values.
    parse_time(sem, year)

    ct_parse.main(sem, year)
    scg_parse.main(sem, year)
    st_parse.main(sem, year)
    xl_parse.main(sem, year)
Ejemplo n.º 3
0
def try_set_arguments(sky, coordinates, date_and_time):
    if date_and_time:
        sky.set_angle(parse.parse_time(date_and_time))

    if coordinates:
        sky.change_direction(*parse.parse_coordinates(
            coordinates[0].replace('_', '-'), coordinates[1]))
Ejemplo n.º 4
0
def get(sem, year):
    """Uses wget to download the registrar files. Files need to be
    converted into UTF-8 by user afterward."""

    index = parse_time(sem, year)
    print('Semester-year string: %s.' % index)
    wget_files(index)
    print('Now convert the files to UTF-8 with Unix line endings using Emacs and then pass in --parse.')
Ejemplo n.º 5
0
def get(sem, year):
    """Uses wget to download the registrar files. Files need to be
    converted into UTF-8 by user afterward."""

    index = parse_time(sem, year)
    print('Semester-year string: %s.' % index)
    wget_files(index)
    print(
        'Now convert the files to UTF-8 with Unix line endings using Emacs and then pass in --parse.'
    )
Ejemplo n.º 6
0
def send_time_to_match(bot, user):
    time = parse.parse_time(user)

    if isinstance(time, str):
        message_text = time
        bot.send_message(user.id, message_text)
        return
    else:
        days, hours, minutes = time
    endings = get_endings(user.language, days, hours, minutes)

    if minutes < 0:
        message_text = LANG_DICT[user.language]['match_started_msg']
    else:
        message_text = '{} {} {} {}, {} {}, {} {}'.format(LANG_DICT[user.language]['time_to_match_msg'],
                                                          endings[0],
                                                          days, endings[1],
                                                          hours, endings[2],
                                                          minutes, endings[3])

    bot.send_message(user.id, message_text)
Ejemplo n.º 7
0
def handle_match_started_users(bot, users):
    if datetime.now().minute % 5 == 0:
        for user in users:
            try:
                days, hours, minutes = parse.parse_time(user)
            except ValueError:
                continue
                if days == 0:
                    if datetime.now().hour == 10 and not user.match_started_notifs['day_left']:
                        bot.send_message(user.id, LANG_DICT[user.language]['match_today_msg'])
                        bot.send_message(user.id, get_match_info(user),
                                         parse_mode='markdown')
                        users_controller.update_match_started_notifs(user, 'day_left')
                    elif hours == 0 and minutes == 10 and not user.match_started_notifs['ten_minutes_left']:
                        bot.send_message(user.id, LANG_DICT[user.language]['ten_minutes_left_msg'])
                        users_controller.update_match_started_notifs(user, 'ten_minutes_left')
                        send_match_links(bot, user)
                    else:
                        users_controller.update_match_started_notifs(user)
                elif days == -1 and hours == 23 and minutes == 59 and not user.match_started_notifs['started']:
                    bot.send_message(user.id, LANG_DICT[user.language]['match_started_msg'])
                    users_controller.update_match_started_notifs(user, 'started')
                    send_match_links(bot, user)
Ejemplo n.º 8
0
 def test_parse_time(self):
     self.assertEqual(parse.parse_time('1.1.2001 12:30'), 31667400000)
Ejemplo n.º 9
0
def handle_text_broadcast_users(bot, users):
    if datetime.now().minute % 5 == 0:
        for user in users:
            days, hours, minutes = parse.parse_time(user)
            if days == -1 and hours == 23 and minutes == 59:
                threading.Thread(target=start_text_broadcast, args=(bot, users,)).start()