Jason R. Coombs avatar Jason R. Coombs committed ba86ff1

Implemented case-insensitive lookup on FoldedCaseKeyedDict

Comments (0)

Files changed (1)

jaraco/util/dictlib.py

 	>>> d = FoldedCaseKeyedDict({'heLlo': 'world'})
 	>>> d['hello']
 	u'world'
+	>>> d['Hello']
+	u'world'
 	>>> d
 	{u'heLlo': u'world'}
 	>>> d = FoldedCaseKeyedDict({'heLlo': 'world', 'Hello': 'world'})
 	>>> d
 	{u'heLlo': u'world'}
 	"""
-	def __setitem__(self, key, val):
-		if isinstance(key, basestring):
-			key = jaraco.util.string.FoldedCase(key)
-		dict.__setitem__(self, key, val)
-
 	def __init__(self, *args, **kargs):
 		super(FoldedCaseKeyedDict, self).__init__()
 		# build a dictionary using the default constructs
 		for item in d.items():
 			self.__setitem__(*item)
 
+	def __setitem__(self, key, val):
+		if isinstance(key, basestring):
+			key = jaraco.util.string.FoldedCase(key)
+		super(FoldedCaseKeyedDict, self).__setitem__(key, val)
+
+	def __getitem__(self, key):
+		if isinstance(key, basestring):
+			key = jaraco.util.string.FoldedCase(key)
+		return super(FoldedCaseKeyedDict, self).__getitem__(key)
+
 	def __contains__(self, key):
 		if isinstance(key, basestring):
 			key = jaraco.util.string.FoldedCase(key)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.