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 :
- Divide into sub-problems - iter_input()
- Solve sub-problems - iter_output()
- 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 :
- setting key_to_cast
- setting value_cast
- 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.