From 0456d166cc1adb8ba910d82f2f682513c5fcfdca Mon Sep 17 00:00:00 2001 From: deronnax Date: Thu, 7 Aug 2014 17:52:39 +0200 Subject: [PATCH] simpler and faster unfold function --- radicale/ical.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/radicale/ical.py b/radicale/ical.py index 23b6ae2..878b7f2 100644 --- a/radicale/ical.py +++ b/radicale/ical.py @@ -28,6 +28,7 @@ Define the main classes of a collection as seen from the server. import os import posixpath import hashlib +import re from uuid import uuid4 from random import randint from contextlib import contextmanager @@ -58,14 +59,7 @@ def unfold(text): Read rfc5545-3.1 for info. """ - lines = [] - for line in text.splitlines(): - if lines and (line.startswith(" ") or line.startswith("\t")): - lines[-1] += line[1:] - else: - lines.append(line) - return lines - + return re.sub('\r\n( |\t)', '', text).splitlines() class Item(object): """Internal iCal item."""