Back to index

plone3  3.1.7
Public Member Functions
icalendar.caselessdict.CaselessDict Class Reference
Inheritance diagram for icalendar.caselessdict.CaselessDict:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
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__

Detailed Description

A dictionary that isn't case sensitive, and only use string as keys.

>>> ncd = CaselessDict(key1='val1', key2='val2')
>>> ncd
CaselessDict({'KEY2': 'val2', 'KEY1': 'val1'})
>>> ncd['key1']
'val1'
>>> ncd['KEY1']
'val1'
>>> ncd['KEY3'] = 'val3'
>>> ncd['key3']
'val3'
>>> ncd.setdefault('key3', 'FOUND')
'val3'
>>> ncd.setdefault('key4', 'NOT FOUND')
'NOT FOUND'
>>> ncd['key4']
'NOT FOUND'
>>> ncd.get('key1')
'val1'
>>> ncd.get('key3', 'NOT FOUND')
'val3'
>>> ncd.get('key4', 'NOT FOUND')
'NOT FOUND'
>>> 'key4' in ncd
True
>>> del ncd['key4']
>>> ncd.has_key('key4')
False
>>> ncd.update({'key5':'val5', 'KEY6':'val6', 'KEY5':'val7'})
>>> ncd['key6']
'val6'
>>> keys = ncd.keys()
>>> keys.sort()
>>> keys
['KEY1', 'KEY2', 'KEY3', 'KEY5', 'KEY6']

Definition at line 3 of file caselessdict.py.


Constructor & Destructor Documentation

def icalendar.caselessdict.CaselessDict.__init__ (   self,
  args,
  kwargs 
)

Reimplemented in icalendar.prop.TypesFactory, icalendar.prop.vRecur, icalendar.cal.Component, and icalendar.cal.ComponentFactory.

Definition at line 43 of file caselessdict.py.

00043 
00044     def __init__(self, *args, **kwargs):
00045         "Set keys to upper for initial dict"
00046         dict.__init__(self, *args, **kwargs)
00047         for k,v in self.items():
00048             k_upper = k.upper()
00049             if k != k_upper:
00050                 dict.__delitem__(self, k)
00051                 self[k_upper] = v

Here is the call graph for this function:


Member Function Documentation

Definition at line 61 of file caselessdict.py.

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

Definition at line 58 of file caselessdict.py.

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

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 
)

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 89 of file caselessdict.py.

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

Here is the caller graph for this function:

Definition at line 86 of file caselessdict.py.

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

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

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:

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.caselessdict.CaselessDict.pop (   self,
  key,
  default = None 
)

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:

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 
)

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 
)
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:


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