Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes
icalendar.prop.vText Class Reference
Collaboration diagram for icalendar.prop.vText:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def escape
def __repr__
def ical
def from_ical
def __str__

Public Attributes

 params

Static Public Attributes

string encoding = 'utf-8'
tuple from_ical = staticmethod(from_ical)

Detailed Description

Simple text
>>> t = vText(u'Simple text')
>>> t.ical()
'Simple text'

Escaped text
>>> t = vText('Text ; with escaped, chars')
>>> t.ical()
'Text \\\\; with escaped\\\\, chars'

Escaped newlines
>>> vText('Text with escaped\N chars').ical()
'Text with escaped\\\\n chars'

If you pass a unicode object, it will be utf-8 encoded. As this is the
(only) standard that RFC 2445 support.

>>> t = vText(u'international chars   ')
>>> t.ical()
'international chars \\xc3\\xa6\\xc3\\xb8\\xc3\\xa5 \\xc3\\x86\\xc3\\x98\\xc3\\x85 \\xc3\\xbc'

Unicode is converted to utf-8
>>> t = vText(u'international   ')
>>> str(t)
'international \\xc3\\xa6 \\xc3\\xb8 \\xc3\\xa5'

and parsing?
>>> vText.from_ical('Text \\; with escaped\\, chars')
u'Text ; with escaped, chars'

>>> print vText.from_ical('A string with\\; some\\\\ characters in\\Nit')
A string with; some\\ characters in
it

Definition at line 940 of file prop.py.


Constructor & Destructor Documentation

def icalendar.prop.vText.__init__ (   self,
  args,
  kwargs 
)

Definition at line 979 of file prop.py.

00979 
00980     def __init__(self, *args, **kwargs):
00981         unicode.__init__(self, *args, **kwargs)
00982         self.params = Parameters()


Member Function Documentation

Definition at line 995 of file prop.py.

00995 
00996     def __repr__(self):
00997         return u"vText(%s)" % unicode.__repr__(self)

Definition at line 1015 of file prop.py.

01015 
01016     def __str__(self):
01017         return self.ical()
01018 
01019 

Here is the call graph for this function:

def icalendar.prop.vText.escape (   self,
  value 
)
Format value according to iCalendar TEXT escaping rules.

Definition at line 983 of file prop.py.

00983 
00984     def escape(self, value):
00985         """
00986         Format value according to iCalendar TEXT escaping rules.
00987         """
00988         return (value.replace('\N', '\n')
00989                      .replace('\\', '\\\\')
00990                      .replace(';', r'\;')
00991                      .replace(',', r'\,')
00992                      .replace('\r\n', r'\n')
00993                      .replace('\n', r'\n')
00994                      )

Here is the caller graph for this function:

Definition at line 1001 of file prop.py.

01001 
01002     def from_ical(ical):
01003         "Parses the data format from ical text format"
01004         try:
01005             ical = (ical.replace(r'\N', r'\n')
01006                         .replace(r'\r\n', '\n')
01007                         .replace(r'\n', '\n')
01008                         .replace(r'\,', ',')
01009                         .replace(r'\;', ';')
01010                         .replace('\\\\', '\\'))
01011             return ical.decode(vText.encoding)
01012         except:
            raise ValueError, 'Expected ical text, got: %s' % ical
def icalendar.prop.vText.ical (   self)

Definition at line 998 of file prop.py.

00998 
00999     def ical(self):
01000         return self.escape(self).encode(self.encoding)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

string icalendar.prop.vText.encoding = 'utf-8' [static]

Definition at line 977 of file prop.py.

tuple icalendar.prop.vText.from_ical = staticmethod(from_ical) [static]

Definition at line 1013 of file prop.py.

Definition at line 981 of file prop.py.


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