Simple and beautiful library for data formatting/convert/serialize
pip install reformer
Why
There are many great python libraries for validation, serialization and data formatting search as marshmallow, DRF etc. Usually they base on data validation.
Otherwise reformer design only for data formatting, and in a schema you need to define type of transformation and data source.
How to use
To define schema you need to create Reformer base class:
from reformer import Reformer, Field, MapField, MethodField
class Schema(Reformer):
_fields_ = ('name', 'surname')
fullname = Field('name').replace('_', '-') + ' ' + Field('surname')
admin = Field('username').at(['admin', 'root'])
welcome = MapField('username', {
'admin': 'Hi bro',
'root': 'God?'
})
posts_titles = Field('posts').iter(['title'])
status = ('http://api.com/get_user_status/' + Field('id', to=str)).handle(requests.get)
target = {
'id': 353,
'name': 'John',
'surname': 'Black',
'username': 'admin',
'posts': [
{'title': 'New', 'id': 10},
{'title': 'My first post', 'id': 11},
]
}
print(Schema.transform(target))
# OrderedDict([
# ('name', 'John'),
# ('surname', 'Black'),
# ('fullname', 'John Black'),
# ('admin', True),
# ('welcome', 'Hi bro'),
# ('posts_titles', ['New', 'My first post']),
# ('status', 'INIT'),
# ])
FUTURE
errors
Metadata
Release files for reformer 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| reformer-0.1.3.tar.gz | 4.4 kB | Without provenance | Details for reformer-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| reformer-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for reformer-0.1.3-py3-none-any.whl |
Total release size: 10.5 kB
Release files / reformer-0.1.3.tar.gz
| Download URL | reformer-0.1.3.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c844e31355ca005fd945f8e3d69896a1ce8690e9b0b26c554156cf2e2bab801a
|
|
BLAKE2b-256 checksum How to use checksums |
747610d1e95186ffc6a77db09ceba0f237623f3aad6452a7058d224de47cb016
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.11.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.5.2
|
Release files / reformer-0.1.3-py3-none-any.whl
| Download URL | reformer-0.1.3-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9c2e21768c30d4f9f20b1ddb6242803cd3557c5122847714bfdfad3642afea6c
|
|
BLAKE2b-256 checksum How to use checksums |
0fa551e22a24f48550c1b977cbc755261094dc42c090f294d023d5542feed83c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.11.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.5.2
|
Security for reformer 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.