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
mapping (collections.abc.Mapping) – Mapping to filter.
names (str | collections.abc.Sequence[str]) – Name for given mapping elements or a list of names.
- Returns
Filtered mapping elements.
- Return type
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...>}