changeset 111:8b773358ad47 rel-0.9

Use "id" field in source calendar events gcm_id generation, and "iCalUID" for the target calendar.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 18 Oct 2016 12:30:19 +0300
parents c6771a596d77
children c0c177950dac
files multimerge.py
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/multimerge.py	Tue Oct 18 12:29:13 2016 +0300
+++ b/multimerge.py	Tue Oct 18 12:30:19 2016 +0300
@@ -133,13 +133,13 @@
 
 
 ## Generate gcm IDs for given list of events
-def gcm_generate_ids(events, calendar_id, sep):
+def gcm_generate_ids(events, calendar_id, sep, field):
     if not events:
         return events
 
-    for ev in events:
-        ev["gcm_cal_id"] = calendar_id
-        ev["gcm_id"] = calendar_id + sep + ev["iCalUID"]
+    for event in events:
+        event["gcm_cal_id"] = calendar_id
+        event["gcm_id"] = calendar_id + sep + event[field]
 
     return events
 
@@ -560,7 +560,7 @@
             gcm_debug(4, u"  No matching event color found!")
 
     # Add events, if any, to main list
-    events = gcm_generate_ids(gcm_fetch_events(calendar["id"], False), calendar["id"], "___")
+    events = gcm_generate_ids(gcm_fetch_events(calendar["id"], False), calendar["id"], "___", "id")
     if events:
         for event in events:
             if event["status"] != u"cancelled":
@@ -574,7 +574,7 @@
 
 ## Get current events
 gcm_debug(3, u"Fetching current target calendar events.")
-dst_events = gcm_generate_ids(gcm_fetch_events(cfg.dst_id, True), "", "")
+dst_events = gcm_generate_ids(gcm_fetch_events(cfg.dst_id, True), "", "", "iCalUID")
 gcm_debug(3, u"Found {0} event(s).".format(len(dst_events)))