Python bindings for kaiv, a Kv Format Swiss-Army knife
Project description
kaiv — Kv Format Swiss-Army knife
Python bindings for kaiv-rs, the
Kv Format Swiss-Army knife CLI tool.
Install the kaiv CLI and its Python API in one step:
pip install kaiv
CLI usage
# Print a value by key
kaiv get APP_NAME config.kv
# Validate a KV file
kaiv check config.kv
# Re-output in canonical form (sorted keys, no comments)
kaiv fmt config.kv
# Export to JSON
kaiv export json config.kv
# Import from JSON
kaiv import json config.json
Pass - or omit the file argument to read from stdin.
Python API
import kaiv
# Get a value by key (returns None if not found)
value = kaiv.get("APP_NAME", "APP_NAME=My App\nDEBUG=true\n")
# => "My App"
# Validate KV input (returns a list of error strings, empty if valid)
errors = kaiv.check("APP_NAME=My App\nDEBUG=true\n")
# => []
# Canonical form (sorted keys, no comments/blanks)
canonical = kaiv.fmt("DEBUG=true\nAPP_NAME=My App\n")
# => "APP_NAME=My App\nDEBUG=true\n"
# Export KV to JSON
json_str = kaiv.export_json("APP_NAME=My App\nDEBUG=true\n")
# => '{"APP_NAME":"My App","DEBUG":"true"}'
# Import JSON to KV
kv_str = kaiv.import_json('{"APP_NAME":"My App","DEBUG":"true"}')
# => "APP_NAME=My App\nDEBUG=true\n"
All functions accept a string of KV content (not a file path) and raise
ValueError on invalid input.
Development
Prerequisites: Rust toolchain, Python ≥ 3.8, maturin
pip install maturin
# Build and install into the current virtualenv for development
maturin develop
# Build a release wheel
maturin build --release
# Publish to PyPI
maturin publish
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kaiv-0.1.0.tar.gz.
File metadata
- Download URL: kaiv-0.1.0.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de13579e358503c1c30f7343c81542529eb20f36f7bc20f5d971b229c79104e2
|
|
| MD5 |
123b49bc4665c2d37bf5386ad723ae8e
|
|
| BLAKE2b-256 |
41ec3857e5d85d695adf07ca454a3c7cc3b4c99dee27616bbf19aa34655981f9
|
File details
Details for the file kaiv-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: kaiv-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 459.7 kB
- Tags: CPython 3.10, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5c84edc9ff7c2919b48b056734ea60d33c6d9ebcd4aa1c6f536db3ae5422a76
|
|
| MD5 |
2ee610d339acbb10f48dd16da5dd5cb0
|
|
| BLAKE2b-256 |
089c8697f2e4d16902225c1e8bb7bb5fd9aaa05642055058c88a4827dc3cce48
|