From ab19510e73ff3048acb58aa648b86c58c4ea9882 Mon Sep 17 00:00:00 2001 From: James French Date: Mon, 2 Aug 2010 00:04:49 +0800 Subject: [PATCH] Comment cleaup, added function --- icalparse.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/icalparse.py b/icalparse.py index 3b9091a..5010d1d 100755 --- a/icalparse.py +++ b/icalparse.py @@ -28,8 +28,6 @@ import os class InvalidICS(Exception): pass class notJoined(Exception): pass -# RFC5545 and RFC5546 iCalendar registries contain upper case letters -# and dashes only and are separated from the value by a colon (:) icalEntry = re.compile('^[A-Z\-]+:.*') def lineJoiner(oldcal): @@ -38,8 +36,6 @@ def lineJoiner(oldcal): if list(oldcal) == oldcal: oldcal = '\r\n'.join(oldcal) - # RFC2445 This sequence defines a content 'fold' and needs to be stripped - # from the output before writing the file oldcal.replace('\r\n ', '') return oldcal.split('\r\n') @@ -47,11 +43,14 @@ def lineJoiner(oldcal): def lineFolder(oldcal, length=75): '''Folds content lines to a specified length, returns a list''' + if length > 75: + sys.stderr.write('WARN: lines > 75 octets are not RFC compliant\n') + cal = [] sl = length - 1 for line in oldcal: - # Line & line ending line ending fit inside length, do nothing + # Line fits inside length, do nothing if len(line.rstrip()) <= length: cal.append(line) else: @@ -64,6 +63,10 @@ def lineFolder(oldcal, length=75): return cal +def getContent(url='',stdin=False): + pass + + if __name__ == '__main__': from optparse import OptionParser # If the user passed us a 'stdin' argument, we'll go with that, @@ -125,9 +128,3 @@ if __name__ == '__main__': if options.stdin: content = sys.stdin.read() - - # RFC5545 and RFC5546 New calendars should be generated UTF-8 and we need to - # be able to read ANSI as well. This should take care of us. - content = unicode(content, encoding='utf-8') - - #return content -- 2.20.1