Skip to main content

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


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 details)

Uploaded Source

Built Distribution

bpmappers-0.8.2-py2.py3-none-any.whl (11.1 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

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

File hashes

Hashes for bpmappers-0.8.2.tar.gz
Algorithm Hash digest
SHA256 e52f2f076c501026c39e9910104c0be554c0e1e1d443c539c4194559500a7dd9
MD5 c8435609df9a609ed3e64a8c51fe6cbe
BLAKE2b-256 71f0b029fdefb56e870e7fde6d6f5f4053dae6faaf4656a8645be49bf7adcb26

See more details on using hashes here.

File details

Details for the file bpmappers-0.8.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for bpmappers-0.8.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6327c7f6204e0c30a77639c34543d7e98a4b7a0ba007c2b9defea2ddde7b04cf
MD5 c0702d6165a36762bec41792ce0bb89a
BLAKE2b-256 b5297fc7e5aa4f4638a0c29115e3192717447f4f62add2887780bef8ffc53fc8

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