Allow None in IrcDict and InsensitivePreservingDicts.

This commit is contained in:
Jeremy Fincher 2004-10-01 21:25:01 +00:00
parent 133f6a8aff
commit 26771923f6
2 changed files with 10 additions and 2 deletions

View File

@ -493,7 +493,10 @@ class IrcString(str):
class IrcDict(utils.InsensitivePreservingDict):
"""Subclass of dict to make key comparison IRC-case insensitive."""
key = staticmethod(toLower)
def key(self, s):
if s is not None:
s = toLower(s)
return s
class IrcSet(utils.NormalizingSet):

View File

@ -641,7 +641,12 @@ def isIPV6(s):
return False
class InsensitivePreservingDict(UserDict.DictMixin, object):
key = staticmethod(str.lower)
def key(self, s):
"""Override this if you wish."""
if s is not None:
s = s.lower()
return s
def __init__(self, dict=None, key=None):
if key is not None:
self.key = key