Skip to main content

Python implementation of the cnf format

Packages

  • cnfembed - Text-preserving cnf to json, a single file for embedding.
  • cnftest - Harness to run the conformance tests.

Specification

Consult the full specification for examples and details of the format.

Running tests

The cnftest harness runs the full conformance corpus, from a local copy of the spec kept for the tests. To run the tests:

python3 -m unittest discover

Example

This simple example shows the conversion of cnf to json:

key: "value"
nested.key: 0xff
string:
    """
    Hello
    world
    """

One call decodes it to JSON:

from cnfembed import to_json

json = to_json(doc)

This results in:

{"key":"value","nested":{"key":255},"string":"Hello\nworld\n"}

For the time being this port converts one direction only: cnf to json.

A string that fails to parse raises Error with the message including the line and column of the problem:

from cnfembed import Error, to_json

try:
    to_json("a: bare\n")
except Error as err:
    print(err)  # 1:4: cannot parse unquoted value `bare`

For actual embedding into your project, you may opt to copy the cnfembed/cnf.py file alone.

Metadata

Release files for python-cnf 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-cnf 0.0.1
File Size Uploaded Provenance Actions
python_cnf-0.0.1.tar.gz 61.0 kB Without provenance Details for python_cnf-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for python-cnf 0.0.1
File Interpreter ABI Platform Actions
python_cnf-0.0.1-py3-none-any.whl Python 3 none any Details for python_cnf-0.0.1-py3-none-any.whl

Total release size: 79.8 kB

Release files / python_cnf-0.0.1.tar.gz

Download URL python_cnf-0.0.1.tar.gz
Size 61.0 kB
Tags Source
SHA-256 checksum
How to use checksums
aa1873f800eaea067f9c7bda00ccee9eaa84144eb7dbada99b848e844793c58e
BLAKE2b-256 checksum
How to use checksums
3d142086dcf7b6c94842e30d0472db87da33c0ed1c7b715fe973b974967506b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / python_cnf-0.0.1-py3-none-any.whl

Download URL python_cnf-0.0.1-py3-none-any.whl
Size 18.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
79256d76df6ae4a4c6f391404b3545184fecd744dfb95239a524c13ee27ca385
BLAKE2b-256 checksum
How to use checksums
c3021c7d334f41e9ce77420aa8e6c2ab8e18a0709226974fe76717e39b68b66b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for python-cnf 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page