any2any 0.1 documentation

any2any.daccasts

«  any2any.utils   ::   Contents

any2any.daccasts

DivideAndConquerCast

class any2any.daccasts.DivideAndConquerCast(**settings)

Abstract base cast for metamorphosing from and to any complex object or container.

In order to achieve casting, this class implements a “divide and conquer” strategy :

  1. Divide into sub-problems - iter_input()
  2. Solve sub-problems - iter_output()
  3. Combine solutions - build_output()
Members:
Member-order:bysource

Mixins for DivideAndConquerCast

class any2any.daccasts.CastItems

Mixin for DivideAndConquerCast. Implements DivideAndConquerCast.iter_output().

Available settings :

key_to_cast

dict. {<key>: <cast>}. Maps a key with the cast to use.

value_cast

Cast. The cast to use on all values.

key_cast

Cast. The cast to use on all keys.

Members :

iter_output(items_iter)

Casts each item. The cast is looked-up for in the following order :

  1. setting key_to_cast
  2. setting value_cast
  3. finally, using any2any.base.Cast.cast_for()
strip_item(key, value)

Override for use. If True is returned, the item <key>, <value> will be stripped from the output.

class any2any.daccasts.FromIterable

Mixin for DivideAndConquerCast. Implements DivideAndConquerCast.iter_input().

Note that FromIterable is more clever when from_ is a subclass of WrappedContainer.

class any2any.daccasts.ToIterable

Mixin for DivideAndConquerCast. Implements DivideAndConquerCast.build_output().

Note that ToIterable is more clever when to is a subclass of WrappedContainer.

class any2any.daccasts.FromMapping

Mixin for DivideAndConquerCast. Implements DivideAndConquerCast.iter_input().

Note that FromMapping is more clever when from_ is a subclass of WrappedContainer.

class any2any.daccasts.ToMapping

Mixin for DivideAndConquerCast. Implements DivideAndConquerCast.build_output().

Note that ToMapping is more clever when to is a subclass of WrappedContainer.

class any2any.daccasts.FromObject

Mixin for DivideAndConquerCast. Implements DivideAndConquerCast.iter_input().

Note that FromObject is more clever when from_ is a subclass of WrappedObject.

class any2any.daccasts.ToObject

Mixin for DivideAndConquerCast. Implements DivideAndConquerCast.build_output().

Note that ToObject is more clever when to is a subclass of WrappedObject.

Wraps

class any2any.daccasts.WrappedContainer

Bases: any2any.utils.WrappedObject

A subclass of utils.WrappedObject providing informations on a container type.

value_type = NotImplemented

type. The type of value contained.

«  any2any.utils   ::   Contents