SHCL - Simple Hierarchical Config Language. Parser, accessor, writer, and formatter.
Project description
shcl
Simple Hierarchical Config Language. Forgiving to write, predictable to read.
Values are stored as plain text and coerced only when your code asks for a type, so a config file can never silently decide that NO means false. A bad line is skipped or repaired with a diagnostic instead of taking down the whole file.
Pure standard library, no dependencies, one module. Held byte-for-byte against the Rust reference by a shared conformance corpus.
Install
pip install shcl
Use
from shcl import Document, Status
with open("server.shcl", encoding="utf-8") as f:
doc = Document.parse(f.read())
# One call, a typed value, a visible fallback at the call site.
limit = doc.get_int("site[example.com].max-upload-mb", default=10)
# Or ask why a read failed: Good, Empty, NotFound, BadType, Multiple.
r = doc.read_int("site[example.com].max-upload-mb")
if r.status is not Status.Good:
print(r.status, r.raw)
# Wildcards read across instances, with a status per slot.
roots = doc.read_string_array("site[*].root")
Document.parse never raises. When you want a hard error instead, use Document.parse_with(text, Strictness.Strict), which raises LoadError. A get_* call with no default= raises StatusError rather than inventing a value.
Also here: merge for layered config (defaults, site, user), validate against a schema that is itself a SHCL file, a full writer, and a canonical formatter that preserves comments.
Python 3.9 or newer.
Compatibility
Bindings are versioned in lockstep, so 1.x is the same behavior in every language. shcl~=1.0 picks up minor and patch releases on its own and never crosses a major version.
The CLI
This package is the library only. The shcl command ships as a prebuilt binary and as .deb/.rpm/Windows packages - see https://github.com/jim-collier/shcl.
Docs
Language spec, formal grammar, and the other bindings: https://github.com/jim-collier/shcl
License
MIT. SHCL™ is a trademark of Jim Collier - see the trademark policy.
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 shcl-1.0.0.tar.gz.
File metadata
- Download URL: shcl-1.0.0.tar.gz
- Upload date:
- Size: 30.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c5167b5b095031834a94b2004da62fd0d034ff89f7adf986e001ae3489c563e
|
|
| MD5 |
f6c15d288fa85015441d960d1e1151ae
|
|
| BLAKE2b-256 |
bbad84feeb10c21b1e510ef7fc4877f0f63ccd6be4d7bb998ea95d23e0c1d4c1
|
File details
Details for the file shcl-1.0.0-py3-none-any.whl.
File metadata
- Download URL: shcl-1.0.0-py3-none-any.whl
- Upload date:
- Size: 30.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
574625cc13380354a3cc86a79dff6f6c7402d669a51ceb5829d97a82a06774c1
|
|
| MD5 |
493bb69be2e681b12a76fa11fcc793e0
|
|
| BLAKE2b-256 |
d29e09c9a4e699e1c504dce1769ef15c869fe61ad046d83cc6a3c633aae4c8c8
|