Package SPARQLWrapper :: Module KeyCaseInsensitiveDict
[hide private]
[frames] | no frames]

Source Code for Module SPARQLWrapper.KeyCaseInsensitiveDict

 1  # -*- coding: utf-8 -*- 
 2   
 3  """ 
 4  A simple implementation of a key case-insensitive dictionary. 
 5   
 6  @authors: U{Ivan Herman<http://www.ivan-herman.net>}, U{Sergio Fernández<http://www.wikier.org>}, U{Carlos Tejo Alonso<http://www.dayures.net>} 
 7  @organization: U{World Wide Web Consortium<http://www.w3.org>} and U{Foundation CTIC<http://www.fundacionctic.org/>}. 
 8  @license: U{W3C® SOFTWARE NOTICE AND LICENSE<href="http://www.w3.org/Consortium/Legal/copyright-software">} 
 9  """ 
10   
11 -class KeyCaseInsensitiveDict(dict):
12 """ 13 A simple implementation of a key case-insensitive dictionary 14 """ 15
16 - def __init__(self, d={}):
17 for k, v in d.items(): 18 self[k] = v
19
20 - def __setitem__(self, key, value):
21 if (hasattr(key, "lower")): 22 key = key.lower() 23 dict.__setitem__(self, key, value)
24
25 - def __getitem__(self, key):
26 if (hasattr(key, "lower")): 27 key = key.lower() 28 return dict.__getitem__(self, key)
29
30 - def __delitem__(self, key):
31 if hasattr(key, "lower"): 32 key = key.lower() 33 dict.__delitem__(self, key)
34