コード例 #1
0
 def extract_cancelled_event(row, date_str=''):
     event = LSFEvent()
     td_tags = row.find_all('td')
     if len(td_tags) != 0:
         begin_str = LSFTextUtils.correct_time_string(LSFTextUtils.remove_spaces(td_tags[0].text))
         end_str = LSFTextUtils.correct_time_string(td_tags[1].text)
         event.begin = datetime.strptime(date_str + ' ' + begin_str, '%d.%m.%Y %H:%M')
         event.end = datetime.strptime(date_str + ' ' + end_str, '%d.%m.%Y %H:%M')
         event.id = td_tags[2].text
         event.title = LSFTextUtils.remove_new_line_and_tab(td_tags[3].text)
         event.event_link = td_tags[3].find('a')['href']
         event.student_group = LSFTextUtils.remove_spaces_at_beginning(td_tags[4].text)
         event.lecturer = LSFTextUtils.remove_spaces_at_beginning(td_tags[5].text)
         event.cancel_note = td_tags[6].text
     return event
コード例 #2
0
 def extract_normal_event(row, date_str=''):
     event = LSFEvent()
     td_tags = row.find_all('td')
     if len(td_tags) != 0:
         campus_and_building = LSFTextUtils.split_string_at_nth_space(td_tags[4].text, 1)
         begin_str = LSFTextUtils.correct_time_string(LSFTextUtils.remove_spaces(td_tags[0].text))
         end_str = LSFTextUtils.correct_time_string(td_tags[1].text)
         event.begin = datetime.strptime(date_str + ' ' + begin_str, '%d.%m.%Y %H:%M')
         event.end = datetime.strptime(date_str + ' ' + end_str, '%d.%m.%Y %H:%M')
         event.id = td_tags[2].text
         event.title = LSFTextUtils.remove_new_line_and_tab(td_tags[3].text)
         event.event_link = td_tags[3].find('a')['href']
         event.campus = LSFTextUtils.remove_spaces_at_end(campus_and_building[0])
         event.building = LSFTextUtils.rename_TGS(campus_and_building[1])
         event.room = LSFTextUtils.remove_new_line_and_tab(LSFTextUtils.split_string_at_last_space(td_tags[5].text)[1])
         event.room_link = td_tags[5].find('a')['href']
         event.student_group = LSFTextUtils.remove_spaces_at_beginning(td_tags[6].text)
         event.lecturer = LSFTextUtils.remove_spaces_at_beginning(td_tags[7].text)
     return event