flexget.utils.serialization module#

class flexget.utils.serialization.DateSerializer[source]#

Bases: Serializer

classmethod deserialize(data, version)[source]#

Return an instance of the original class, recreated from the serialized form.

Parameters:
Return type:

date

classmethod serialize(value)[source]#

Return a plain python datatype which is json serializable.

Parameters:

value (date)

classmethod serializer_handles(value)[source]#

Return True if this serializer can handle value.

_abc_impl = <_abc._abc_data object>#
class flexget.utils.serialization.DateTimeSerializer[source]#

Bases: Serializer

classmethod deserialize(data, version)[source]#

Return an instance of the original class, recreated from the serialized form.

Parameters:
Return type:

datetime

classmethod serialize(value)[source]#

Return a plain python datatype which is json serializable.

Parameters:

value (datetime)

classmethod serializer_handles(value)[source]#

Return True if this serializer can handle value.

_abc_impl = <_abc._abc_data object>#
class flexget.utils.serialization.FGDumper(stream, default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None, sort_keys=True)[source]#

Bases: SafeDumper

yaml_representers = {<class 'NoneType'>: <function SafeRepresenter.represent_none>, <class 'bool'>: <function SafeRepresenter.represent_bool>, <class 'bytes'>: <function SafeRepresenter.represent_binary>, <class 'datetime.date'>: <function SafeRepresenter.represent_date>, <class 'datetime.datetime'>: <function SafeRepresenter.represent_datetime>, <class 'dict'>: <function _yaml_representer>, <class 'float'>: <function SafeRepresenter.represent_float>, <class 'int'>: <function SafeRepresenter.represent_int>, <class 'list'>: <function SafeRepresenter.represent_list>, <class 'set'>: <function SafeRepresenter.represent_set>, <class 'str'>: <function SafeRepresenter.represent_str>, <class 'tuple'>: <function SafeRepresenter.represent_list>, None: <function SafeRepresenter.represent_undefined>}#
class flexget.utils.serialization.FGLoader(stream)[source]#

Bases: SafeLoader

class flexget.utils.serialization.Serializer[source]#

Bases: ABC

Any data types that should be serializable should subclass this, and implement the serialize and deserialize methods.

This is important for data that is stored in Entry fields so that it can be stored to the database.

abstractmethod classmethod deserialize(data, version)[source]#

Return an instance of the original class, recreated from the serialized form.

Parameters:
Return type:

Any

abstractmethod classmethod serialize(value)[source]#

Return a plain python datatype which is json serializable.

Parameters:

value (Any)

Return type:

Any

classmethod serializer_handles(value)[source]#

Return True if this serializer can handle value.

Parameters:

value (Any)

Return type:

bool

classmethod serializer_name()[source]#

Return name of the serializer defaults to class name.

This can be overridden in subclass implementations if desired.

Return type:

str

classmethod serializer_version()[source]#

If the format of serialization changes, this number should be incremented.

The deserialize method of this class should continue to handle the old versions as well as the current version.

Return type:

int

_abc_impl = <_abc._abc_data object>#
class flexget.utils.serialization.SetSerializer[source]#

Bases: Serializer

classmethod deserialize(data, version)[source]#

Return an instance of the original class, recreated from the serialized form.

Parameters:
Return type:

set

classmethod serialize(value)[source]#

Return a plain python datatype which is json serializable.

Parameters:

value (set)

Return type:

list

classmethod serializer_handles(value)[source]#

Return True if this serializer can handle value.

_abc_impl = <_abc._abc_data object>#
class flexget.utils.serialization.TupleSerializer[source]#

Bases: Serializer

classmethod deserialize(data, version)[source]#

Return an instance of the original class, recreated from the serialized form.

Parameters:
Return type:

tuple

classmethod serialize(value)[source]#

Return a plain python datatype which is json serializable.

Parameters:

value (tuple)

Return type:

list

classmethod serializer_handles(value)[source]#

Return True if this serializer can handle value.

_abc_impl = <_abc._abc_data object>#
flexget.utils.serialization._deserializer_for(serializer_name)[source]#
Parameters:

serializer_name (str)

Return type:

type[Serializer]

flexget.utils.serialization._serializer_for(value)[source]#
Return type:

type[Serializer] | None

flexget.utils.serialization._yaml_constructor(loader, node)[source]#
flexget.utils.serialization._yaml_representer(dumper, data)[source]#
flexget.utils.serialization.deserialize(value)[source]#

Restore an object stored with this serialization system to its original format.

Parameters:

value (Any) – Serialized representation of the object.

Returns:

Deserialized object.

Return type:

Any

flexget.utils.serialization.dumps(value)[source]#

Dump an object to JSON text using the serialization system.

Parameters:

value (Any)

Return type:

str

flexget.utils.serialization.loads(value)[source]#

Restore an object from JSON text created by dumps.

Parameters:

value (str)

Return type:

Any

flexget.utils.serialization.serialize(value)[source]#

Convert an object to JSON serializable format.

Parameters:

value (Any) – Object to serialize.

Returns:

JSON serializable representation of this object.

Return type:

Any

flexget.utils.serialization.yaml_dump(data, *args, **kwargs)[source]#

Dump an object to YAML text using the serialization system.

flexget.utils.serialization.yaml_load(stream)[source]#

Restore an object from YAML text created by yaml_dump.