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.2.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.2-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: robust_toml_config-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 634ce9dd85d3235963893860f2ee8d68ceac6e56893e245b0317301ee5e026c5
MD5 2cec4a70fdffbcb1efbc93a7196360ac
BLAKE2b-256 48706fe56585b8e9378bd536843e9844969e95db4ec8774cd061c4465ae1fe6a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for robust_toml_config-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 70f1cbe0782f931bae279b4cea2f52ccdd3bbabed74ff2e48fa70c13d79a117c
MD5 5b8f7779238587547a4791589d74a786
BLAKE2b-256 924a1ddfb2c5cf1877af210194fc0511c541a79113dffc392c0151cef6f8b3f1

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