chiark / gitweb /
handle empty subjects when matching
[gooswapper] / gooswapper.py
index 9f4cefa271a7ff60e1ef96d04db36b070e419a98..ffad0e0bbf82a697dcf573d0a0cb7ecaf0bd4c21 100644 (file)
@@ -325,23 +325,26 @@ def update_ex_to_gcal(ex_acct,
                                                body=gevent,
                                                sendUpdates="none").execute()
 
-def match_ex_to_gcal(ex_acct,gcal_acct,gcal_tz,events,gcal_id="primary"):
+def match_ex_to_gcal(ex_acct,gcal_acct,gcal_tz,events,gcal_id="primary",ignore_link=True):
     recur = 0
     matched = 0
     skipped = 0
     for ev_id in events:
         event = get_ex_event_by_itemid(ex_acct.calendar,ev_id)
-        if event.is_recurring:
-            recur += 1
-            continue
-        elif event.gcal_link is not None:
+#        if event.is_recurring:
+#            recur += 1
+#            continue
+#next line needs to be elif if above uncommented
+        if event.gcal_link is not None and ignore_link is False:
             skipped += 1
             continue
         matches = gcal_acct.events().list(calendarId=gcal_id,
                                           timeMin=event.start.isoformat(),
                                           timeMax=event.end.isoformat()).execute()
         for ge in matches['items']:
-            if ge['summary'].strip()==event.subject.strip():
+            if ( ge.get("summary") is None and event.subject is None ) or \
+               ( ge.get("summary") is not None and event.subject is not None \
+                 and ge['summary'].strip()==event.subject.strip()):
                 logger.info("Matching '%s' starting at %s" % (event.subject,
                                                               event.start.isoformat()))
                 event.gcal_link = ge['id']