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
orpredicates
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