Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
lollipop
.. image:: https://img.shields.io/pypi/l/lollipop.svg :target: https://github.com/maximkulkin/lollipop/blob/master/LICENSE :alt: License: MIT
.. image:: https://img.shields.io/travis/maximkulkin/lollipop.svg :target: https://travis-ci.org/maximkulkin/lollipop :alt: Build Status
.. image:: https://readthedocs.org/projects/lollipop/badge/?version=latest :target: http://lollipop.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status
.. image:: https://img.shields.io/pypi/v/lollipop.svg :target: https://pypi.python.org/pypi/lollipop :alt: PyPI
Data serialization and validation library
.. code-block:: python
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'}
::
$ pip install lollipop
Documentation is available at http://lollipop.readthedocs.io/ .
MIT licensed. See the bundled LICENSE <https://github.com/maximkulkin/lollipop/blob/master/LICENSE>
_ file for more details.
FAQs
Data serialization and validation library
We found that lollipop demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.