cuddly_dicts
Turn a KDL document like this:
landtable version=1 {
// Minimum compatible Landtable version
ensure_landtable_version "0.0.1"
provisioning {
// Whether to allow runtime provisioning
// (whether you can add/remove fields via the API or the web)
allow_runtime_provisioning true
// A provisioning strategy defines how a new database can be
// created.
strategy "Nest Postgres" {
primary {
using "postgres_provisioning_plugin"
hostname "hackclub.app"
authentication "userpass" {
username "sarah"
password "i_l0ve_hC!"
}
// or:
authentication "vault-pg" {
path "database/creds/landtable"
}
}
}
}
}
Into a dict like this:
{
"landtable": {
"version": 1,
"ensure_landtable_version": "0.0.1",
"provisioning": {
"allow_runtime_provisioning": True,
"strategy": {
"Nest Postgres": {
"primary": {
"using": "postgres_provisioning_plugin",
"hostname": "hackclub.app",
"authentication": {
"userpass": {
"username": "sarah",
"password": "i_l0ve_hC!"
}
}
}
}
}
}
}
}
Conversion rules
version 1
becomes
{
"version": 1
}
version 1
version 2
becomes
{
"version": [1, 2]
}
connector "foo"
connector "bar" {
port /dev/ttyUSB0
}
becomes
{
"connector": {
"foo": {},
"bar": {
"port": "/dev/ttyUSB0"
}
}
}
[!INFO] New in 3.0.2.
connector "foo" port="/dev/ttyUSB0"
becomes
{
"connector": {
"foo": {
"port": "/dev/ttyUSB0"
}
}
}
connector "foo" port="/dev/ttyUSB0" {
baud_rate 24000
}
becomes
{
"connector": {
"foo": {
"port": "/dev/ttyUSB0",
"baud_rate": 24000
}
}
}
cuddly_dicts (as of v3) supports value converters, so you can do things like this:
definitely_encrypted_ssn (base64)"QUFBLUdHLVNTU1M="
License
MIT or WTFPL, depending on how much of a prude you are
Motivation
- Keep using Landtable's existing validation library (Pydantic)
- Support multiple configuration languages (TOML, JSON, YAML, whatever!) by making them all compile down to the same representation that can be validated
cuddly_dicts proved to be more useful to me in other projects, so now I use it in most things.
Metadata
Release files for cuddly-dicts 3.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cuddly_dicts-3.0.2.tar.gz | 5.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cuddly_dicts-3.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.6 kB
Release files / cuddly_dicts-3.0.2.tar.gz
| Download URL | cuddly_dicts-3.0.2.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a722e97df6f898e23a186e2580cdba038ed4ddf31121965978c10390e254b61a
|
|
BLAKE2b-256 checksum How to use checksums |
d9ea71409617b040187369c1784246394574685d520a73d35b9481a44b4fb1bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 29, 2025.
Transparency logRelease files / cuddly_dicts-3.0.2-py3-none-any.whl
| Download URL | cuddly_dicts-3.0.2-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9531ecb2d7150262e450f1caa864ce21d8db648b6adf9c35dd2bf1328928e7ce
|
|
BLAKE2b-256 checksum How to use checksums |
0ba0eb58010aff67023904b139abb7c19d3c3c97d886a55a651324d605c05cbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 29, 2025.
Transparency log