Skip to main content

Robust TOML configuration manager with format preservation

Project description

Robust TOML Config Manager

PyPI version Python versions

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") and set("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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robust_toml_config-1.0.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

robust_toml_config-1.0.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file robust_toml_config-1.0.1.tar.gz.

File metadata

  • Download URL: robust_toml_config-1.0.1.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

Hashes for robust_toml_config-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1b186f6a04af7900ecbc32c2b19316085ab592ef0ddbbc8cbe806fc380acd165
MD5 803680b99637402da9844d2a35e3b5e8
BLAKE2b-256 1c27ff08e3e92c5c1649244dd64dcbbd4f8ed02d66a74a7cdf8a55971efa13cc

See more details on using hashes here.

File details

Details for the file robust_toml_config-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for robust_toml_config-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 872d00c204a512e28c65b49c66961c6b5c6f4957abb4c3ddf6f7d39e59ff903f
MD5 f4007b34b38352bc4dda16edcd9880b6
BLAKE2b-256 b1d857e387620bafae8d020cde2f5f6766b4a25662499ab90408e26886099eda

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page