parselglossy.views module#

Tools to extract views of dictionaries.

parselglossy.views.view_by(what: str, d: ~typing.Dict[str, ~typing.Any], *, predicate: ~typing.Callable[[~typing.Any, str], bool] = <function <lambda>>, missing: ~typing.Optional[~typing.Type[Exception]] = None, transformer: ~typing.Callable[[~typing.Any], ~typing.Any] = <function <lambda>>) Dict[str, Any][source]#

Recursive decimation of a template into an input.

Parameters
  • what (str) – What view to extract from the dictionary. Any of type, default, docstring or predicates is allowed.

  • d (JSONDict) –

  • predicate (Callable) – A predicate accepting two arguments.

  • missing (Optional[Exception]) –

  • transformer (Callable) –

Returns

outgoing – A dictionary with the desired view.

Return type

JSONDict

:raises exc:ValueError if what is not among the allowed views.:

parselglossy.views.view_by_default(d: Dict[str, Any]) Dict[str, Any][source]#

Partial application of view_by() for defaults.

Parameters

d (JSONDict) –

Returns

outgoing – A dictionary with a view by defaults.

Return type

JSONDict

parselglossy.views.view_by_default_keywords(keywords: List[Dict[str, Any]]) Dict[str, Any][source]#

View by defaults only for lists of keywords.

Parameters

keywords (List[JSONDict]) –

Returns

outgoing – A dictionary with a view by defaults for the keywords.

Return type

JSONDict

parselglossy.views.view_by_docstring(d: Dict[str, Any]) Dict[str, Any][source]#

Partial application of view_by() for docstrings.

Parameters

d (JSONDict) –

Returns

outgoing – A dictionary with a view by docstrings.

Return type

JSONDict

parselglossy.views.view_by_predicates(d: Dict[str, Any]) Dict[str, Any][source]#

Partial application of view_by() for predicates.

Parameters

d (JSONDict) –

Returns

outgoing – A dictionary with a view by predicates.

Return type

JSONDict

parselglossy.views.view_by_type(d: Dict[str, Any]) Dict[str, Any][source]#

Partial application of view_by() for types.

Parameters

d (JSONDict) –

Returns

outgoing – A dictionary with a view by types.

Return type

JSONDict