Back to index

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

List of all members.

Public Member Functions

def __init__
def ical
def parse_type
def from_ical
def __str__
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__

Public Attributes

 params

Static Public Attributes

list frequencies
tuple types
tuple parse_type = staticmethod(parse_type)
tuple from_ical = staticmethod(from_ical)

Detailed Description

Let's see how close we can get to one from the rfc:
FREQ=YEARLY;INTERVAL=2;BYMONTH=1;BYDAY=SU;BYHOUR=8,9;BYMINUTE=30

>>> r = dict(freq='yearly', interval=2)
>>> r['bymonth'] = 1
>>> r['byday'] = 'su'
>>> r['byhour'] = [8,9]
>>> r['byminute'] = 30
>>> r = vRecur(r)
>>> r.ical()
'BYHOUR=8,9;BYDAY=SU;BYMINUTE=30;BYMONTH=1;FREQ=YEARLY;INTERVAL=2'

>>> r = vRecur(FREQ='yearly', INTERVAL=2)
>>> r['BYMONTH'] = 1
>>> r['BYDAY'] = 'su'
>>> r['BYHOUR'] = [8,9]
>>> r['BYMINUTE'] = 30
>>> r.ical()
'BYDAY=SU;BYMINUTE=30;BYMONTH=1;INTERVAL=2;FREQ=YEARLY;BYHOUR=8,9'

>>> r = vRecur(freq='DAILY', count=10)
>>> r['bysecond'] = [0, 15, 30, 45]
>>> r.ical()
'COUNT=10;FREQ=DAILY;BYSECOND=0,15,30,45'

>>> r = vRecur(freq='DAILY', until=datetime(2005,1,1,12,0,0))
>>> r.ical()
'FREQ=DAILY;UNTIL=20050101T120000'

How do we fare with regards to parsing?
>>> r = vRecur.from_ical('FREQ=DAILY;INTERVAL=2;COUNT=10')
>>> r
{'COUNT': [10], 'FREQ': ['DAILY'], 'INTERVAL': [2]}
>>> vRecur(r).ical()
'COUNT=10;FREQ=DAILY;INTERVAL=2'

>>> r = vRecur.from_ical('FREQ=YEARLY;INTERVAL=2;BYMONTH=1;BYDAY=-SU;BYHOUR=8,9;BYMINUTE=30')
>>> r
{'BYHOUR': [8, 9], 'BYDAY': ['-SU'], 'BYMINUTE': [30], 'BYMONTH': [1], 'FREQ': ['YEARLY'], 'INTERVAL': [2]}
>>> vRecur(r).ical()
'BYDAY=-SU;BYMINUTE=30;INTERVAL=2;BYMONTH=1;FREQ=YEARLY;BYHOUR=8,9'

Some examples from the spec

>>> r = vRecur.from_ical('FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1')
>>> vRecur(r).ical()
'BYSETPOS=-1;FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR'

>>> r = vRecur.from_ical('FREQ=YEARLY;INTERVAL=2;BYMONTH=1;BYDAY=SU;BYHOUR=8,9;BYMINUTE=30')
>>> vRecur(r).ical()
'BYDAY=SU;BYMINUTE=30;INTERVAL=2;BYMONTH=1;FREQ=YEARLY;BYHOUR=8,9'

and some errors
>>> r = vRecur.from_ical('BYDAY=12')
Traceback (most recent call last):
    ...
ValueError: Error in recurrence rule: BYDAY=12

Definition at line 821 of file prop.py.


Constructor & Destructor Documentation

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

Reimplemented from icalendar.caselessdict.CaselessDict.

Definition at line 902 of file prop.py.

00902 
00903     def __init__(self, *args, **kwargs):
00904         CaselessDict.__init__(self, *args, **kwargs)
00905         self.params = Parameters()


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:

Definition at line 935 of file prop.py.

00935 
00936     def __str__(self):
00937         return self.ical()
00938 
00939 

Here is the call 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))

Definition at line 923 of file prop.py.

00923 
00924     def from_ical(ical):
00925         "Parses the data format from ical text format"
00926         try:
00927             recur = vRecur()
00928             for pairs in ical.split(';'):
00929                 key, vals = pairs.split('=')
00930                 recur[key] = vRecur.parse_type(key, vals)
00931             return dict(recur)
00932         except:
            raise ValueError, 'Error in recurrence rule: %s' % ical

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:

Definition at line 906 of file prop.py.

00906 
00907     def ical(self):
00908         # SequenceTypes
00909         result = []
00910         for key, vals in self.items():
00911             typ = self.types[key]
00912             if not type(vals) in SequenceTypes:
00913                 vals = [vals]
00914             vals = ','.join([typ(val).ical() for val in vals])
00915             result.append('%s=%s' % (key, vals))
00916         return ';'.join(result)

Here is the call graph for this function:

Here is the caller graph for this function:

def icalendar.prop.vRecur.parse_type (   key,
  values 
)

Definition at line 917 of file prop.py.

00917 
00918     def parse_type(key, values):
00919         # integers
00920         parser = vRecur.types.get(key, vText)
        return [parser.from_ical(v) for v in values.split(',')]
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

Initial value:
["SECONDLY",  "MINUTELY", "HOURLY", "DAILY", "WEEKLY",
                   "MONTHLY", "YEARLY"]

Definition at line 883 of file prop.py.

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

Definition at line 933 of file prop.py.

Definition at line 904 of file prop.py.

tuple icalendar.prop.vRecur.parse_type = staticmethod(parse_type) [static]

Definition at line 921 of file prop.py.

Initial value:
CaselessDict({
        'COUNT':vInt,
        'INTERVAL':vInt,
        'BYSECOND':vInt,
        'BYMINUTE':vInt,
        'BYHOUR':vInt,
        'BYMONTHDAY':vInt,
        'BYYEARDAY':vInt,
        'BYMONTH':vInt,
        'UNTIL':vDDDTypes,
        'BYSETPOS':vInt,
        'WKST':vWeekday,
        'BYDAY':vWeekday,
        'FREQ':vFrequency
    })

Definition at line 886 of file prop.py.


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