Welcome to pykwalify’s documentation!¶
PyKwalify is a open source port of the kwalify lib and specification. The original source code was written in Java but this port is based on Python. The code is open source, and available on github.
YAML/JSON validation library
This framework is a port with alot added functionality of the java version of the framework kwalify that can be found at: http://www.kuwata-lab.com/kwalify/
The source code can be found at: http://sourceforge.net/projects/kwalify/files/kwalify-java/0.5.1/
The schema this library is base and extended from: http://www.kuwata-lab.com/kwalify/ruby/users-guide.01.html#schema
Create a data file. Json and Yaml formats are both supported.
- foo - bar
Create a schema file with validation rules.
type: seq sequence: - type: str
Run validation from cli.
pykwalify -d data.yaml -s schema.yaml
The documentation describes in detail how each keyword and type works and what is possible in each case.
But there is a lot of real world examples that can be found in the test data/files. It shows alot of examples of how all keywords and types work in practise and in combination with eachother.
The files can be found here and it shows both schema/data combinations that will work and that will fail.
PyYaml and ruamel.yaml¶
PyYaml is the default installed yaml parser and
ruamel.yaml is possible to install at the same time with the following command
pip install 'pykwalify[ruamel]' # or for development: pip install -e '.[ruamel]'
ruamel.yaml will however be used if both is installed becuase it is more up to date and includes the YAML 1.2 specification that
PyYaml do not support.
PyYaml will still be the default parser becuase it is used more and is still considered the default
YAML parser in the python world.
Depending on how both libraries is developed, this can change in the future in any major update.
UTF-8 and data encoding¶
If you have problems with unicode values not working properly when running pykwalify on python 2.7.x then try to add this environment variable to your execution and it might help to force UTF-8 encoding on all string objects.
If this do not work please open up a issue with your schema and data that can be used to track down the problem in the source code.
PYTHONIOENCODING=UTF-8 pykwalify ...
|python support||2.7, 3.3, 3.4, 3.5, 3.6, 3.7|
|Docs (Latest release)||http://pykwalify.readthedocs.io/en/master/|
|Docs (Unstable branch)||http://pykwalify.readthedocs.io/en/unstable/|
|Gitter (Free Chat)|
|Copyright||Copyright (c) 2013-2017 Johan Andersson|
|git repo||git clone firstname.lastname@example.org:Grokzen/pykwalify.git|
|install stable||pip install pykwalify|
$ git clone email@example.com:Grokzen/pykwalify.git pykwalify $ cd ./pykwalify $ virtualenv .venv $ source .venv/bin/activate $ pip install -r dev-requirements.txt $ pip install -e .
docopt >= 0.6.2
python-dateutil >= 2.4.2
|supported yml parsers||
PyYaml >= 3.11
ruamel.yaml >= 0.11.0