From aace9ea8b2dbcdbdc1b3ed30a672a52b0a619e3f Mon Sep 17 00:00:00 2001 From: James French Date: Mon, 2 Aug 2010 12:54:00 +0800 Subject: [PATCH] Checks for the correct opening stanza --- icalparse.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/icalparse.py b/icalparse.py index 713e9f3..110a19a 100755 --- a/icalparse.py +++ b/icalparse.py @@ -30,6 +30,9 @@ class notJoined(Exception): pass def lineJoiner(oldcal): '''Takes a string containing a calendar and returns an array of its lines''' + if not oldcal[0:15] == 'BEGIN:VCALENDAR': + raise InvalidICS, "Does not appear to be a valid ICS file" + if list(oldcal) == oldcal: oldcal = '\r\n'.join(oldcal) @@ -149,3 +152,5 @@ if __name__ == '__main__': url = '' content = getContent(url, options.stdin) + cal = lineJoiner(content) + print cal -- 2.20.1