Skip to main content

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


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.tar.gz (7.9 kB view details)

Uploaded Source

File details

Details for the file bpmappers-0.5.tar.gz.

File metadata

  • Download URL: bpmappers-0.5.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for bpmappers-0.5.tar.gz
Algorithm Hash digest
SHA256 ed17e1c63fd7a7bed4b3c4cd3e71b02ab9251a12cfd488c9a583c89c359f1c5c
MD5 890919c5d264a41d2ae2b49a9ec79107
BLAKE2b-256 97939c6dc70728beee4a9670fe872877ec4a5a5067b63cdb5564d38934d9ee36

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page