Skip to main content

python-cuddle

CI

A Python library for the KDL Document Language.

Install

pip install cuddle

Or if you're using poetry:

poetry add cuddle

Cuddle supports Python 3.9 and above.

Usage

from cuddle import Document, Node, NodeList, dumps, loads

loaded_doc = loads('''// Nodes can be separated into multiple lines
title \
  "Some title"

// Nested nodes are fully supported
contents {
  section "First section" {
    paragraph "This is the first paragraph"
    paragraph "This is the second paragraph"
  }
}

// Files must be utf8 encoded!
smile "😁"

// Instead of anonymous nodes, nodes and properties can be wrapped
// in "" for arbitrary node names.
"!@#$@$%Q#$%~@!40" "1.2.3" "!!!!!"=true

// The following is a legal bare identifier:
foo123~!@#$%^&*.:'|/?+ "weeee"

// And you can also use unicode!
ノード お名前="☜(゚ヮ゚☜)"

// kdl specifically allows properties and values to be
// interspersed with each other, much like CLI commands.
foo bar=true "baz" quux=false 1 2 3
''')
print(dumps(loaded_doc))

print()

# Creating documents from scratch is a bit verbose
nodes = []
child_node = Node("complex name here!", None)
nodes.append(
    Node("simple-name", None, arguments=[123], children=[child_node])
)
nodes.append(
    Node("second-node", None, properties={"key": "value"})
)
node_list = NodeList(nodes)
doc = Document(node_list)
print(dumps(doc))

The output:

title "Some title"
smile "😁"
!@#$@$%Q#$%~@!40 !!!!!=true "1.2.3"
foo123~!@#$%^&*.:'|/?+ "weeee"
ノード お名前="☜(゚ヮ゚☜)"
foo bar=true quux=false "baz" 1 2 3

simple-name 123 {
  "complex name here!"
}
second-node key="value"

License

The code is available under the MIT license.

Metadata

Release files for cuddle 1.0.6

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

Source distribution (sdist)

Source distribution for cuddle 1.0.6
File Size Uploaded Provenance
cuddle-1.0.6.tar.gz 37.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cuddle 1.0.6
File Interpreter ABI Platform
cuddle-1.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 52.6 kB

Release files / cuddle-1.0.6.tar.gz

Download URL cuddle-1.0.6.tar.gz
Size 37.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1ad9ac0077cdccc8b6b85794635c895a91fe312a3d9f8d1cb4c7591921fb06c5
BLAKE2b-256 checksum
How to use checksums
520d431efa5679a6b7fa01c49463b8371ade2ed20b91af7b79eeda8f039500b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

Release files / cuddle-1.0.6-py3-none-any.whl

Download URL cuddle-1.0.6-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bbf0163b069bd0a9cfe0493d07388cfdbf2641bfd285fd2fb546094e58018fc3
BLAKE2b-256 checksum
How to use checksums
b04b7b5ead7c30116a7b4124baa3a390c7d76ac9f84fcc32f1f11eab40c03fd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

Security for cuddle 1.0.6

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.

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