colour.utilities.CaseInsensitiveMapping¶
- class colour.utilities.CaseInsensitiveMapping(data=None, **kwargs)[source]¶
Bases:
collections.abc.MutableMapping
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
Attributes
Methods
Warning
The keys are expected to be unicode or string-like objects.
References
[]
Examples
>>> methods = CaseInsensitiveMapping({'McCamy': 1, 'Hernandez': 2}) >>> methods['mccamy'] 1
- __setitem__(item, value)[source]¶
Sets given item with given value.
The item is stored as lower in the mapping while the original name and its value are stored together as the value in a tuple:
{“item.lower()”: (“item”, value)}
- __getitem__(item)[source]¶
Returns the value of given item.
The item value is retrieved using its lower name in the mapping.
- Parameters
item (unicode) – Item name.
- Returns
Item value.
- Return type
- __delitem__(item)[source]¶
Deletes the item with given name.
The item is deleted from the mapping using its lower name.
- Parameters
item (unicode) – Item name.
- __contains__(item)[source]¶
Returns if the mapping contains given item.
- Parameters
item (unicode) – Item name.
- Returns
Is item in mapping.
- Return type
- __iter__()[source]¶
Iterates over the items names in the mapping.
The item names returned are the original input ones.
- Returns
Item names.
- Return type
generator
- __eq__(item)[source]¶
Returns the equality with given object.
- Parameters
item – Object item.
- Returns
Equality.
- Return type
- __ne__(item)[source]¶
Returns the inequality with given object.
- Parameters
item – Object item.
- Returns
Inequality.
- Return type
- __repr__()¶
Returns an ellipsis string representation of the case-insensitive mutable mapping for documentation purposes.
- Returns
Ellipsis string representation.
- Return type
unicode
- copy()[source]¶
Returns a copy of the mapping.
- Returns
Mapping copy.
- Return type
Notes
The
colour.utilities.CaseInsensitiveMapping
class copy returned is a simple copy not a deepcopy.
- lower_items()[source]¶
Iterates over the lower items names.
- Returns
Lower item names.
- Return type
generator
- __hash__ = None¶
- __weakref__¶
list of weak references to the object (if defined)