parselglossy.views module

Tools to extract views of dictionaries.

parselglossy.views.view_by(what: str, d: Dict[str, Any], *, predicate: Callable[[Any, str], bool] = <function <lambda>>, missing: Optional[Type[Exception]] = None, transformer: Callable[Any, 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_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