Checks for the correct opening stanza
authorJames French <[email protected]>
Mon, 2 Aug 2010 04:54:00 +0000 (12:54 +0800)
committerJames French <[email protected]>
Mon, 2 Aug 2010 04:54:00 +0000 (12:54 +0800)
icalparse.py

index 713e9f3..110a19a 100755 (executable)
@@ -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

UCC git Repository :: git.ucc.asn.au