Skip to main content

Transform dictionaries into Python objects

Project description

Easily create Python objects from dictionaries- basically an ORM that can work with any type of database. Usage example:

from cargo.spec import Spec, unpack
from cargo.fields import Field

class Model(Spec):
    name    = Field(str).With.length(6)
    version = Field(tuple).where.each.Is.An(int)

unpack(Model, {
    'name':'Eugene',
    'version':(0,1)
    })

Nested unpacking is currently supported but the library assumes that you are passing in objects of a reasonable depth (i.e. not recursive) and therefore does not cache the seen values.

cargo is still work in progress and it’s API may change either completeley or partially, or the internal functionality modified without any notice at any given point in time.

You can now get this package easily by installing the latest release from the Python Package Index, something like the following:

$ pip install cargo

If you want to run the test suites or contribute some code you need to install a library called Requires via pip, i.e. which will make the tests run:

$ pip install Requires
$ git clone ssh://git@github.com/eugene-eeo/cargo
$ python cargo/tests.py

Project details


Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page