git.ucc.asn.au
/
frenchie
/
icalparse.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9fa00de
)
Splits in prep for running the rules
author
James French
<
[email protected]
>
Mon, 2 Aug 2010 05:49:27 +0000
(13:49 +0800)
committer
James French
<
[email protected]
>
Mon, 2 Aug 2010 05:49:27 +0000
(13:49 +0800)
icalparse.py
patch
|
blob
|
history
diff --git
a/icalparse.py
b/icalparse.py
index
2c7ec4e
..
a492dfa
100755
(executable)
--- a/
icalparse.py
+++ b/
icalparse.py
@@
-70,6
+70,19
@@
def lineFolder(oldcal, length=75):
return cal
return cal
+def splitFields(cal):
+ '''Takes a list of lines in a calendar file and returns a list of key, value pairs'''
+
+ ical = [tuple(x.split(':',1)) for x in cal]
+
+ # Check that we got 2 items on every line
+ for line in ical:
+ if not len(line) == 2:
+ raise InvalidICS, "Didn't find a content key on: %s"%(line)
+
+ return ical
+
+
def getContent(url='',stdin=False):
'''Generic content retriever, DO NOT use this function in a CGI script as
it can read from the local disk (which you probably don't want it to).
def getContent(url='',stdin=False):
'''Generic content retriever, DO NOT use this function in a CGI script as
it can read from the local disk (which you probably don't want it to).
@@
-160,4
+173,5
@@
if __name__ == '__main__':
content = getContent(url, options.stdin)
cal = lineJoiner(content)
content = getContent(url, options.stdin)
cal = lineJoiner(content)
- print cal
+ ical = splitFields(cal)
+ print ical
UCC
git Repository :: git.ucc.asn.au