colour.utilities.CaseInsensitiveMapping

class colour.utilities.CaseInsensitiveMapping(data=None, **kwargs)[source]

Implements a case-insensitive mutable mapping / dict object.

Allows values retrieving from keys while ignoring the key case. The keys are expected to be unicode or string-like objects supporting the str.lower() method.

Parameters:data (dict) – dict of data to store into the mapping at initialisation.
Other Parameters:
 **kwargs (dict, optional) – Key / Value pairs to store into the mapping at initialisation.
__setitem__()[source]
__getitem__()[source]
__delitem__()[source]
__contains__()[source]
__iter__()[source]
__len__()[source]
__eq__()[source]
__ne__()[source]
__repr__()
copy()[source]
lower_items()[source]

Warning

The keys are expected to be unicode or string-like objects.

References

Examples

>>> methods = CaseInsensitiveMapping({'McCamy': 1, 'Hernandez': 2})
>>> methods['mccamy']
1
__init__(data=None, **kwargs)[source]

Methods

__init__([data])
clear(() -> None.  Remove all items from D.)
copy() Returns a copy of the mapping.
get((k[,d]) -> D[k] if k in D, …)
items(() -> list of D’s (key, value) pairs, …)
iteritems(() -> an iterator over the (key, …)
iterkeys(() -> an iterator over the keys of D)
itervalues(…)
keys(() -> list of D’s keys)
lower_items() Iterates over the lower items names.
pop((k[,d]) -> v, …) If key is not found, d is returned if given, otherwise KeyError is raised.
popitem(() -> (k, v), …) as a 2-tuple; but raise KeyError if D is empty.
setdefault((k[,d]) -> D.get(k,d), …)
update(([E, …) If E present and has a .keys() method, does: for k in E: D[k] = E[k]
values(() -> list of D’s values)