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.6.tar.gz
(187.5 kB
view hashes)
Built Distributions
bpmappers-0.6-py3.2.egg
(52.3 kB
view hashes)
bpmappers-0.6-py3.1.egg
(51.7 kB
view hashes)
bpmappers-0.6-py2.7.egg
(51.0 kB
view hashes)
bpmappers-0.6-py2.6.egg
(51.2 kB
view hashes)
bpmappers-0.6-py2.5.egg
(51.3 kB
view hashes)