def fetchEvents(self, min_time:datetime.datetime, timedelta_in_days:int=90, calender_id:str=modification.calendar_id(), order_by="startTime", max_results:int=500, time_boundery=modification.timeBoundery()): """ holt google events und gibt sie im eigenen Event-Datentyp zurück :param min_time: zeitpunkt ab welchem events geholt werden sollen :param timedelta_in_days: zeitraum für den Events geholt werden sollen :param order_by: "startTime"or"updated" :param time_boundery: zeitüberhang für termin der zu kurze abfolge erkennbar ewerden lässt :return: list(google_tools.Event()'s) """ events = [] google_event: dict for google_event in self.fetchGoogleEvents( min_time=min_time, timedelta_in_days=timedelta_in_days , calender_id=calender_id, order_by=order_by, max_results=max_results, single_events=True): start = google_event["start"] starttime_string = start.get("dateTime", None) if start.get("dateTime", None) else start.get("date", None) end = google_event["end"] endtime_string = end.get("dateTime", None) if end.get("dateTime", None) else end.get("date", None) event = Event(start=self.timeStringToDateTime(starttime_string), end=self.timeStringToDateTime(endtime_string), company_name=google_event["summary"], location=google_event.get("location", " "), duration=None, time_boundery=time_boundery, description=google_event.get("description", "")) events.append(event) return events
def _deleteEvents(self, min_time:datetime.datetime, time_delta_in_days:int=60, calender_id:str=modification.calendar_id(), max_results=30): """ACHTUNG dev und debugtool""" warnings.warn("ACHTUNG du bist dabei im Kalender zu LÖSCHEN!!!!", UserWarning) if not input(f"(Y/N)") in ("Y"): return google_events = self.fetchGoogleEvents(min_time=min_time, calender_id=calender_id, timedelta_in_days=time_delta_in_days, max_results=max_results, single_events=True) for google_event in google_events: self.service.events().delete(calendarId='primary', eventId=google_event["id"]).execute()
def createGoogleEvent(self, my_event:Event, calender_id=modification.calendar_id(), color_id=modification.color_id()): """ erzeugt google-event aus google_tools.Event() :return: """ reminder_stats = self.createReminderStats() event = self.createEventDict(start_time=my_event.start, end_time=my_event.end, company=my_event.company_name, description=my_event.description, location=my_event.location, reminder_list=reminder_stats, color_id=color_id) print(f"nach google soll eingespeist werden: calendar_id: {calender_id}, body: {event}") event = self.service.events().insert(calendarId=calender_id, body=event).execute() print('Event created: %s' % (event.get('htmlLink')))
def fetchGoogleEvents(self, min_time:datetime.datetime, timedelta_in_days:int=90, calender_id:str=modification.calendar_id(), order_by="startTime", max_results:int=500, single_events=True): """ holt google events und gibt sie im eigenen Event-Datentyp zurück :param min_time: zeitpunkt ab welchem events geholt werden sollen :param timedelta_in_days: zeitraum für den Events geholt werden sollen :param order_by: "startTime"or"updated" :param time_boundery: zeitüberhang für termin der zu kurze abfolge erkennbar ewerden lässt :return: list(google_events-->dict) """ max_time = min_time + datetime.timedelta(days=timedelta_in_days) print(f"{self.f}CalendarId hier!!!!!!!!! : {calender_id} {Fore.RESET}") raw_google_events = self.service.events().list( calendarId=calender_id, timeMin=self.datetimeToTimeString(min_time), timeMax=self.datetimeToTimeString(max_time), maxResults=max_results, singleEvents=single_events, orderBy=order_by).execute() fetched_google_events = raw_google_events.get("items", []) print(f"{self.f}fetched_google_events: {fetched_google_events} {Fore.RESET}") return fetched_google_events
def createEvents(self, events, calender_id=modification.calendar_id(), color_id=modification.color_id()): print(f"{self.f}alle events hier in create Events: {events} {Fore.RESET}") for ev, second in events: print(f"googleevent soll erzeugt werden!!!! event: {ev}") self.createGoogleEvent(my_event=ev, calender_id=calender_id, color_id=color_id)