Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes
icalendar.parser.Contentlines Class Reference
Inheritance diagram for icalendar.parser.Contentlines:
Inheritance graph
Collaboration diagram for icalendar.parser.Contentlines:
Collaboration graph

List of all members.

Public Member Functions

def __str__
def from_string

Static Public Attributes

tuple from_string = staticmethod(from_string)

Detailed Description

I assume that iCalendar files generally are a few kilobytes in size. Then
this should be efficient. for Huge files, an iterator should probably be
used instead.

>>> c = Contentlines([Contentline('BEGIN:VEVENT\\r\\n')])
>>> str(c)

Lets try appending it with a 100 charater wide string
>>> c.append(Contentline(''.join(['123456789 ']*10)+'\\r\\n'))
>>> str(c)
'BEGIN:VEVENT\\r\\n\\r\\n123456789 123456789 123456789 123456789 123456789 123456789 123456789 1234\\r\\n 56789 123456789 123456789 \\r\\n'

Notice that there is an extra empty string in the end of the content lines.
That is so they can be easily joined with: '\r\n'.join(contentlines)).
>>> Contentlines.from_string('A short line\\r\\n')
['A short line', '']
>>> Contentlines.from_string('A faked\\r\\n  long line\\r\\n')
['A faked long line', '']
>>> Contentlines.from_string('A faked\\r\\n  long line\\r\\nAnd another lin\\r\\n\\te that is folded\\r\\n')
['A faked long line', 'And another line that is folded', '']

Definition at line 426 of file

Member Function Documentation

Definition at line 451 of file

00452     def __str__(self):
00453         "Simply join self."
00454         return '\r\n'.join(map(str, self))

Definition at line 455 of file

00456     def from_string(st):
00457         "Parses a string into content lines"
00458         try:
00459             # a fold is carriage return followed by either a space or a tab
00460             unfolded = FOLD.sub('', st)
00461             lines = [Contentline(line) for line in unfolded.splitlines() if line]
00462             lines.append('') # we need a '\r\n' in the end of every content line
00463             return Contentlines(lines)
00464         except:
            raise ValueError, 'Expected StringType with content lines'

Member Data Documentation

Definition at line 465 of file

The documentation for this class was generated from the following file: