changeset 98:fe3bfabf0b5f

Rename settings dest_* and source_* to dst_* and src_* respectively.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 06 Oct 2016 15:49:05 +0300
parents 524915af5e87
children 4b84bb5bb8b5
files example.cfg multimerge.py
diffstat 2 files changed, 33 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/example.cfg	Thu Oct 06 15:23:54 2016 +0300
+++ b/example.cfg	Thu Oct 06 15:49:05 2016 +0300
@@ -13,19 +13,19 @@
 ### Calendar settings
 ###
 # Regular expression to match the SOURCE calendars by name
-#source_regex = ^R:\s*(.*?)\s*\(\s*(.+?)\s*\)\s*$
+#src_regex = ^R:\s*(.*?)\s*\(\s*(.+?)\s*\)\s*$
 
 # Mapping of source regexp submatches
-#source_regmap = 1, 2
+#src_regmap = 1, 2
 
-# Destination calendar name (MUST match dest_regex)
-dest_name = Raahen kansainvälisyystoiminta [{0}]
+# Destination calendar name (MUST match dst_regex)
+dst_name = Raahen kansainvälisyystoiminta [{0}]
 
-# Destination calendar name regexp (or use dest_id)
-dest_regex = ^Raahen kansainvälisyystoiminta
+# Destination calendar name regexp (or use dst_id)
+dst_regex = ^Raahen kansainvälisyystoiminta
 
-# Destination calendar ID (not needed if dest_regex is set)
-#dest_id = 
+# Destination calendar ID (not needed if dst_regex is set)
+#dst_id = 
 
 
 ###
--- a/multimerge.py	Thu Oct 06 15:23:54 2016 +0300
+++ b/multimerge.py	Thu Oct 06 15:49:05 2016 +0300
@@ -366,13 +366,13 @@
 cfg.mdef("email_srv_user", True, cfg.is_string, None, None)
 cfg.mdef("email_srv_password", True, cfg.is_string, None, None)
 
-cfg.mdef("source_regex", True, cfg.is_string, None, u"^R:\s*(.*?)\s*\(\s*(.+?)\s*\)\s*$")
-cfg.mdef("source_regmap", False, cfg.is_list, cfg.trans_list, [1, 2])
-cfg.mdef("source_regmap_len", False, None, None, len(cfg.source_regmap))
+cfg.mdef("src_regex", True, cfg.is_string, None, u"^R:\s*(.*?)\s*\(\s*(.+?)\s*\)\s*$")
+cfg.mdef("src_regmap", False, cfg.is_list, cfg.trans_list, [1, 2])
+cfg.mdef("src_regmap_len", False, None, None, len(cfg.src_regmap))
 
-cfg.mdef("dest_name", True, cfg.is_string, None, None)
-cfg.mdef("dest_regex", True, cfg.is_string, None, None)
-cfg.mdef("dest_id", True, cfg.is_string, None, None)
+cfg.mdef("dst_name", True, cfg.is_string, None, None)
+cfg.mdef("dst_regex", True, cfg.is_string, None, None)
+cfg.mdef("dst_id", True, cfg.is_string, None, None)
 
 cfg.mdef("noauth_local_webserver", False, None, None, True)
 #cfg.mdef("auth_host_name", False, None, None, "localhost")
@@ -426,17 +426,17 @@
         cfg.mset("email_ok", True)
 
 
-if len(cfg.source_regmap) != cfg.source_regmap_len:
-    gcm_fatal(u"Setting source_regmap list must be {0} items.".format(cfg.source_regmap_len))
+if len(cfg.src_regmap) != cfg.src_regmap_len:
+    gcm_fatal(u"Setting src_regmap list must be {0} items.".format(cfg.src_regmap_len))
 else:
     # Force to integers
     try:
-        cfg.source_regmap = map(lambda x: int(x), cfg.source_regmap)
+        cfg.src_regmap = map(lambda x: int(x), cfg.src_regmap)
     except Exception as e:
-        gcm_fatal(u"Invalid source_regmap: {0}".format(str(e)))
+        gcm_fatal(u"Invalid src_regmap: {0}".format(str(e)))
 
 
-if not cfg.dest_regex and not cfg.dest_id:
+if not cfg.dst_regex and not cfg.dst_id:
     gcm_fatal(u"Target calendar ID or name required, but not set.")
 
 
@@ -470,17 +470,17 @@
 
 
 ## Filter desired SOURCE calendars based on specified regexp
-src_re = re.compile(cfg.source_regex, re.UNICODE)
-dst_re = re.compile(cfg.dest_regex, re.UNICODE)
+src_re = re.compile(cfg.src_regex, re.UNICODE)
+dst_re = re.compile(cfg.dst_regex, re.UNICODE)
 src_calendars = []
 dst_calendar = None
 for calendar in calendars:
     if u"summary" in calendar:
         # Find destination calendar ID if not set
-        if not cfg.dest_id and dst_re.match(calendar["summary"]):
-            cfg.mset("dest_id", calendar["id"])
+        if not cfg.dst_id and dst_re.match(calendar["summary"]):
+            cfg.mset("dst_id", calendar["id"])
             dst_calendar = calendar
-        elif cfg.dest_id and calendar["id"] == cfg.dest_id:
+        elif cfg.dst_id and calendar["id"] == cfg.dst_id:
             dst_calendar = calendar
 
         # If summary or summaryOverride match the regexp, add calendar
@@ -489,8 +489,8 @@
             mre = src_re.match(calendar[u"summaryOverride"])
 
         if mre:
-            calendar["gcm_title"] = mre.group(cfg.source_regmap[0])
-            calendar["gcm_id"] = mre.group(cfg.source_regmap[1])
+            calendar["gcm_title"] = mre.group(cfg.src_regmap[0])
+            calendar["gcm_id"] = mre.group(cfg.src_regmap[1])
             src_calendars.append(calendar)
 
 gcm_debug(3, u"{0} source calendars found.".format(len(src_calendars)))
@@ -498,7 +498,7 @@
 
 ## Check if we have destination calendar ID
 if not dst_calendar:
-    gcm_fatal(u"Could not find target/destination calendar ID for '"+ cfg.dest_name +"'.")
+    gcm_fatal(u"Could not find target/destination calendar ID for '"+ cfg.dst_name +"'.")
 else:
     gcm_debug(3, u"Target calendar '{0}' [ ID: {1} ]".format(dst_calendar["summary"], dst_calendar["id"]))
 
@@ -550,7 +550,7 @@
 ## Get current events
 gcm_debug(3, u"Fetching current target calendar events.")
 result = service.events().list(
-    calendarId=cfg.dest_id,
+    calendarId=cfg.dst_id,
     singleEvents=True,
     showDeleted=True,
     ).execute()
@@ -580,7 +580,7 @@
                 event.pop("sequence", None)
                 event.pop("id", None)
                 event["iCalUID"] = event["gcm_id"]
-                new_event = service.events().update(calendarId=cfg.dest_id, eventId=d_event["id"], body=event).execute()
+                new_event = service.events().update(calendarId=cfg.dst_id, eventId=d_event["id"], body=event).execute()
             except Exception as e:
                 gcm_fatal(u"Failed to update event {0}:\n\n{1}\n\nERROR: {2}\n".format(event["gcm_id"], event, str(e)))
         else:
@@ -593,7 +593,7 @@
         event.pop("id", None)
         event["iCalUID"] = event["gcm_id"]     # Replace Google generated ID with our own
         try:
-            new_event = service.events().insert(calendarId=cfg.dest_id, body=event).execute()
+            new_event = service.events().insert(calendarId=cfg.dst_id, body=event).execute()
         except Exception as e:
             gcm_fatal(u"Failed to insert new event:\n\n{0}\n\nERROR: {1}\n".format(event, str(e)))
 
@@ -609,7 +609,7 @@
         gcm_debug(4, u"Deleting event {0}".format(event["gcm_id"]))
         evn_purged += 1
         try:
-            service.events().delete(calendarId=cfg.dest_id, eventId=event["id"]).execute()
+            service.events().delete(calendarId=cfg.dst_id, eventId=event["id"]).execute()
         except Exception as e:
             gcm_fatal(u"Failed to delete stale event:\n{0}\n\nERROR: {1}\n".format(event, str(e)))
 
@@ -624,8 +624,8 @@
 gcm_debug(3, u"Updating target calendar name timestamp {0}".format(t_str))
 
 try:
-    dst_calendar["summary"] = cfg.dest_name.format(t_str)
-    new_calendar = service.calendars().update(calendarId=cfg.dest_id, body=dst_calendar).execute()
+    dst_calendar["summary"] = cfg.dst_name.format(t_str)
+    new_calendar = service.calendars().update(calendarId=cfg.dst_id, body=dst_calendar).execute()
 except Exception as e:
     gcm_fatal(u"Failed to update target calendar:\n{0}\n\nERROR: {1}\n".format(dst_calendar, str(e)))