colour.utilities.filter_mapping#

colour.utilities.filter_mapping(mapping: collections.abc.Mapping, names: str | collections.abc.Sequence[str]) dict[source]#

Filter given mapping with given names.

Parameters
Returns

Filtered mapping elements.

Return type

dict

Notes

  • If the mapping passed is a colour.utilities.CanonicalMapping class instance, then the lower, slugified and canonical keys are also used for matching.

  • To honour the filterers ordering, the return value is a dict class instance.

Examples

>>> class Element:
...     pass
...
>>> mapping = {
...     "Element A": Element(),
...     "Element B": Element(),
...     "Element C": Element(),
...     "Not Element C": Element(),
... }
>>> filter_mapping(mapping, "Element A")  
{'Element A': <colour.utilities.common.Element object at 0x...>}