Back to index

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

List of all members.

Public Member Functions

def __init__
def for_property
def ical
def from_ical
def __getitem__
def __setitem__
def __delitem__
def __contains__
def get
def setdefault
def pop
def popitem
def has_key
def update
def copy
def clear
def __repr__

Static Public Attributes

tuple types_map
 Property types.

Detailed Description

All Value types defined in rfc 2445 are registered in this factory class. To
get a type you can use it like this.
>>> factory = TypesFactory()
>>> datetime_parser = factory['date-time']
>>> dt = datetime_parser(datetime(2001, 1, 1))
>>> dt.ical()
'20010101T000000'

A typical use is when the parser tries to find a content type and use text
as the default
>>> value = '20050101T123000'
>>> value_type = 'date-time'
>>> typ = factory.get(value_type, 'text')
>>> typ.from_ical(value)
datetime.datetime(2005, 1, 1, 12, 30)

It can also be used to directly encode property and parameter values
>>> comment = factory.ical('comment', u'by Rasmussen, Max Møller')
>>> str(comment)
'by Rasmussen\\\\, Max M\\xc3\\xb8ller'
>>> factory.ical('priority', 1)
'1'
>>> factory.ical('cn', u'Rasmussen, Max Møller')
'Rasmussen\\\\, Max M\\xc3\\xb8ller'

>>> factory.from_ical('cn', 'Rasmussen\\\\, Max M\\xc3\\xb8ller')
u'Rasmussen, Max M\\xf8ller'

The value and parameter names don't overlap. So one factory is enough for
both kinds.

Definition at line 1268 of file prop.py.


Constructor & Destructor Documentation

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

Reimplemented from icalendar.caselessdict.CaselessDict.

Definition at line 1302 of file prop.py.

01302 
01303     def __init__(self, *args, **kwargs):
01304         "Set keys to upper for initial dict"
01305         CaselessDict.__init__(self, *args, **kwargs)
01306         self['binary'] = vBinary
01307         self['boolean'] = vBoolean
01308         self['cal-address'] = vCalAddress
01309         self['date'] = vDDDTypes
01310         self['date-time'] = vDDDTypes
01311         self['duration'] = vDDDTypes
01312         self['float'] = vFloat
01313         self['integer'] = vInt
01314         self['period'] = vPeriod
01315         self['recur'] = vRecur
01316         self['text'] = vText
01317         self['time'] = vTime
01318         self['uri'] = vUri
01319         self['utc-offset'] = vUTCOffset
01320         self['geo'] = vGeo
01321         self['inline'] = vInline
01322 


Member Function Documentation

def icalendar.caselessdict.CaselessDict.__contains__ (   self,
  item 
) [inherited]

Definition at line 61 of file caselessdict.py.

00061 
00062     def __contains__(self, item):
00063         return dict.__contains__(self, item.upper())

def icalendar.caselessdict.CaselessDict.__delitem__ (   self,
  key 
) [inherited]

Definition at line 58 of file caselessdict.py.

00058 
00059     def __delitem__(self, key):
00060         dict.__delitem__(self, key.upper())

def icalendar.caselessdict.CaselessDict.__getitem__ (   self,
  key 
) [inherited]

Definition at line 52 of file caselessdict.py.

00052 
00053     def __getitem__(self, key):
00054         return dict.__getitem__(self, key.upper())

Here is the caller graph for this function:

Reimplemented in icalendar.cal.Component, and icalendar.parser.Parameters.

Definition at line 92 of file caselessdict.py.

00092 
00093     def __repr__(self):
00094         return 'CaselessDict(' + dict.__repr__(self) + ')'
def icalendar.caselessdict.CaselessDict.__setitem__ (   self,
  key,
  value 
) [inherited]

Definition at line 55 of file caselessdict.py.

00055 
00056     def __setitem__(self, key, value):
00057         dict.__setitem__(self, key.upper(), value)

Here is the caller graph for this function:

def icalendar.caselessdict.CaselessDict.clear (   self) [inherited]

Definition at line 89 of file caselessdict.py.

00089 
00090     def clear(self):
00091         dict.clear(self)

Here is the caller graph for this function:

def icalendar.caselessdict.CaselessDict.copy (   self) [inherited]

Definition at line 86 of file caselessdict.py.

00086 
00087     def copy(self):
00088         return CaselessDict(dict.copy(self))

def icalendar.prop.TypesFactory.for_property (   self,
  name 
)

Definition at line 1411 of file prop.py.

01411 
01412     def for_property(self, name):
01413         "Returns a the default type for a property or parameter"
01414         return self[self.types_map.get(name, 'text')]

Here is the caller graph for this function:

def icalendar.prop.TypesFactory.from_ical (   self,
  name,
  value 
)
Decodes a named property or parameter value from an icalendar encoded
string to a primitive python type.

Definition at line 1423 of file prop.py.

01423 
01424     def from_ical(self, name, value):
01425         """
01426         Decodes a named property or parameter value from an icalendar encoded
01427         string to a primitive python type.
01428         """
01429         type_class = self.for_property(name)
01430         decoded = type_class.from_ical(str(value))
01431         return decoded

Here is the call graph for this function:

def icalendar.caselessdict.CaselessDict.get (   self,
  key,
  default = None 
) [inherited]

Definition at line 64 of file caselessdict.py.

00064 
00065     def get(self, key, default=None):
00066         return dict.get(self, key.upper(), default)

Here is the caller graph for this function:

def icalendar.caselessdict.CaselessDict.has_key (   self,
  key 
) [inherited]

Definition at line 76 of file caselessdict.py.

00076 
00077     def has_key(self, key):
00078         return dict.has_key(self, key.upper())

Here is the caller graph for this function:

def icalendar.prop.TypesFactory.ical (   self,
  name,
  value 
)
Encodes a named value from a primitive python type to an
icalendar encoded string.

Definition at line 1415 of file prop.py.

01415 
01416     def ical(self, name, value):
01417         """
01418         Encodes a named value from a primitive python type to an
01419         icalendar encoded string.
01420         """
01421         type_class = self.for_property(name)
01422         return type_class(value).ical()

Here is the call graph for this function:

def icalendar.caselessdict.CaselessDict.pop (   self,
  key,
  default = None 
) [inherited]

Definition at line 70 of file caselessdict.py.

00070 
00071     def pop(self, key, default=None):
00072         return dict.pop(self, key.upper(), default)

Here is the caller graph for this function:

def icalendar.caselessdict.CaselessDict.popitem (   self) [inherited]

Definition at line 73 of file caselessdict.py.

00073 
00074     def popitem(self):
00075         return dict.popitem(self, key.upper())

def icalendar.caselessdict.CaselessDict.setdefault (   self,
  key,
  value = None 
) [inherited]

Definition at line 67 of file caselessdict.py.

00067 
00068     def setdefault(self, key, value=None):
00069         return dict.setdefault(self, key.upper(), value)

def icalendar.caselessdict.CaselessDict.update (   self,
  indict 
) [inherited]
Multiple keys where key1.upper() == key2.upper() will be lost.

Definition at line 79 of file caselessdict.py.

00079 
00080     def update(self, indict):
00081         """
00082         Multiple keys where key1.upper() == key2.upper() will be lost.
00083         """
00084         for entry in indict:
00085             self[entry] = indict[entry]

Here is the caller graph for this function:


Member Data Documentation

Property types.

Definition at line 1327 of file prop.py.


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