lollipop
Data serialization and validation library
Features
flexible schema definition API with powerful type combinators
data validation
serialization/deserialization
in-place deserialization
Example
from lollipop.types import Object, String, Date
from lollipop.validators import Length
from collections import namedtuple
from datetime import date
Person = namedtuple('Person', ['name'])
Book = namedtuple('Book', ['title', 'publish_date', 'author'])
PersonType = Object({
'name': String(validate=Length(min=1)),
}, constructor=Person)
BookType = Object({
'title': String(),
'publish_date': Date(),
'author': PersonType,
}, constructor=Book)
harryPotter1 = Book(
title='Harry Potter and the Philosopher\'s Stone',
publish_date=date(1997, 6, 26),
author=Person(name='J. K. Rowling')
)
# Dumping
BookType.dump(harryPotter1)
# => {'title': 'Harry Potter and the Philosopher\'s Stone',
# 'publish_date': '1997-06-26',
# 'author': {'name': 'J. K. Rowling'}}
# Loading
BookType.load({'title': 'Harry Potter and the Philosopher\'s Stone',
'publish_date': '1997-06-26',
'author': {'name': 'J. K. Rowling'}})
# => Book(title='Harry Potter and the Philosopher\'s Stone',
# publish_date=date(1997, 06, 26),
# author=User(name='J. K. Rowling'))
# Partial inplace loading
BookType.load_into(harryPotter1, {'publish_date': '1997-06-27'})
# => Book(title='Harry Potter and the Philosopher\'s Stone',
# publish_date=date(1997, 06, 27),
# author=User(name='J. K. Rowling'))
# Loading list of objects
List(BookType).load([
{'title': 'Harry Potter and the Philosopher\'s Stone',
'publish_date': '1997-06-26',
'author': {'name': 'J. K. Rowling'}},
{'title': 'Harry Potter and the Chamber of Secrets',
'publish_date': '1998-07-02',
'author': {'name': 'J. K. Rowling'}},
])
# => [Book(...), Book(...)]
# Validation
BookType.validate({
'title': 'Harry Potter and the Philosopher\'s Stone',
'author': {'name': ''},
})
# => {'author': {'name': 'Length should be at least 1'},
# 'publish_date': 'Value is required'}
Installation
$ pip install lollipop
Documentation
Documentation is available at http://lollipop.readthedocs.io/ .
Requirements
Python >= 2.6 or <= 3.6
Project Links
Documentation: http://lollipop.readthedocs.io/
License
MIT licensed. See the bundled LICENSE file for more details.
Metadata
Release files for lollipop 1.1.8
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 |
|---|---|---|---|---|
| lollipop-1.1.8.tar.gz | 78.6 kB | Without provenance | Details for lollipop-1.1.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lollipop-1.1.8-py3-none-any.whl | Python 3 | none | any | Details for lollipop-1.1.8-py3-none-any.whl |
Total release size: 102.2 kB
Release files / lollipop-1.1.8.tar.gz
| Download URL | lollipop-1.1.8.tar.gz |
|---|---|
| Size | 78.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bf4897800ca6272377bff02d6cab6c50fcdda9763b38030851c34dc84a357f7b
|
|
BLAKE2b-256 checksum How to use checksums |
b4a20802ee33aed913fa0d1ef8a81615d28748a09c8878caa2d4c8f9fc58adad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Release files / lollipop-1.1.8-py3-none-any.whl
| Download URL | lollipop-1.1.8-py3-none-any.whl |
|---|---|
| Size | 23.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9801cb0fd45056112b99969b6866d777738c02dee6ad8ffc9e609bc6e768b303
|
|
BLAKE2b-256 checksum How to use checksums |
0549d58d63f9566de914853f67182ef836a0d03369a6fd07e343ec4c07330511
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Security for lollipop 1.1.8
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.