bpmappers 0.5
Model to dictionary mapping for Python
Latest Version: 0.5.1
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}
| File | Type | Py Version | Uploaded on | Size | # downloads |
|---|---|---|---|---|---|
| bpmappers-0.5.tar.gz (md5) | Source | 2011-10-01 | 7KB | 347 | |
- Author: K.K. BeProud
- Home Page: http://tokibito.bitbucket.org/bpmappers/
- Categories
- Package Index Owner: tokibito
- DOAP record: bpmappers-0.5.xml
