lollipop


Namelollipop JSON
Version 1.1.8 PyPI version JSON
download
home_pagehttps://github.com/maximkulkin/lollipop
SummaryData serialization and validation library
upload_time2023-07-06 02:38:46
maintainer
docs_urlNone
authorMaxim Kulkin
requires_python
licenseMIT
keywords serialization rest json api marshal marshalling deserialization validation schema marshmallow
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            ********
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

Features
========
* flexible schema definition API with powerful type combinators
* data validation
* serialization/deserialization
* in-place deserialization

Example
=======
.. 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'}


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/
- PyPI: https://pypi.python.org/pypi/lollipop
- Issues: https://github.com/maximkulkin/lollipop/issues


License
=======

MIT licensed. See the bundled `LICENSE <https://github.com/maximkulkin/lollipop/blob/master/LICENSE>`_ file for more details.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/maximkulkin/lollipop",
    "name": "lollipop",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "serialization,rest,json,api,marshal,marshalling,deserialization,validation,schema,marshmallow",
    "author": "Maxim Kulkin",
    "author_email": "maxim.kulkin@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b4/a2/0802ee33aed913fa0d1ef8a81615d28748a09c8878caa2d4c8f9fc58adad/lollipop-1.1.8.tar.gz",
    "platform": null,
    "description": "********\nlollipop\n********\n\n.. image:: https://img.shields.io/pypi/l/lollipop.svg\n    :target: https://github.com/maximkulkin/lollipop/blob/master/LICENSE\n    :alt: License: MIT\n\n.. image:: https://img.shields.io/travis/maximkulkin/lollipop.svg\n    :target: https://travis-ci.org/maximkulkin/lollipop\n    :alt: Build Status\n\n.. image:: https://readthedocs.org/projects/lollipop/badge/?version=latest\n    :target: http://lollipop.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation Status\n\n.. image:: https://img.shields.io/pypi/v/lollipop.svg\n    :target: https://pypi.python.org/pypi/lollipop\n    :alt: PyPI\n\nData serialization and validation library\n\nFeatures\n========\n* flexible schema definition API with powerful type combinators\n* data validation\n* serialization/deserialization\n* in-place deserialization\n\nExample\n=======\n.. code-block:: python\n\n    from lollipop.types import Object, String, Date\n    from lollipop.validators import Length\n    from collections import namedtuple\n    from datetime import date\n\n    Person = namedtuple('Person', ['name'])\n    Book = namedtuple('Book', ['title', 'publish_date', 'author'])\n\n    PersonType = Object({\n        'name': String(validate=Length(min=1)),\n    }, constructor=Person)\n\n    BookType = Object({\n        'title': String(),\n        'publish_date': Date(),\n        'author': PersonType,\n    }, constructor=Book)\n\n    harryPotter1 = Book(\n        title='Harry Potter and the Philosopher\\'s Stone',\n        publish_date=date(1997, 6, 26),\n        author=Person(name='J. K. Rowling')\n    )\n\n    # Dumping\n    BookType.dump(harryPotter1)\n    # => {'title': 'Harry Potter and the Philosopher\\'s Stone',\n    #     'publish_date': '1997-06-26',\n    #     'author': {'name': 'J. K. Rowling'}}\n\n    # Loading\n    BookType.load({'title': 'Harry Potter and the Philosopher\\'s Stone',\n                   'publish_date': '1997-06-26',\n                   'author': {'name': 'J. K. Rowling'}})\n    # => Book(title='Harry Potter and the Philosopher\\'s Stone',\n    #         publish_date=date(1997, 06, 26),\n    #         author=User(name='J. K. Rowling'))\n\n    # Partial inplace loading\n    BookType.load_into(harryPotter1, {'publish_date': '1997-06-27'})\n    # => Book(title='Harry Potter and the Philosopher\\'s Stone',\n    #         publish_date=date(1997, 06, 27),\n    #         author=User(name='J. K. Rowling'))\n\n    # Loading list of objects\n    List(BookType).load([\n        {'title': 'Harry Potter and the Philosopher\\'s Stone',\n         'publish_date': '1997-06-26',\n         'author': {'name': 'J. K. Rowling'}},\n        {'title': 'Harry Potter and the Chamber of Secrets',\n         'publish_date': '1998-07-02',\n         'author': {'name': 'J. K. Rowling'}},\n    ])\n    # => [Book(...), Book(...)]\n\n    # Validation\n    BookType.validate({\n        'title': 'Harry Potter and the Philosopher\\'s Stone',\n        'author': {'name': ''},\n    })\n    # => {'author': {'name': 'Length should be at least 1'},\n    #     'publish_date': 'Value is required'}\n\n\nInstallation\n============\n\n::\n\n    $ pip install lollipop\n\n\nDocumentation\n=============\n\nDocumentation is available at http://lollipop.readthedocs.io/ .\n\n\nRequirements\n============\n\n- Python >= 2.6 or <= 3.6\n\n\nProject Links\n=============\n\n- Documentation: http://lollipop.readthedocs.io/\n- PyPI: https://pypi.python.org/pypi/lollipop\n- Issues: https://github.com/maximkulkin/lollipop/issues\n\n\nLicense\n=======\n\nMIT licensed. See the bundled `LICENSE <https://github.com/maximkulkin/lollipop/blob/master/LICENSE>`_ file for more details.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Data serialization and validation library",
    "version": "1.1.8",
    "project_urls": {
        "Homepage": "https://github.com/maximkulkin/lollipop"
    },
    "split_keywords": [
        "serialization",
        "rest",
        "json",
        "api",
        "marshal",
        "marshalling",
        "deserialization",
        "validation",
        "schema",
        "marshmallow"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0549d58d63f9566de914853f67182ef836a0d03369a6fd07e343ec4c07330511",
                "md5": "0fff1cb25b4b8d7b762a4e739b93956d",
                "sha256": "9801cb0fd45056112b99969b6866d777738c02dee6ad8ffc9e609bc6e768b303"
            },
            "downloads": -1,
            "filename": "lollipop-1.1.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0fff1cb25b4b8d7b762a4e739b93956d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 23605,
            "upload_time": "2023-07-06T02:38:44",
            "upload_time_iso_8601": "2023-07-06T02:38:44.556683Z",
            "url": "https://files.pythonhosted.org/packages/05/49/d58d63f9566de914853f67182ef836a0d03369a6fd07e343ec4c07330511/lollipop-1.1.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b4a20802ee33aed913fa0d1ef8a81615d28748a09c8878caa2d4c8f9fc58adad",
                "md5": "c918eca92f36c49c00b2c0ce1a14c243",
                "sha256": "bf4897800ca6272377bff02d6cab6c50fcdda9763b38030851c34dc84a357f7b"
            },
            "downloads": -1,
            "filename": "lollipop-1.1.8.tar.gz",
            "has_sig": false,
            "md5_digest": "c918eca92f36c49c00b2c0ce1a14c243",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 78560,
            "upload_time": "2023-07-06T02:38:46",
            "upload_time_iso_8601": "2023-07-06T02:38:46.518730Z",
            "url": "https://files.pythonhosted.org/packages/b4/a2/0802ee33aed913fa0d1ef8a81615d28748a09c8878caa2d4c8f9fc58adad/lollipop-1.1.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-06 02:38:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "maximkulkin",
    "github_project": "lollipop",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "tox": true,
    "lcname": "lollipop"
}
        
Elapsed time: 0.47502s