futurefinity.utils – FutureFinity Utilities

futurefinity.utils contains a series of utilities for common use.

exception futurefinity.utils.FutureFinityError[source]

Basic FutureFinity Error Class.

All Errors from FutureFinity are based on this class.

class futurefinity.utils.MagicDict(*args, **kwargs)[source]

An implementation of one-to-many mapping.

add(name: typing.Any, value: typing.Any)[source]

Add a value to the MagicDict.

get_first(name: typing.Any, default: typing.Any=None)[source]

Get the first value with the name.

get_list(name: typing.Any, default: typing.Any=None)[source]

Return all values with the name in a list.

class futurefinity.utils.TolerantMagicDict(*args, **kwargs)[source]

An implementation of case-insensitive one-to-many mapping.

Everything is the same as MagicDict, but Keys must be str and are case-insensitive.

This doesn’t mean that the normal MagicDict is mean.

futurefinity.utils.ensure_bytes(var: typing.Any) → bytes[source]

Try to convert passed variable to a bytes object.

futurefinity.utils.ensure_str(var: typing.Any) → str[source]

Try to convert passed variable to a str object.

futurefinity.utils.format_timestamp(ts: typing.Union=None) → str[source]

Make a HTTP Protocol timestamp.