3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-26 04:32:51 +01:00

structures: support a 'data' keyword argument in (IRC)CaseInsensitiveDict

This commit is contained in:
James Lu 2017-08-25 02:07:54 -07:00
parent a02fa45d96
commit f34198647e

View File

@ -30,7 +30,11 @@ class CaseInsensitiveDict(collections.abc.MutableMapping):
""" """
A dictionary storing items case insensitively. A dictionary storing items case insensitively.
""" """
def __init__(self): def __init__(self, *, data=None):
if data is not None:
assert isinstance(data, dict)
self._data = data
else:
self._data = {} self._data = {}
def _keymangle(self, key): def _keymangle(self, key):
@ -67,8 +71,8 @@ class IRCCaseInsensitiveDict(CaseInsensitiveDict):
""" """
A dictionary storing channels case insensitively. Channel objects are initialized on access. A dictionary storing channels case insensitively. Channel objects are initialized on access.
""" """
def __init__(self, irc): def __init__(self, irc, *, data=None):
super().__init__() super().__init__(data=data)
self._irc = irc self._irc = irc
def _keymangle(self, key): def _keymangle(self, key):