vContent

tests/test_calendar_stream.py

8:c408f51100a9
2008-11-02 Paul Boddie Overhauled the reading and writing to more properly handle folded lines, introducing a ContentLine class for parsing whole content lines, and making a separate Writer class which is able to transparently fold lines for the StreamWriter class. Added iterwrite functions, although their name could be better chosen. Updated the tests to more properly test reading and to test writing.
     1 #!/usr/bin/env python     2      3 import codecs, vCalendar     4      5 f = codecs.open("tests/test.ics", encoding="utf-8")     6 out = codecs.open("tmp.ics", "w", encoding="utf-8")     7 try:     8     doc = vCalendar.iterparse(f)     9     w = vCalendar.iterwrite(out)    10     for name, parameters, value in doc:    11         print "%r, %r, %r" % (name, parameters, value)    12         w.write(name, parameters, value)    13 finally:    14     out.close()    15     f.close()    16     17 # vim: tabstop=4 expandtab shiftwidth=4