Skip to main content

A simple TOML configurator for Python

Project description

Simple TOML Configurator

The Simple TOML Configurator is a versatile Python library designed to streamline the handling and organization of configuration settings across various types of applications. This library facilitates the management of configuration values through a user-friendly interface and stores these settings in TOML file format for easy readability and accessibility.

Features

  1. Effortless Configuration Management: The heart of the library is the Configuration class, which simplifies the management of configuration settings. It provides intuitive methods to load, update, and store configurations, ensuring a smooth experience for developers.

  2. Universal Applicability: The Simple TOML Configurator is designed to work seamlessly with any type of Python application, ranging from web frameworks like Flask, Django, and FastAPI to standalone scripts and command-line utilities.

  3. TOML File Storage: Configuration settings are stored in TOML files, a popular human-readable format. This enables developers to review, modify, and track configuration changes easily.

  4. Attribute-Based Access: Accessing configuration values is straightforward, thanks to the attribute-based approach. Settings can be accessed and updated as attributes, making it convenient for both reading and modifying values.

  5. Updating Configurations: The library enables the updating of configuration settings from a dictionary, ensuring that the changes are accurately reflected both in-memory and in the stored TOML file.

  6. Default Values: Developers can define default values for various configuration sections and keys. The library automatically incorporates new values and manages the removal of outdated ones.

  7. Customization Capabilities: The Configuration class can be extended and customized to cater to application-specific requirements. Developers can implement custom logic with getters and setters to handle unique settings or scenarios.

Usage Example

from simple_toml_configurator import Configuration

# Define default configuration values
default_config = {
    "app": {
        "ip": "0.0.0.0",
        "host": "",
        "port": 5000,
        "upload_folder": "uploads"
    }
    "mysql": {
        "user": "root",
        "password": "root"
        "databases": {
            "prod": "db1",
            "dev": "db2"
            }
    }
}

# Initialize the Simple TOML Configurator
settings = Configuration()
settings.init_config("config", default_config, "app_config")
# Stores an app_config.toml file in the `config` folder at the current working directory.

# Access and update configuration values
print(settings.app_ip)  # Output: '0.0.0.0'
settings.update_config({"app_ip": "1.2.3.4"})
print(settings.app_ip)  # Output: '1.2.3.4'

# Access all settings as a dictionary
all_settings = settings.get_settings()
print(all_settings)
# Output: {'app_ip': '1.2.3.4', 'app_host': '', 'app_port': 5000, 'app_upload_folder': 'uploads'}

# Modify values directly in the config dictionary
settings.config["mysql"]["databases"]["prod"] = "db3"
settings.update()
print(settings.mysql_databases["prod"])  # Output: 'db3'

The Simple TOML Configurator empowers developers to efficiently manage configuration settings across a wide range of Python applications. Whether you're building a web application, a command-line tool, or a standalone script, this library provides the tools you need to maintain and access configuration values with ease and clarity.

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

Simple-TOML-Configurator-1.0.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

Simple_TOML_Configurator-1.0.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file Simple-TOML-Configurator-1.0.0.tar.gz.

File metadata

File hashes

Hashes for Simple-TOML-Configurator-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a4839bc72c2ec9b4f2868a35c378ddada8a77a345405854d1c21df3542bbe35e
MD5 c8a65de99338e4bb188f1782388d8f81
BLAKE2b-256 8bb9be7b14922af11cd8ec8e6261b2ad9264d74518a9e4754b9600a2f2f9fbc3

See more details on using hashes here.

File details

Details for the file Simple_TOML_Configurator-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for Simple_TOML_Configurator-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c1cd598094c35ddee6c3e85600e77599ec643f46f256be6ede480a5a31ba9104
MD5 c13a6bc8d3b9e6888c3c1db9284abc24
BLAKE2b-256 ce94156318835db373bf54dd6e969db597f7d0f8513088cb459f34f592c737ef

See more details on using hashes here.

Supported by

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