RETIRED, further work has moved to Debian project infrastructure
Go to file
Brian Waldon 19b2b3e103 Release version 1.3.0 2016-06-25 11:13:15 -07:00
test flake8 compliance 2016-06-25 11:04:19 -07:00
warlock Better error message on __setitem__ failure (#22) 2016-06-25 11:06:43 -07:00
.gitignore Break up core pieces into separate modules 2012-12-22 15:39:09 -08:00
.travis.yml Run python setup.py develop in Travis 2016-06-25 11:08:28 -07:00
HACKING.txt Update HACKING.txt 2016-06-25 11:05:23 -07:00
LICENSE.txt Add license headers to source files 2013-01-31 07:16:37 -08:00
MANIFEST.in LICENSE.txt was missing in the source tarball 2013-10-10 01:07:23 +02:00
README.md Setup Travis CI config 2016-06-25 10:41:34 -07:00
requirements.txt Add python3 support 2013-07-23 07:10:27 -07:00
setup.cfg Support universal wheels 2015-10-02 00:48:00 +01:00
setup.py Release version 1.3.0 2016-06-25 11:13:15 -07:00

README.md

Warlock

Build Status

Build self-validating python objects using JSON schemas.

  1. Create your schema

    schema = { 'name': 'Country', 'properties': { 'name': {'type': 'string'}, 'abbreviation': {'type': 'string'}, 'population': {'type': 'integer'}, }, 'additionalProperties': False, }

  2. Create a model

    import warlock Country = warlock.model_factory(schema)

  3. Create an object using your model

    sweden = Country(name='Sweden', abbreviation='SE')

  4. Let the object validate itself

    sweden.name = 5 Traceback (most recent call last): File "", line 1, in File "warlock/core.py", line 53, in setattr raise InvalidOperation(msg) warlock.core.InvalidOperation: Unable to set 'name' to '5'

    sweden.overlord = 'Bears' Traceback (most recent call last): File "", line 1, in File "warlock/core.py", line 53, in setattr raise InvalidOperation(msg) warlock.core.InvalidOperation: Unable to set 'overlord' to 'Bears'

  5. Generate a JSON Patch document to track changes

    sweden.population=9453000 sweden.patch '[{"path": "/population", "value": 9453000, "op": "add"}]'