django_unicorn.call_method_parser
#
Module Contents#
- exception django_unicorn.call_method_parser.InvalidKwargError#
Bases:
Exception
Common base class for all non-exit exceptions.
- django_unicorn.call_method_parser.eval_value(value)#
Uses ast.literal_eval to parse strings into an appropriate Python primitive.
Also returns an appropriate object for strings that look like they represent datetime, date, time, duration, or UUID.
- django_unicorn.call_method_parser.parse_kwarg(kwarg: str, *, raise_if_unparseable=False) Dict[str, Any] #
Parses a potential kwarg as a string into a dictionary.
Example
parse_kwarg(βtest=β1ββ) == {βtestβ: β1β}
- Parameters:
kwarg β Potential kwarg as a string. e.g. βtest=β1ββ.
raise_if_unparseable β Raise an error if the kwarg cannot be parsed. Defaults to False.
- Returns:
Dictionary of key-value pairs.
- django_unicorn.call_method_parser.parse_call_method_name(call_method_name: str) Tuple[str, Tuple[Any], Mapping[str, Any]] #
Parses the method name from the request payload into a set of parameters to pass to a method.
- Parameters:
call_method_name (param) β String representation of a method name with parameters, e.g. βset_name(βBobβ)β
- Returns:
Tuple of method_name, a list of arguments and a dict of keyword arguments