Model to dictionary mapping for Python
Project description
Model to dictionary mapping for Python.
>>> 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.5.1.tar.gz
(170.5 kB
view details)
File details
Details for the file bpmappers-0.5.1.tar.gz
.
File metadata
- Download URL: bpmappers-0.5.1.tar.gz
- Upload date:
- Size: 170.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13a76aab234826a0006addcc5ed982d06cedf8bab9687317d8a5dcb7ff611cff |
|
MD5 | d0c92fca6c7b4fa4decad854d8536832 |
|
BLAKE2b-256 | 0150d6c6bba862c500389f4bb80758c6fc037fdfe97e1ffdc0773842a33726ef |