Skip to main content

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.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 just bytes. This is useful if you want to e.g. validate a large file, since you can mmap() 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 to Schema for easier debugging.

0.1.11

  • Initial release.

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

pycddl-0.5.1.tar.gz (20.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pycddl-0.5.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

pycddl-0.5.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

pycddl-0.5.1-cp311-none-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.11Windows x86-64

pycddl-0.5.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pycddl-0.5.1-cp311-cp311-macosx_11_0_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl (2.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64macOS 11.0+ universal2 (ARM64, x86-64)macOS 11.0+ x86-64

pycddl-0.5.1-cp310-none-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.10Windows x86-64

pycddl-0.5.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pycddl-0.5.1-cp310-cp310-macosx_11_0_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl (2.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64macOS 11.0+ universal2 (ARM64, x86-64)macOS 11.0+ x86-64

pycddl-0.5.1-cp39-none-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.9Windows x86-64

pycddl-0.5.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pycddl-0.5.1-cp39-cp39-macosx_11_0_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl (2.4 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64macOS 11.0+ universal2 (ARM64, x86-64)macOS 11.0+ x86-64

pycddl-0.5.1-cp38-none-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.8Windows x86-64

pycddl-0.5.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

pycddl-0.5.1-cp38-cp38-macosx_11_0_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl (2.4 MB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64macOS 11.0+ universal2 (ARM64, x86-64)macOS 11.0+ x86-64

File details

Details for the file pycddl-0.5.1.tar.gz.

File metadata

  • Download URL: pycddl-0.5.1.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.1.0

File hashes

Hashes for pycddl-0.5.1.tar.gz
Algorithm Hash digest
SHA256 f564a88b6eb5c30e2a9ecc4551ef3429479e991d256b185d0ec362a9a769f7b9
MD5 5712aad6b5b583ea5faf6da6baaee196
BLAKE2b-256 a12320acd7c63806688d1a8c16d56d25948951858fa587b1bd19dc8f96387a75

See more details on using hashes here.

File details

Details for the file pycddl-0.5.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pycddl-0.5.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f0f98cf523a3350d1c843838cc650ff257e15cb284b32e2ffba0b6ddd93c247c
MD5 7d6e1eaa7e6b963813f442aaa3fbdf34
BLAKE2b-256 ec94b9ced068e731d07a6eb075cba8b06e91849a8577286a7c613bb756b0110e

See more details on using hashes here.

File details

Details for the file pycddl-0.5.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pycddl-0.5.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aeb0f52bc00a17bb212ae24088f4d57383c9af0b14a4756d27334b744e8c7045
MD5 03fc1f0b04d1ee9dccd2a8c46301a5b2
BLAKE2b-256 0ffe3d778aeaafdb8be26d8b788d660cbea4dd3f9c4a077109a153eded38bd45

See more details on using hashes here.

File details

Details for the file pycddl-0.5.1-cp311-none-win_amd64.whl.

File metadata

  • Download URL: pycddl-0.5.1-cp311-none-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.1.0

File hashes

Hashes for pycddl-0.5.1-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 8e2e0b3e68402bfb88714c5fa606e1ed3dda01c6a2ff45444f98820fd0481005
MD5 923d39513a00b9f749d99f38052b25f8
BLAKE2b-256 b507840c019648e1863b93902431429d9e1f50714b0a35849e11da36a7c87ac8

See more details on using hashes here.

File details

Details for the file pycddl-0.5.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pycddl-0.5.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7421f56f23ac745c74577b56e30c4e9da132baa1448d42811e6a14f1b03fd5c5
MD5 0644320b6361be0cc965ee47d12f457d
BLAKE2b-256 1aed95a6aac470e7e5128be0d8bcc31143f9ebbbaa8f73574b407b97b93f0144

See more details on using hashes here.

File details

Details for the file pycddl-0.5.1-cp311-cp311-macosx_11_0_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for pycddl-0.5.1-cp311-cp311-macosx_11_0_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 8d023487342e6f71eb04225a84e611e0dc3462cd330625a6442bb0ddf4c4b112
MD5 b676d82a9345638147298939e975bbb1
BLAKE2b-256 38f506c605d514cf1c725170aa7b44c3faca6e379bb73ebde55b9df7994dd875

See more details on using hashes here.

File details

Details for the file pycddl-0.5.1-cp310-none-win_amd64.whl.

File metadata

  • Download URL: pycddl-0.5.1-cp310-none-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.1.0

File hashes

Hashes for pycddl-0.5.1-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 331e03af0b0cec0cf5e85a533bb8decaac5775658cf3b86cc5fb05a1e85ab3e9
MD5 db8ece9ceda77a2f8f0c5021a242c758
BLAKE2b-256 58f11daae7410f7f42a7e3e8241a554a05e924bc1498a8fa2cff31a4e911d08a

See more details on using hashes here.

File details

Details for the file pycddl-0.5.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pycddl-0.5.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5ebf0f6038c39514ced48c338b68395bbb1bc31bd22d91dc0100c630e618d4ba
MD5 76a0021c6c9812f078555c6f57da2a27
BLAKE2b-256 22b50cbae8a9d7e8f3ad75390ec433444304281bdabbd8ea6f12596a554b163d

See more details on using hashes here.

File details

Details for the file pycddl-0.5.1-cp310-cp310-macosx_11_0_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for pycddl-0.5.1-cp310-cp310-macosx_11_0_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 91ad1a8b44b34607c5fba730720e9935b20ba09353d15d4b818db8b3edebc1da
MD5 725c9e87048ebc0a20ed90cb6f65f2bd
BLAKE2b-256 1f8adc7276342d9008654cd0702b73ae8e32f9b135de25adb38802099248df59

See more details on using hashes here.

File details

Details for the file pycddl-0.5.1-cp39-none-win_amd64.whl.

File metadata

  • Download URL: pycddl-0.5.1-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.1.0

File hashes

Hashes for pycddl-0.5.1-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 6f5f5d1b39b265452f09131f05c7813f80150d8c435cad683d4cfbe59e5d64ba
MD5 0ca7295710856c576cb56ca8799c45f7
BLAKE2b-256 682526c1800ca2db7ae231a83a86716709a993ef71db3db271dd940280f0e1d3

See more details on using hashes here.

File details

Details for the file pycddl-0.5.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pycddl-0.5.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 063858b20f3cef0d6d1c233d10033af1031f9f3c46ed91ba28f31f92fb04fdac
MD5 a793571835f7507142d90a1269254701
BLAKE2b-256 4f8c13ccfd1d9cf2127588412f7a0ed2fe6057ee6e4d5ea49dbabb24530f4b88

See more details on using hashes here.

File details

Details for the file pycddl-0.5.1-cp39-cp39-macosx_11_0_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for pycddl-0.5.1-cp39-cp39-macosx_11_0_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 d57892bc8f9c2ee324e88b816df68f5b0e85beafc599f6bf195c20a741d17c44
MD5 e30aa81d233378b4d5380f9bca4b233e
BLAKE2b-256 207823a1edaf24c91f2991c585ee8cc98f26bea90f5ec6c1ebdb190b5b5c2da7

See more details on using hashes here.

File details

Details for the file pycddl-0.5.1-cp38-none-win_amd64.whl.

File metadata

  • Download URL: pycddl-0.5.1-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.1.0

File hashes

Hashes for pycddl-0.5.1-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 6d835b5528da3cf35b0730f2495f3834388dc8240e61990421a7c53fb1b1b37b
MD5 287103299c87fa82f7ffbb1a26aeda35
BLAKE2b-256 5ccfea688d1126c59b57e14a7be7c6b379ad3053cec6dda22be5beecc2af9045

See more details on using hashes here.

File details

Details for the file pycddl-0.5.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pycddl-0.5.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2b733a961aee2128e3a0ad4170471aceb8d4e16169710ef54245d4339bacc1c0
MD5 87e596baa926d207238e0d7cfca5a2ef
BLAKE2b-256 54cc22a1702e535c567cdc0999d8d2d6154195061b643004168f3184c0098804

See more details on using hashes here.

File details

Details for the file pycddl-0.5.1-cp38-cp38-macosx_11_0_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for pycddl-0.5.1-cp38-cp38-macosx_11_0_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 820c0f8ab7c42debcea7dcaf4e72d20b5eebe83b7bacaf62c79d1447b9afbc70
MD5 672ef5a83d027db4203f0019ddbb1142
BLAKE2b-256 9ac1fe934536f358bed2e4caa1161bee6561f925883cdd115c525c2581db1975

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page