Simplified deserialization using dataclasses
Project description
pavlova is a library that assists in mapping an unknown input into a dataclass.
from datetime import datetime
from dataclasses import dataclass
from pavlova import Pavlova
@dataclass
class Input:
id: int
name: str
date: datetime
Pavlova().from_mapping({
'id': 10,
'name': 100
'date': '2018-08-10',
}, Input)
# Input(id=10, name='100', date=datetime.datetime(2018, 8, 10, 0, 0))
Pavlova was born out of frustration with the lack of typing support for existing deserialization libraries. With the introduction of dataclasses in Python 3.7, they seemed like the perfect use for defining a deserialization schema.
Supported functionality
Parsing of booleans, datetimes, floats, ints, strings, decimals, dictionaries, enums, lists are currently supported.
There are more parsers to come, however to implement your own custom parser, simply implement PavlovaParser in pavlova.parsers, and register it with the Pavlova object with the register_parser method.
Installation
pip install pavlova
Requirements
Pavlova is only supported on Python 3.6 and higher. With Python 3.6, it will install the dataclasses <https://github.com/ericvsmith/dataclasses> module. With Python 3.7 and higher, it will use the built-in dataclasses module.
License
GNU LGPLv3. Please see LICENSE and COPYING.LESSER.
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
Built Distribution
File details
Details for the file pavlova-0.1.1.dev2.tar.gz
.
File metadata
- Download URL: pavlova-0.1.1.dev2.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5298f58b067ac23207e15fb01dc377b3effd33030971ef420ac237fa94c028f |
|
MD5 | c59dbccd95aca679c433aa7bf000aaca |
|
BLAKE2b-256 | 5f15ed9bbdcb43f49d98e3316c881730e332d68b65b15dc05546fd803f857c9d |
File details
Details for the file pavlova-0.1.1.dev2-py3-none-any.whl
.
File metadata
- Download URL: pavlova-0.1.1.dev2-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b87ef5654a650a0755c1ae5199cbf53a7b9c54f972a97ca19a20742ee19f4897 |
|
MD5 | 062bbff8b7c1bdee7d53b7ef1ded6f25 |
|
BLAKE2b-256 | e62f2cce75dde650bdd1fde5cc18374a2aaceab3b4469dc38b40f70524a3e32b |