Revision
3581
Author
cdaboo@apple.com
Date
2009-01-09 11:26:30 -0800 (Fri, 09 Jan 2009)

Log Message

Handle the case where an entire line has \'s on it.

Modified Paths

Diff

Modified: CalendarServer/trunk/calendarserver/tools/fixcalendardata.py (3580 => 3581)


--- CalendarServer/trunk/calendarserver/tools/fixcalendardata.py	2009-01-09 17:09:46 UTC (rev 3580)
+++ CalendarServer/trunk/calendarserver/tools/fixcalendardata.py	2009-01-09 19:26:30 UTC (rev 3581)
@@ -89,7 +89,9 @@
                 level2Path = os.path.join(level1Path, "%02X" % (j,))
                 if os.path.exists(level2Path):
                     for item in os.listdir(level2Path):
-                        scanCalendarHome(basePath, os.path.join(level2Path, item), scanFile, doFix)
+                        calendarHome = os.path.join(level2Path, item)
+                        if os.path.isdir(calendarHome):
+                            scanCalendarHome(basePath, calendarHome, scanFile, doFix)
 
 def scanCalendarHome(basePath, calendarHome, scanFile, doFix):
     print "Scanning: %s" % (calendarHome,)
@@ -134,7 +136,7 @@
 
         # See whether there is a \" that needs fixing.
         # NB Have to handle the case of a folded line... 
-        if icsData.find('\\"') != -1 or icsData.find('\\\r\n "') != -1:
+        if icsData.find('\\"') != -1 or icsData.find('\\\r\n "') != -1 or icsData.find('\r\n \r\n "') != -1:
             if doFix:
                 if fixPath(icsPath, icsData):
                     didFix = True
@@ -208,7 +210,7 @@
         
     # Fix by continuously replacing \" with " until no more replacements occur
     while True:
-        newIcsData = icsData.replace('\\"', '"').replace('\\\r\n "', '\r\n "')
+        newIcsData = icsData.replace('\\"', '"').replace('\\\r\n "', '\r\n "').replace('\r\n \r\n "', '\r\n "')
         if newIcsData == icsData:
             break
         else: