def _run_delete(client, options, args): cal_user_list = client.get_calendar_user_list(options.cal) if not cal_user_list: LOG.error('No calendar matches "' + options.cal + '"') return parser = DateRangeParser() date_range = parser.parse(options.date) titles_list = googlecl.build_titles_list(options.title, args) for cal in cal_user_list: single_events, recurring_events = client.get_events( cal.user, start_date=date_range.start, end_date=date_range.end, titles=titles_list, query=options.query, expand_recurrence=True, ) if options.prompt: LOG.info(safe_encode("For calendar " + unicode(cal))) if single_events: client.DeleteEntryList(single_events, "event", options.prompt) if recurring_events: if date_range.specified_as_range: # if the user specified a date that was a range... client.delete_recurring_events( recurring_events, date_range.start, date_range.end, cal.user, options.prompt ) else: client.delete_recurring_events(recurring_events, date_range.start, None, cal.user, options.prompt) if not (single_events or recurring_events): LOG.warning("No events found that match your options!")
def _list(client, options, args): cal_user_list = client.get_calendar_user_list(options.cal) if not cal_user_list: LOG.error('No calendar matches "' + options.cal + '"') return titles_list = googlecl.build_titles_list(options.title, args) parser = DateRangeParser() date_range = parser.parse(options.date) for cal in cal_user_list: print "" print safe_encode("[" + unicode(cal) + "]") single_events = client.get_events( cal.user, start_date=date_range.start, end_date=date_range.end, titles=titles_list, query=options.query, split=False, ) for entry in single_events: print googlecl.base.compile_entry_string( CalendarEntryToStringWrapper(entry, client.config), options.fields.split(","), delimiter=options.delimiter, )
def full_add_event(self, titles, calendar_user, date, reminder): """Create an event piece by piece (no quick add). Args: titles: List of titles of events. calendar_user: "******" of the calendar to add to. date: Text representation of a date and/or time. reminder: Number of minutes before event to send reminder. Set to 0 for no reminder. Returns: Response entries from batch-inserting the events. """ import atom request_feed = gdata.calendar.CalendarEventFeed() # start_text, _, end_text = googlecl.calendar.date.split_string(date, [',']) parser = DateRangeParser() date_range = parser.parse(date) start_time, end_time = date_range.to_when() for title in titles: event = gdata.calendar.CalendarEventEntry() event.title = atom.Title(text=title) when = gdata.calendar.When(start_time=start_time, end_time=end_time) if reminder: when.reminder.append(gdata.calendar.Reminder(minutes=reminder)) event.when.append(when) request_feed.AddInsert(event, "insert-" + title[0:5]) response_feed = self.ExecuteBatch(request_feed, USER_BATCH_URL_FORMAT % calendar_user) return response_feed.entry
def full_add_event(self, titles, calendar_user, date, reminder): """Create an event piece by piece (no quick add). Args: titles: List of titles of events. calendar_user: "******" of the calendar to add to. date: Text representation of a date and/or time. reminder: Number of minutes before event to send reminder. Set to 0 for no reminder. Returns: Response entries from batch-inserting the events. """ import atom request_feed = gdata.calendar.CalendarEventFeed() # start_text, _, end_text = googlecl.calendar.date.split_string(date, [',']) parser = DateRangeParser() date_range = parser.parse(date) start_time, end_time = date_range.to_when() for title in titles: event = gdata.calendar.CalendarEventEntry() event.title = atom.Title(text=title) when = gdata.calendar.When(start_time=start_time, end_time=end_time) if reminder: when.reminder.append(gdata.calendar.Reminder(minutes=reminder)) event.when.append(when) request_feed.AddInsert(event, 'insert-' + title[0:5]) response_feed = self.ExecuteBatch(request_feed, USER_BATCH_URL_FORMAT % calendar_user) return response_feed.entry
def _run_delete(client, options, args): cal_user_list = client.get_calendar_user_list(options.cal) if not cal_user_list: LOG.error('No calendar matches "' + options.cal + '"') return parser = DateRangeParser() date_range = parser.parse(options.date) titles_list = googlecl.build_titles_list(options.title, args) for cal in cal_user_list: single_events, recurring_events = client.get_events( cal.user, start_date=date_range.start, end_date=date_range.end, titles=titles_list, query=options.query, expand_recurrence=True) if options.prompt: LOG.info(safe_encode('For calendar ' + unicode(cal))) if single_events: client.DeleteEntryList(single_events, 'event', options.prompt) if recurring_events: if date_range.specified_as_range: # if the user specified a date that was a range... client.delete_recurring_events(recurring_events, date_range.start, date_range.end, cal.user, options.prompt) else: client.delete_recurring_events(recurring_events, date_range.start, None, cal.user, options.prompt) if not (single_events or recurring_events): LOG.warning('No events found that match your options!')
def _list(client, options, args): cal_user_list = client.get_calendar_user_list(options.cal) if not cal_user_list: LOG.error('No calendar matches "' + options.cal + '"') return titles_list = googlecl.build_titles_list(options.title, args) parser = DateRangeParser() date_range = parser.parse(options.date) for cal in cal_user_list: print '' print safe_encode('[' + unicode(cal) + ']') single_events = client.get_events(cal.user, start_date=date_range.start, end_date=date_range.end, titles=titles_list, query=options.query, split=False) for entry in single_events: print googlecl.base.compile_entry_string( CalendarEntryToStringWrapper(entry, client.config), options.fields.split(','), delimiter=options.delimiter)