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,
|
TypedDict,
|
||||||
TypeAlias,
|
TypeAlias,
|
||||||
Literal,
|
Literal,
|
||||||
|
NamedTuple,
|
||||||
)
|
)
|
||||||
|
|
||||||
import google.auth
|
import google.auth
|
||||||
@ -84,6 +85,11 @@ EventList: TypeAlias = List[EventData]
|
|||||||
EventTuple: TypeAlias = Tuple[EventData, EventData]
|
EventTuple: TypeAlias = Tuple[EventData, EventData]
|
||||||
|
|
||||||
|
|
||||||
|
class EventsSearchResults(NamedTuple):
|
||||||
|
exists: List[EventTuple]
|
||||||
|
new: List[EventData]
|
||||||
|
|
||||||
|
|
||||||
class GoogleCalendarService:
|
class GoogleCalendarService:
|
||||||
"""class for make google calendar service Resource
|
"""class for make google calendar service Resource
|
||||||
|
|
||||||
@ -227,14 +233,14 @@ class GoogleCalendar:
|
|||||||
self.logger.info("%d events listed", len(events))
|
self.logger.info("%d events listed", len(events))
|
||||||
return 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
|
"""find existing events from list, by 'iCalUID' field
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
events {list} -- list of events
|
events {list} -- list of events
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
tuple -- (events_exist, events_not_found)
|
EventsSearchResults -- (events_exist, events_not_found)
|
||||||
events_exist - list of tuples: (new_event, exists_event)
|
events_exist - list of tuples: (new_event, exists_event)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -277,7 +283,7 @@ class GoogleCalendar:
|
|||||||
i += 1
|
i += 1
|
||||||
batch.execute()
|
batch.execute()
|
||||||
self.logger.info("%d events exists, %d not found", len(exists), len(not_found))
|
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):
|
def insert_events(self, events: EventList):
|
||||||
"""insert list of events
|
"""insert list of events
|
||||||
|
Loading…
x
Reference in New Issue
Block a user