Robust TOML configuration manager with format preservation
Project description
Robust TOML Config Manager
A robust, feature-rich TOML configuration manager for Python that preserves formatting, comments, and ordering in your TOML files.
Features
- ✅ Format Preservation: Maintains comments, whitespace, and ordering
- 🛡️ Robust Handling: Automatic encoding fallback and error recovery
- ⚙️ Dot-Path Access: Simple
get("section.key")andset("section.key", value)syntax - 💾 Auto-Save: Changes automatically saved to disk (configurable)
- 🔄 Batch Updates: Context manager for efficient batch operations
- 🧪 Type Safety: Ensure values are of the correct type
- 📦 Lightweight: Single dependency (tomlkit)
Installation
pip install robust-toml-config
Quick Start
from robust_toml_config import TOMLConfig
# Create or load config
config = TOMLConfig(
"config.toml",
default_data={
"app": {
"name": "My App",
"version": "1.0.0"
}
}
)
# Get values
app_name = config.get("app.name") # "My App"
# Set values
config.set("app.version", "1.0.1")
# Update entire section
config.update_section("database", {
"host": "db.example.com",
"port": 5432
})
# Batch updates
with config.batch_update():
config.set("logging.level", "DEBUG")
config.set("logging.file", "app.log")
config.set("server.port", 8080)
# Ensure type safety
timeout = config.ensure_type("server.timeout", float, 30.0)
# Save to a new file
config.save("config_backup.toml")
Documentation
Full documentation available at GitHub Wiki
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
License
MIT License - see LICENSE for details.
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 robust_toml_config-1.0.0.tar.gz.
File metadata
- Download URL: robust_toml_config-1.0.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1606def847a54f3e113a21f2b891f14f9af857228de9d3e3208689248f08b428
|
|
| MD5 |
fa2b9b91cc16e5963123cb5c85dacbe7
|
|
| BLAKE2b-256 |
1d451269ce195d0fa30ad8d69b0b64c0d5ed02d7c3815fb1de66e27c8bb876a9
|
File details
Details for the file robust_toml_config-1.0.0-py3-none-any.whl.
File metadata
- Download URL: robust_toml_config-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
165d4b5aa03afbdf99e4d34802ac6934d396a8f78d9c4d93c132c51538babe9a
|
|
| MD5 |
c28e7ec1636180cc83f88bde01ccf997
|
|
| BLAKE2b-256 |
a9d0804d62c2437a9f99adb613384995cc4fbc28e9be6e87666bac842df552c6
|