Skip to main content

Fast functional serializers

Project description

https://img.shields.io/pypi/v/pystrainer.svg

Strainer is a different take on serialization and validation in python. It utilizes a functional style over inheritance.

An example of Strainer, the example has been borrowed from Marshmallow

artist_serializer = create_serializer(
  field('name')
)

album_schema = create_serializer(
  field('title'),
  field('release_date'),
  child('artist', serializer=artist_serializer)
)

class Artist(object):
    def __init__(self, name):
        self.name = name

class Album(object):
    def __init__(self, title, release_date, artist):
        self.title = title
        self.release_date = release_date
        self.artist = artist

bowie = Artist(name='David Bowie')
album = Album(
    artist=bowie,
    title='Hunky Dory',
    release_date=date(1971, 12, 17)
)

simple_data = album_schema.to_representation({}, album)

pprint.pprint(simple_data)

# {'artist': {'name': 'David Bowie'},
#  'release_date': datetime.date(1971, 12, 17),
#  'title': 'Hunky Dory'}

Installation

To install Strainer, simply:

$ pip install pystrainer
✨🍰✨

Satisfaction, guaranteed.

Documentation

Fantastic documentation is available at http://docs.python-requests.org/, for a limited time only.

How to Contribute

  1. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug. There is a Contributor Friendly tag for issues that should be ideal for people who are not very familiar with the codebase yet.

  2. Fork the repository on GitHub to start making your changes to the master branch (or branch off of it).

  3. Write a test which shows that the bug was fixed or that the feature works as expected.

  4. Send a pull request and bug the maintainer until it gets merged and published. :) Make sure to add yourself to AUTHORS.

Release History

0.0.1 (2016-11-23)

  • Birth

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pystrainer-0.0.1.tar.gz (4.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page