[CalendarServer-changes] [11390] PyCalendar/trunk/src/pycalendar/calendar.py

source_changes at macosforge.org source_changes at macosforge.org
Fri Jun 21 10:58:14 PDT 2013


Revision: 11390
          http://trac.calendarserver.org//changeset/11390
Author:   cdaboo at apple.com
Date:     2013-06-21 10:58:14 -0700 (Fri, 21 Jun 2013)
Log Message:
-----------
Provide calendar level option for changing a UID on components.

Modified Paths:
--------------
    PyCalendar/trunk/src/pycalendar/calendar.py

Modified: PyCalendar/trunk/src/pycalendar/calendar.py
===================================================================
--- PyCalendar/trunk/src/pycalendar/calendar.py	2013-06-20 18:04:20 UTC (rev 11389)
+++ PyCalendar/trunk/src/pycalendar/calendar.py	2013-06-21 17:58:14 UTC (rev 11390)
@@ -147,6 +147,33 @@
         return result
 
 
+    def changeUID(self, oldUID, newUID):
+        """
+        Change the UID of all components with a matching UID to a new value. We need to
+        do this at the calendar level because this object maintains mappings based on UID
+        which need to be updated whenever the UID changes.
+
+        @param oldUID: the old value to match
+        @type oldUID: C{str}
+        @param newUID: the new value to match
+        @type newUID: C{str}
+        """
+
+        # Each component
+        for component in self.mComponents:
+            if component.getUID() == oldUID:
+                component.setUID(newUID)
+
+        # Maps
+        if oldUID in self.mOverriddenComponentsByUID:
+            self.mOverriddenComponentsByUID[newUID] = self.mOverriddenComponentsByUID[oldUID]
+            del self.mOverriddenComponentsByUID[oldUID]
+        for ctype in self.mMasterComponentsByTypeAndUID:
+            if oldUID in self.mMasterComponentsByTypeAndUID[ctype]:
+                self.mMasterComponentsByTypeAndUID[ctype][newUID] = self.mMasterComponentsByTypeAndUID[ctype][oldUID]
+                del self.mMasterComponentsByTypeAndUID[ctype][oldUID]
+
+
     def finalise(self):
         # Get calendar name if present
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130621/4c31daf7/attachment.html>


More information about the calendarserver-changes mailing list