Skip to content

Module preconvert

A Library to enable preconversion of any Python type into one that is easily serializable

Sub-modules

Functions

converter
def (
    *kinds: Any,
    scope: str = 'base',
    store: Dict[str, Dict[str, Dict[str, Callable]]] = {'preconvert': {'base': OrderedDict([(typing.Collection, <class 'list'>), (<class 'generator'>, <class 'tuple'>), (typing.Mapping, <class 'dict'>), (<class 'decimal.Decimal'>, <class 'str'>), (<class 'uuid.UUID'>, <class 'str'>), (<class 'datetime.date'>, <function datetime_converter at 0x7f1a9a7211e0>), (<class 'datetime.datetime'>, <function datetime_converter at 0x7f1a9a7211e0>), (<class 'datetime.timedelta'>, <function time_delta_converter at 0x7f1a9a721268>), (<enum 'Enum'>, <function use_value_attribute at 0x7f1a9a7212f0>), (<class 'typing.NamedTuple'>, <function convert_namedtuple at 0x7f1a9b7ed2f0>), (<class 'bytes'>, <function byte_converter at 0x7f1a9a721488>), (<class 'numpy.ndarray'>, <function numpy_listable at 0x7f1a853f1b70>), (<class 'str'>, <function numpy_stringable at 0x7f1a83f640d0>), (<class 'numpy.str_'>, <function numpy_stringable at 0x7f1a83f640d0>), (<class 'numpy.bytes_'>, <function numpy_byte_decodeable at 0x7f1a83f09a60>), (<class 'numpy.bool_'>, <function numpy_boolable at 0x7f1a83f09ae8>), (<class 'numpy.integer'>, <function numpy_integerable at 0x7f1a83f09b70>), (<class 'float'>, <function numpy_floatable at 0x7f1a83f09bf8>), (<class 'numpy.floating'>, <function numpy_floatable at 0x7f1a83f09bf8>)])}},
    override: bool = False,
    package: Union[str, preconvert.register.AutoPackage] = <AutoPackage.FUNCTION_OR_PRECONVERT: 3>
) -> Callable

decorator that registers the wrapped function as a pre-converter for the provided types in the provided store data structure or a default global one.

Returns the decorated function unchanged.

default_serializer
def (
    item: Any,
    namespace: str = 'base',
    base_namespace: str = 'base',
    using: Union[Iterable[str], preconvert.output.convert.PreconversionSource] = <PreconversionSource.ALL_PACKAGES: 1>,
    store: Dict[str, Dict[str, Dict[Any, Callable]]] = {'preconvert': {'base': OrderedDict([(typing.Collection, <class 'list'>), (<class 'generator'>, <class 'tuple'>), (typing.Mapping, <class 'dict'>), (<class 'decimal.Decimal'>, <class 'str'>), (<class 'uuid.UUID'>, <class 'str'>), (<class 'datetime.date'>, <function datetime_converter at 0x7f1a9a7211e0>), (<class 'datetime.datetime'>, <function datetime_converter at 0x7f1a9a7211e0>), (<class 'datetime.timedelta'>, <function time_delta_converter at 0x7f1a9a721268>), (<enum 'Enum'>, <function use_value_attribute at 0x7f1a9a7212f0>), (<class 'typing.NamedTuple'>, <function convert_namedtuple at 0x7f1a9b7ed2f0>), (<class 'bytes'>, <function byte_converter at 0x7f1a9a721488>), (<class 'numpy.ndarray'>, <function numpy_listable at 0x7f1a853f1b70>), (<class 'str'>, <function numpy_stringable at 0x7f1a83f640d0>), (<class 'numpy.str_'>, <function numpy_stringable at 0x7f1a83f640d0>), (<class 'numpy.bytes_'>, <function numpy_byte_decodeable at 0x7f1a83f09a60>), (<class 'numpy.bool_'>, <function numpy_boolable at 0x7f1a83f09ae8>), (<class 'numpy.integer'>, <function numpy_integerable at 0x7f1a83f09b70>), (<class 'float'>, <function numpy_floatable at 0x7f1a83f09bf8>), (<class 'numpy.floating'>, <function numpy_floatable at 0x7f1a83f09bf8>)])}}
)