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/?a=commitdiff_plain;h=8deb30a4ba5d4368c59b153df06aeeff60a26dbf;p=frenchie%2Ficalparse.git 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