Skip to main content

Module for validating and transforming data

Project description

https://badge.fury.io/py/duc.svg https://travis-ci.org/bmwant21/duc.svg?branch=master https://coveralls.io/repos/bmwant21/duc/badge.svg?branch=master

Duc (transducer) is a data transformation tool for Python.

>>> d = Duc({'name': {'validator': {'type': 'string'}, 'transform': {'name': 'number_name', 'type': 'integer'}})
>>> v.validate({'name': '518'})
True
>>> v.transform()
True
>>> v.result
{'number_name': 518}

About

Sometimes your application receives data from one place and then (after some transformation) sends it to other place. Often you cannot change the format of data you receive because source dictates its own requirements. But with Duc you can validate input (using Cerberus) and make transformations on it (using similar syntax). Particular example is when you get data from a client and save it to database. You want to validate it or leave it as-is (if you trust client) but select specific fields or transform data to other format is required. Slightly like forms in web-application. It was tested under Python 3.4. Compatibility with other versions is not guaranteed.

Documentation

Complete documentation is missed by you can check examples.py for code snippets and usage illustration

Installation

Duc is on PyPI so all you need is:

$ pip install duc

Also you can install it from Github directly (to use latest version)

$ pip install git+https://github.com/bmwant21/duc.git

Testing

Just run (with Pytest):

$ py.test tests

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

duc-1.2.zip (5.6 kB view details)

Uploaded Source

File details

Details for the file duc-1.2.zip.

File metadata

  • Download URL: duc-1.2.zip
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for duc-1.2.zip
Algorithm Hash digest
SHA256 1d3393ca4ad677316099d3714e31663236a317fb2999f6871ec936d0569df203
MD5 32f77d1a9f465fd6dc66f9f2e70acb00
BLAKE2b-256 80524215aa683c0d4746f2dbf9d3aabe38d5e2216da1db5affca863374099033

See more details on using hashes here.

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