A mapping tool from model to dictionary.
Project description
A mapping tool from model to dictionary.
>>> from bpmappers import Mapper, RawField >>> class SpamMapper(Mapper): ... spam = RawField('foo') ... egg = RawField('bar') ... >>> >>> SpamMapper(dict(foo=123, bar='abc')).as_dict() {'egg': 'abc', 'spam': 123} >>> >>> class FooModel(object): ... def __init__(self, foo, bar): ... self.foo = foo ... self.bar = bar ... >>> SpamMapper(FooModel(foo=123, bar='abc')).as_dict() {'egg': 'abc', 'spam': 123} >>> >>> class HogeMapper(Mapper): ... hoge = RawField('hoge.piyo.fuga') ... >>> HogeMapper({'hoge': {'piyo': {'fuga': 123}}}).as_dict() {'hoge': 123}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bpmappers-0.8.2.tar.gz
(36.4 kB
view hashes)
Built Distribution
Close
Hashes for bpmappers-0.8.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6327c7f6204e0c30a77639c34543d7e98a4b7a0ba007c2b9defea2ddde7b04cf |
|
MD5 | c0702d6165a36762bec41792ce0bb89a |
|
BLAKE2b-256 | b5297fc7e5aa4f4638a0c29115e3192717447f4f62add2887780bef8ffc53fc8 |