def event_factory(raw_event): new_event = Event(raw_event['starts_at'], raw_event['ends_at']) new_event.title = raw_event['title'] new_event.set_teams([player['name'] for player in raw_event['teams']]) print("possible players: {0}".format(new_event.teams)) new_event.set_tags(raw_event['tags_array']) return new_event
def convert_event(self, html_event): event = Event() event.id = self.extract_id(html_event) event.title = self.extract_title(html_event) event.date = self.extract_date(html_event) event.enrollment_date = self.extract_enrollment_date(html_event) return event
def get_events(self): event = Event() event.id = 'unique' event.title = 'Øl øl øl!' event.notification_sent = False event.date = datetime.now() + timedelta(days=1) event.enrollment_date = datetime.now() + timedelta(minutes=10) time.sleep(5) return [event]
def to_event(cls, row): event = Event() if row['id']: event.id = row['id'] if row['title']: event.title = row['title'] if row['notification_sent']: event.notification_sent = row['notification_sent'] if row['date']: event.date = row['date'] if row['enrollment_date']: event.enrollment_date = row['enrollment_date'] return event
def run_query(self): self.__last_result = copy.copy(self.__result) self.__result = [] self.__clients_projects = {} for calendar_name in self.calendars.keys(): calendar = self.calendars[calendar_name] if self.text_query: query = gdata.calendar.service.CalendarEventQuery( calendar, 'private', 'full', self.text_query ) else: query = gdata.calendar.service.CalendarEventQuery( calendar, 'private', 'full' ) if self.date_from: query.start_min = self.date_from.strftime('%Y-%m-%d') self.__last_date_from = copy.copy(self.date_from) if self.date_to: query.start_max = self.date_to.strftime('%Y-%m-%d') self.__last_date_to = copy.copy(self.date_to) query.max_results = self.__max_results feed = self.calendar_service.CalendarQuery(query) for an_event in feed.entry: event = Event() event.staff = calendar_name event.title = an_event.title.text event.content = an_event.content.text for a_when in an_event.when: start_time_ts = time.strptime( a_when.start_time[0:16], '%Y-%m-%dT%H:%M' ) start_time = datetime.datetime( start_time_ts.tm_year, start_time_ts.tm_mon, start_time_ts.tm_mday, start_time_ts.tm_hour, start_time_ts.tm_min ) event.start_time = start_time end_time_ts = time.strptime( a_when.end_time[0:16], '%Y-%m-%dT%H:%M' ) end_time = datetime.datetime( end_time_ts.tm_year, end_time_ts.tm_mon, end_time_ts.tm_mday, end_time_ts.tm_hour, end_time_ts.tm_min ) event.end_time = end_time try: content_text = an_event.content.text.replace( 'desc:', 'description:' ) content_dict = yaml.load(content_text) except Exception, e: print e print 'an_event.title.text:', an_event.title.text for a_when in an_event.when: print time.strptime( a_when.start_time[0:16], '%Y-%m-%dT%H:%M' ) for key in content_dict.keys(): ''' this steps through the content of the description in the event entry to determin the client, project, etc. ''' event.__dict__[key] = content_dict[key] self.__result.append(event) if not self.__clients_projects.has_key(content_dict['client']): self.__clients_projects[content_dict['client']] = {}
def test_notification_status(self): event = Event() event.title = 'Cool title' assert Mapper.to_row(event)['title'] == 'Cool title'