def get_todolist(user, client):
# Try the primary calendar first, as this is the default for the
# vast majority of users.
default = client.calendars().get(calendarId='primary').execute()
event = _get_todolist(user, client, default)
if event is not None:
return event, default
# Now look at the user's other calendars to see if it's on there.
calendars = client.calendarList().list().execute()
for calendar in calendars.get('items', ()):
if calendar['id'] == default['id']:
continue
if not calendar['accessRole'] in ('owner', 'writer'):
continue
event = _get_todolist(user, client, calendar)
if event is not None:
return event, calendar
# They don't have one, so add it to their default calendar.
return None, default
评论列表
文章目录