def load(self): """ Load all data from backend A single query is performed and the result set is parsed afterwards. """ pisiprogress.getCallback().verbose("Google Calendar: Loading") feed = self.cal_client.GetCalendarEventFeed('/calendar/feeds/'+self.calendarid+'/private/full?max-results=%d' %(GOOGLE_CALENDAR_MAXRESULTS)) pisiprogress.getCallback().progress.setProgress(20) # we guess that the actual query took up 20 % of the time - the remaining 80 % are taken by parsing the content ... pisiprogress.getCallback().update('Loading') count = 0 inTotal = len(feed.entry) for i, an_event in enumerate(feed.entry): globalId, updated, attributes = self._geventToPisiEvent(an_event) if globalId == None: globalId = events.assembleID() tmpEvent = events.Event( globalId, updated, attributes ) tmpEvent.attributes['globalid'] = globalId self.replaceEvent(globalId, tmpEvent) else: tmpEvent = events.Event( globalId, updated, attributes) self._allEvents[globalId] = tmpEvent self._googleevents[globalId] = an_event count+=1 pisiprogress.getCallback().progress.setProgress(20 + ((count*80) / inTotal)) pisiprogress.getCallback().update('Loading')
def load(self): """ Load all data from backend For data parsing (VCF) the tools layer in L{vobjecttools} is used. """ pisiprogress.getCallback().progress.push(0, 100) pisiprogress.getCallback().verbose("SyncML: Loading") if_calendar = SyncmlModule.SyncmlCalendarInterface(self._url, self._username, self._password, self._database, SYNCMLSERVER_IDENTIFIER) events_raw = if_calendar.downloadItems() # load if_calendar.finish() pisiprogress.getCallback().progress.setProgress(20) pisiprogress.getCallback().update("Loading") i = 0 for x in events_raw.keys(): print events_raw[x] content = vobject.readOne(events_raw[x]) if content.contents.has_key('vevent'): # maybe it's an empty file - you new know ;) for y in content.contents['vevent']: atts, globalId, updated = vobjecttools.extractICSEntry(y) if not globalId or globalId == "": globalId = events.assembleID() tmpEvent = events.Event( globalId, updated, atts) tmpEvent.attributes['globalid'] = globalId self.replaceEvent(globalId, tmpEvent) else: tmpEvent = events.Event(globalId, updated, atts) tmpEvent.attributes['globalid'] = globalId self._allEvents[globalId] = tmpEvent self._mapping[globalId] = x i += 1 pisiprogress.getCallback().progress.setProgress(20 + ((i*80) / len(events_raw))) pisiprogress.getCallback().update('Loading') pisiprogress.getCallback().progress.drop()