def testParse(self): events = gcal.parse_feed("calendar.xml") expected = [gcal.Event(calendar_title = "Stanford Humanities Center Events", event_title = "Adams Bodomo: What is it like to be an African in China?", event_id = "iir0l1284maac3f9c8rejr8f5c", updated = "2011-09-29T17:58:43.000Z", start_time = datetime.datetime(2011, 10, 13, 13, 30), end_time = datetime.datetime(2011, 10, 13, 15, 30), location = "Stanford Humanities Center Board Room", status = "confirmed", description = """Adams Bodomo will look at what has often been termed "Africa's newest diaspora" by reviewing contemporary Africa - China relations. Closer official interactions between these two areas have led to an increasing number of Africans visiting, settling, and forming communities in China. Bodomo will share the results of a study he undertook with 700 Africans across six main Chinese cities. The research addresses many aspects of everyday life of Africans in China, from why Africans go to China to how they are received by the Chinese state and certainly has theoretical implications for cross-cultural and cross-linguistic studies in an era of globalization.\n\nAdams Bodomo is African Studies Programme Director at the School of Humanities, University of Hong Kong. He obtained his PhD from the Norwegian University of Science and Technology after obtaining Bachelors and Masters Degrees at the University of Ghana. Dr Bodomo has given invited lectures on the topic of Africans in China and on general Africa - China relations studies at several leading universities, including Yale University, SOAS, and Peking University. His latest book is entitled: "Africans in China: An Investigation into the African Presence in China and its Consequences on Africa - China Relations" (in press with Cambria Press, NY).""", thumbnail = None, full_image = None, endowment_title = None)] self.assertEquals(expected[0], events[0])
def main(): gcal_template = ( "http://www.google.com/calendar/feeds/%s/public/basic?" "showdeleted=true&updated-min=2011-08-01T01:00:00-08:00&max-results=1000") threads = [FetchThread(gcal_template % cal.calendar_id) for cal in config.calendar_ids] map(FetchThread.start, threads) # Do work. map(FetchThread.join, threads) # Wait for work to end. events = [] for t in threads: events.extend(gcal.parse_feed(t.document)) posts = blogger.GetPosts() store = datastore.load("database.db") store.update(events, posts) store.save() store.close()