A wrapper around rtoml providing tomli-compatible behavior with enhanced convenience methods for intuitive value access.
Project description
tomly
tomly is a lightweight wrapper around rtoml, designed to provide tomli/tomllib compatible behavior while offering enhanced convenience methods for intuitive data access.
Key Features
- 🎯 Dot Notation: Access and modify nested dictionary keys as object attributes (e.g.,
config.db.port). - 🌍 Environment Interpolation: Automatically expand
${VAR_NAME:default}patterns within strings during loading. - 🌳 Nested Path Operations: Safely get, set, or delete deep values using dot-separated strings or iterables.
- 🔒 Immutability (Freeze): Protect your configuration from accidental runtime changes.
- 🥞 Flattening: Convert nested structures into a single-level dictionary for environment variables or logging.
- ⚡ High Performance: Built on top of
rtoml(Rust-powered) for rapid parsing and serialization.
Installation
pip install tomly
Quick Start
1. Basic Loading & Attribute Access
import tomly as toml
from tomly import DataDict
toml_data = """
[server]
host = "127.0.0.1"
port = 8080
"""
# Parse and wrap into DataDict
config = DataDict(toml.loads(toml_data))
# Access via dot notation
print(config.server.host) # "127.0.0.1"
config.server.port = 9000 # Set values like an object
2. Environment Variable Interpolation
import os
from tomly import DataDict
os.environ["APP_ENV"] = "production"
# DataDict can resolve ${VAR_NAME} or ${VAR_NAME:default}
data = {"env": "${APP_ENV:dev}", "debug": "${DEBUG:false}"}
config = DataDict(data, interpolate_env=True)
print(config.env) # "production"
print(config.debug) # "false" (using default value)
3. Deep Path Manipulation
from tomly import DataDict
config = DataDict()
# Set values at deep paths (auto-creates intermediate dicts)
config.set_nested("app.services.auth.timeout", 30)
# Safe retrieval without KeyErrors
timeout = config.get_nested("app.services.auth.timeout", default=60)
# Delete a nested structure
config.delete_nested("app.services.auth")
4. Read-only Configuration
from tomly import DataDict
config = DataDict({"api": {"version": "v1"}})
config.freeze()
# This will raise a TypeError
config.api.version = "v2"
Project details
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 tomly-0.1.3.tar.gz.
File metadata
- Download URL: tomly-0.1.3.tar.gz
- Upload date:
- Size: 25.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01845ccf54f3c44c410f7ab4e2e787a749a34b31e887923bdacb588e7dcfe730
|
|
| MD5 |
184a643032c5107d294ffcb1c486ff55
|
|
| BLAKE2b-256 |
8f1a1980f285b820b307f7c18d3d554fe5f76e4fd6db93883c419846d1206bf0
|
Provenance
The following attestation bundles were made for tomly-0.1.3.tar.gz:
Publisher:
python-publish.yml on hom-wang/tomly
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tomly-0.1.3.tar.gz -
Subject digest:
01845ccf54f3c44c410f7ab4e2e787a749a34b31e887923bdacb588e7dcfe730 - Sigstore transparency entry: 779820184
- Sigstore integration time:
-
Permalink:
hom-wang/tomly@d282f55e49a2d99815a4fb7b7ccf4b57784abcce -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/hom-wang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d282f55e49a2d99815a4fb7b7ccf4b57784abcce -
Trigger Event:
release
-
Statement type:
File details
Details for the file tomly-0.1.3-py3-none-any.whl.
File metadata
- Download URL: tomly-0.1.3-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb6a4b79be08e4e7e1b75a61ac83e5d7ddc677fe9e6267467357b0a2738115cf
|
|
| MD5 |
be89f66bf26eacf85bcaafa32b8933c8
|
|
| BLAKE2b-256 |
77f6c583de9b6e6c413c640f29fa98d10f42ae6f9a02fbd190f3ed76de681ddb
|
Provenance
The following attestation bundles were made for tomly-0.1.3-py3-none-any.whl:
Publisher:
python-publish.yml on hom-wang/tomly
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tomly-0.1.3-py3-none-any.whl -
Subject digest:
bb6a4b79be08e4e7e1b75a61ac83e5d7ddc677fe9e6267467357b0a2738115cf - Sigstore transparency entry: 779820186
- Sigstore integration time:
-
Permalink:
hom-wang/tomly@d282f55e49a2d99815a4fb7b7ccf4b57784abcce -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/hom-wang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d282f55e49a2d99815a4fb7b7ccf4b57784abcce -
Trigger Event:
release
-
Statement type: