3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +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,8 +30,12 @@ class CaseInsensitiveDict(collections.abc.MutableMapping):
"""
A dictionary storing items case insensitively.
"""
def __init__(self):
self._data = {}
def __init__(self, *, data=None):
if data is not None:
assert isinstance(data, dict)
self._data = data
else:
self._data = {}
def _keymangle(self, key):
"""Converts the given key to lowercase."""
@ -67,8 +71,8 @@ class IRCCaseInsensitiveDict(CaseInsensitiveDict):
"""
A dictionary storing channels case insensitively. Channel objects are initialized on access.
"""
def __init__(self, irc):
super().__init__()
def __init__(self, irc, *, data=None):
super().__init__(data=data)
self._irc = irc
def _keymangle(self, key):