From: James French Date: Mon, 2 Aug 2010 04:54:00 +0000 (+0800) Subject: Checks for the correct opening stanza X-Git-Tag: 0.7~11 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=aace9ea8b2dbcdbdc1b3ed30a672a52b0a619e3f;p=frenchie%2Ficalparse.git Checks for the correct opening stanza --- 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