mirror of
https://github.com/b4tman/sync_ics2gcal
synced 2025-01-21 07:28:24 +00:00
types: + EventsSearchResults
This commit is contained in:
parent
5b4dca0ab9
commit
54146451c7
@ -11,6 +11,7 @@ from typing import (
|
||||
TypedDict,
|
||||
TypeAlias,
|
||||
Literal,
|
||||
NamedTuple,
|
||||
)
|
||||
|
||||
import google.auth
|
||||
@ -84,6 +85,11 @@ EventList: TypeAlias = List[EventData]
|
||||
EventTuple: TypeAlias = Tuple[EventData, EventData]
|
||||
|
||||
|
||||
class EventsSearchResults(NamedTuple):
|
||||
exists: List[EventTuple]
|
||||
new: List[EventData]
|
||||
|
||||
|
||||
class GoogleCalendarService:
|
||||
"""class for make google calendar service Resource
|
||||
|
||||
@ -227,14 +233,14 @@ class GoogleCalendar:
|
||||
self.logger.info("%d events listed", len(events))
|
||||
return events
|
||||
|
||||
def find_exists(self, events: List) -> Tuple[List[EventTuple], EventList]:
|
||||
def find_exists(self, events: List) -> EventsSearchResults:
|
||||
"""find existing events from list, by 'iCalUID' field
|
||||
|
||||
Arguments:
|
||||
events {list} -- list of events
|
||||
|
||||
Returns:
|
||||
tuple -- (events_exist, events_not_found)
|
||||
EventsSearchResults -- (events_exist, events_not_found)
|
||||
events_exist - list of tuples: (new_event, exists_event)
|
||||
"""
|
||||
|
||||
@ -277,7 +283,7 @@ class GoogleCalendar:
|
||||
i += 1
|
||||
batch.execute()
|
||||
self.logger.info("%d events exists, %d not found", len(exists), len(not_found))
|
||||
return exists, not_found
|
||||
return EventsSearchResults(exists, not_found)
|
||||
|
||||
def insert_events(self, events: EventList):
|
||||
"""insert list of events
|
||||
|
Loading…
Reference in New Issue
Block a user