3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 12:12:53 +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. A dictionary storing items case insensitively.
""" """
def __init__(self): def __init__(self, *, data=None):
self._data = {} if data is not None:
assert isinstance(data, dict)
self._data = data
else:
self._data = {}
def _keymangle(self, key): def _keymangle(self, key):
"""Converts the given key to lowercase.""" """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. 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):