def _instance_resource_for_event_in_series(self, event):
        """Searches through the instances of ``event``'s parent series,
        returning the Google Calendar instance resource for with ``start_time``
        that matches ``event``'s.

        :param event: The event to find the instance resource for.
        :type event: :class:`Event`

        :returns: The instance resource that represents ``event``.
        :rtype: dict
        """
        calendar_id = self._calendar_id_for_event(event)
        event_start_date = (GoogleCalendarResourceBuilder.rfc3339(
            event.start_datetime()))
        page_token = None
        while True:
            # Find more instances
            request = self.service.events().instances(calendarId=calendar_id,
                                                      eventId=event.gcal_id,
                                                      pageToken=page_token)
            instances = self._execute_request(request)

            # Look for instances with matching start date
            for instance in instances['items']:
                if instance['start']['dateTime'] == event_start_date:
                    return instance

            # Get the next page of events
            page_token = instances.get('nextPageToken')

            # Quit if there are no more pages
            if not page_token:
                break

        return None
Example #2
0
    def _instance_resource_for_event_in_series(self, event):
        """"""
        calendar_id = self._calendar_id_for_event(event)
        event_start_date = GoogleCalendarResourceBuilder.rfc3339(event.start_datetime())

        page_token = None
        while True:
          request = self.service.events().instances(calendarId=calendar_id,
                                                      eventId=event.gcal_id,
                                                      pageToken=page_token)
          instances = self._execute_request(request)
          for instance in instances['items']:
            if instance['start']['dateTime'] == event_start_date:
                return instance
          page_token = instances.get('nextPageToken')
          if not page_token:
            break

        return None
Example #3
0
    def _instance_resource_for_event_in_series(self, event):
        """"""
        calendar_id = self._calendar_id_for_event(event)
        event_start_date = GoogleCalendarResourceBuilder.rfc3339(
            event.start_datetime())

        page_token = None
        while True:
            request = self.service.events().instances(calendarId=calendar_id,
                                                      eventId=event.gcal_id,
                                                      pageToken=page_token)
            instances = self._execute_request(request)
            for instance in instances['items']:
                if instance['start']['dateTime'] == event_start_date:
                    return instance
            page_token = instances.get('nextPageToken')
            if not page_token:
                break

        return None