class Dict(selector: Optional[Union[str, _Filter, Callable, Any]] = None, default: Any = NO_DEFAULT)[source]

Bases: Filter

Filter to find elements in a dictionary

  • selector – input selector to use on the object

  • default – default value is the element is not found, or if the type mismatch

>>> d = {'a': {'b': 'c', 'd': None}}
>>> Dict('a/b')(d)
>>> Dict('a')(d)
{'b': 'c', 'd': None}
>>> Dict('notfound')(d)
Traceback (most recent call last):
woob.browser.filters.base.ItemNotFound: Element ['notfound'] not found
>>> Dict('notfound', default=None)(d)

This method has to be overridden by children classes.

classmethod select(selector, item, obj=None, key=None)[source]