Validate CBOR documents using CDDL schema language
Project description
PyCDDL: A CDDL validation library for Python
CDDL is a schema language for the CBOR serialization format.
pycddl
allows you to validate CBOR documents match a particular CDDL schema, based on the Rust cddl
library.
For example, here we use the cbor2
library to serialize a dictionary to CBOR, and then validate it:
from pycddl import Schema
import cbor2
uint_schema = Schema("""
object = {
xint: uint
}
"""
)
uint_schema.validate_cbor(cbor2.dumps({"xint", -2}))
If validation fails, a pycddl.ValidationError
is raised.
Reducing memory usage and safety constraints
In order to reduce memory usage, you can pass in any Python object that implements the buffer API and stores bytes, e.g. a memoryview()
or a mmap
object.
The passed-in object must be read-only, and the data must not change during validation! If you mutate the data while validation is happening the result can be memory corruption or other undefined behavior.
Release notes
0.5.2
- Upgrade to newer
cddl
crate (0.9.2), improving validation functionality.
0.5.1
- Upgrade to newer
cddl
crate, fixing some validation bugs.
0.5.0
- Support for ARM macOS.
- Dropped Python 3.7 support.
0.4.1
- Test fixes, with no user-relevant changes.
0.4.0
validate_cbor()
now accepts read-only buffers, not justbytes
. This is useful if you want to e.g. validate a large file, since you canmmap()
it.- The GIL is released when parsing documents larger than 10KiB.
0.3.0
- Fixed major bug where if the document was valid UTF-8, the library would attempt to parse it as JSON!
- Added support for ARM macOS.
0.2.2
- Updated to
cddl
0.9.1.
0.2.1
- Added PyPy wheels.
0.2.0
- Schemas are now only parsed once (when the
Schema()
object is created), instead of every time validation happens, which should improve validation performance. - Updated to a newer version of underlying CDDL library, which should make CDDL parsing more compliant.
- Added a
repr()
implementation toSchema
for easier debugging.
0.1.11
- Initial release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for pycddl-0.5.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4c1f9dda954e93ef1845338af333b9022ee32b583b0b5300db1704a4d96f74d |
|
MD5 | 4f177962b2f733f9ad47fe286fc95b2f |
|
BLAKE2b-256 | 7ecb5f82d7dbc709e922040d2d2260bdef6c10742986658631189eafe1734cf1 |
Hashes for pycddl-0.5.2-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a69f72c5c5c17f6f0f37fe3a43e417b7bfb5536f20a0fb8725a67ab1a8846a74 |
|
MD5 | 21a7169c2f70e80136bbe2935a447c4f |
|
BLAKE2b-256 | fa1b4ffb03dd82a86af2670673692e356d64e0e63b4900bbb4392dae55f91916 |
Hashes for pycddl-0.5.2-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7497f9ce35fe7b27469c66ff93483cfa4994939c3e95bfc38f8f2e5eabc6787 |
|
MD5 | f6bcec0b0390635b954f702126a83a7c |
|
BLAKE2b-256 | 6e3152a98abcfcc1855ec4538828b046e61e20d092bc0a43be7f442ef44da86a |
Hashes for pycddl-0.5.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9876ceab6240af3eebdc3e58669412165df2b7ceddfdbe86c4836d99c1cb19b |
|
MD5 | e754fcb8721a09e14e66cc3dae3118f2 |
|
BLAKE2b-256 | a725295ccab7a11fa1890c32b5d85331e92f00cad19c9168e4fe39f56fb54299 |
Hashes for pycddl-0.5.2-cp311-cp311-macosx_11_0_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8629269f98f93281e2637fef9901f8a0f28086c0745a559d9bc157516b1363d2 |
|
MD5 | b6b49a377a3186599e50079bdc6c8e38 |
|
BLAKE2b-256 | 7a34cade19c8c3c60f505b9c494625d10c069efeaf5743b8a76507b31cdbc8dd |
Hashes for pycddl-0.5.2-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e68f70f86d34c8b04073eac3bd510d4d4d619d64527bf3ac2026bdce39dd5274 |
|
MD5 | d2253df38f6157be35af5a46c38fe716 |
|
BLAKE2b-256 | c5d321b45bd27e7b034621a930d5f9812660b9392906862500dd190c7c0c78c5 |
Hashes for pycddl-0.5.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5029be2bf576c77d0c31ef322d7e51922fc915a189c4a650e98bf2c45f22cb58 |
|
MD5 | b7a4f83229bec611812076547b7859dc |
|
BLAKE2b-256 | 8fbd66069542b0e2695cd34769fd5ac89a3d3248f4965639794750eea0ec16b3 |
Hashes for pycddl-0.5.2-cp310-cp310-macosx_11_0_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04511718198e61b0fec4e742971e2f7bfc9dadffd42de5bcd76415b50e43d1a3 |
|
MD5 | c09bc17d34deb76fa19fc463626deb8c |
|
BLAKE2b-256 | d2ec63a5f12f62a8287fb8f9fb6b03ee6586b51f684f259744d2de61919b6117 |
Hashes for pycddl-0.5.2-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6378b86ac82184289ad7617d62061ef819eb39d374b07a0f1bc4571621d4dd50 |
|
MD5 | 5680a4cf3d4ad404f2c60cc5524c586a |
|
BLAKE2b-256 | 95e92e4592a0eb02d9df008f41c4ed8be6a1057a7e5d210e4c879947e4ca5a29 |
Hashes for pycddl-0.5.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 788990fa32c0cf7dea43e63e6472acbfd9325e86323e93510e9836c23e844fbb |
|
MD5 | 5a06a2bd99a4f495918fd8fbfdeeefc4 |
|
BLAKE2b-256 | 744f0c5b028068bb1671f682997e5b524d07ca55a543fc3ceb289b8bb4d8010b |
Hashes for pycddl-0.5.2-cp39-cp39-macosx_11_0_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d33cc48b4d49a0ef460fdb66eee9cf7b262aedf3142ccbbe6f643adbe5d684c |
|
MD5 | a6e6c4037da00320eb35fc9d07b6f189 |
|
BLAKE2b-256 | f7e29d6b17ba187a56845efd0ea339741808b5856ccc7493041dd2bf727d5611 |
Hashes for pycddl-0.5.2-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e55b27bab25e8d3b4e7209d28b6927c3fcc2415f71134f55daae0872425f145d |
|
MD5 | 5c35dfc2817d75bc93fe473c9075a490 |
|
BLAKE2b-256 | f41e08bd71ba6ebb8fb169c95717db4e8d8bbda6f6cc750c292f6cde207be05d |
Hashes for pycddl-0.5.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4174eb34d74a632f82ddb2e9c2fa0c3336f61509b3e633c386b64190944b01e1 |
|
MD5 | 30626ee278a236e4aac81858299aa604 |
|
BLAKE2b-256 | 44f0777f503699c26544e63aa68b35aefe8d72538245b59cb71d10e771e387f8 |
Hashes for pycddl-0.5.2-cp38-cp38-macosx_11_0_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c35a595a2cb0a94b92c9bb8155d331f92ac285583170e34fcdd2fcfc0d3965e |
|
MD5 | c7ff19ad6435f37a0934be7f8785e197 |
|
BLAKE2b-256 | f15b072dd3b798bb5306d70281b48651b9e415c6826bdb7a53dac97324c4f0a4 |