django_unicorn.utils#

Module Contents#

django_unicorn.utils.function_signature_cache#
django_unicorn.utils.generate_checksum(data: Union[bytes, str, Dict]) str#

Generates a checksum for the passed-in data.

Parameters:

data – The raw input to generate the checksum against.

Returns:

The generated checksum.

django_unicorn.utils.dicts_equal(dictionary_one: Dict, dictionary_two: Dict) bool#

Return True if all keys and values are the same between two dictionaries.

django_unicorn.utils.get_method_arguments(func) List[str]#

Gets the arguments for a method.

Returns:

A list of strings, one for each argument.

django_unicorn.utils.sanitize_html(html: str) django.utils.safestring.SafeText#

Escape all the HTML/XML special characters with their unicode escapes, so value is safe to be output in JSON.

This is the same internals as django.utils.html.json_script except it takes a string instead of an object to avoid calling DjangoJSONEncoder.

django_unicorn.utils.is_non_string_sequence(obj)#

Checks whether the object is a sequence (i.e. list, tuple, set), but _not_ str or bytes type. Helpful when you expect to loop over obj, but explicitly don’t want to allow str.

django_unicorn.utils.is_int(s: str) bool#

Checks whether a string is actually an integer.