colour.utilities.LazyCaseInsensitiveMapping

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

Bases: colour.utilities.data_structures.CaseInsensitiveMapping

Implements a lazy case-insensitive mutable mapping / dict object by inheriting from colour.utilities.CaseInsensitiveMapping class.

Allows lazy 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. The lazy retrieval is performed as follows: If the value is a callable, then it is evaluated and its return value is stored in place of the current value.

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.

Methods

Warning

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

Examples

>>> def callable_a():
...     print(2)
...     return 2
>>> methods = LazyCaseInsensitiveMapping(
...     {'McCamy': 1, 'Hernandez': callable_a})
>>> methods['mccamy']
1
>>> methods['hernandez']
2
2
__getitem__(item)[source]

Returns the value of given item.

The item value is retrieved using its lower name in the mapping. If the value is a callable, then it is evaluated and its return value is stored in place of the current value.

Parameters

item (unicode) – Item name.

Returns

Item value.

Return type

object