From: James French Date: Mon, 2 Aug 2010 06:35:01 +0000 (+0800) Subject: More efficient lineFolder implementation X-Git-Tag: 0.7~2 X-Git-Url: https://git.ucc.asn.au/?p=frenchie%2Ficalparse.git;a=commitdiff_plain;h=8deb30a4ba5d4368c59b153df06aeeff60a26dbf;hp=95b8afd961a54b6028c7281e0ad6b9004e47c0be More efficient lineFolder implementation --- diff --git a/icalparse.py b/icalparse.py index 0fd0de7..cc548a3 100755 --- a/icalparse.py +++ b/icalparse.py @@ -60,12 +60,13 @@ def lineFolder(oldcal, length=75): if len(line.rstrip()) <= length: cal.append(line) else: - brokenline = [line[0:length] + '\r\n'] + brokenline = [line[0:length]] ll = length - while ll < len(line.rstrip('\r\n')) + 1: - brokenline.append(' ' + line[ll:sl+ll].rstrip('\r\n') + '\r\n') + while ll < len(line) + 1: + brokenline.append(line[ll:sl+ll]) ll += sl - cal += brokenline + brokenline = '\r\n '.join(brokenline) + cal.append(brokenline) return cal