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.7.tar.gz
(196.3 kB
view hashes)
Built Distributions
bpmappers-0.7-py33-none-any.whl
(17.2 kB
view hashes)
bpmappers-0.7-py27-none-any.whl
(17.2 kB
view hashes)
bpmappers-0.7-py3.3.egg
(47.2 kB
view hashes)
bpmappers-0.7-py3.2.egg
(44.2 kB
view hashes)
bpmappers-0.7-py2.7.egg
(43.0 kB
view hashes)
bpmappers-0.7-py2.6.egg
(43.1 kB
view hashes)
bpmappers-0.7-py2.5.egg
(43.2 kB
view hashes)