{"id":16389031,"url":"https://github.com/gilbn/simple-toml-configurator","last_synced_at":"2025-07-24T11:33:49.452Z","repository":{"id":191030545,"uuid":"683720096","full_name":"GilbN/Simple-TOML-Configurator","owner":"GilbN","description":"A Python library for management of configuration settings in TOML format across various applications.","archived":false,"fork":false,"pushed_at":"2024-07-14T16:44:45.000Z","size":1357,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-15T12:03:37.877Z","etag":null,"topics":["config","configuration","configuration-files","configurator","django","django-configuration","fastapi","fastapi-configuration","flask","flask-configuration","python","settings","settings-management","setup","toml"],"latest_commit_sha":null,"homepage":"https://gilbn.github.io/Simple-TOML-Configurator/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GilbN.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-27T13:47:10.000Z","updated_at":"2025-02-07T23:21:56.000Z","dependencies_parsed_at":"2023-08-27T19:42:40.333Z","dependency_job_id":"86241782-6564-40c1-9ced-914b3a95fa52","html_url":"https://github.com/GilbN/Simple-TOML-Configurator","commit_stats":null,"previous_names":["gilbn/simple-toml-configurator"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/GilbN/Simple-TOML-Configurator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GilbN%2FSimple-TOML-Configurator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GilbN%2FSimple-TOML-Configurator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GilbN%2FSimple-TOML-Configurator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GilbN%2FSimple-TOML-Configurator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GilbN","download_url":"https://codeload.github.com/GilbN/Simple-TOML-Configurator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GilbN%2FSimple-TOML-Configurator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265523691,"owners_count":23781857,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["config","configuration","configuration-files","configurator","django","django-configuration","fastapi","fastapi-configuration","flask","flask-configuration","python","settings","settings-management","setup","toml"],"created_at":"2024-10-11T04:30:52.718Z","updated_at":"2025-07-24T11:33:49.410Z","avatar_url":"https://github.com/GilbN.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple TOML Configurator\n\n[![PyPI version](https://badge.fury.io/py/Simple-TOML-Configurator.svg)](https://badge.fury.io/py/Simple-TOML-Configurator)\n![PyPI - License](https://img.shields.io/pypi/l/Simple-TOML-Configurator)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/Simple-TOML-Configurator)\n![PyPI - Wheel](https://img.shields.io/pypi/wheel/Simple-TOML-Configurator)\n![Build](https://github.com/gilbn/Simple-TOML-Configurator/actions/workflows/tests.yml/badge.svg?event=push)\n\nThe **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.\n\n## Documentation\n\nhttps://gilbn.github.io/Simple-TOML-Configurator/\n\n## Features\n\n1. **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.\n\n2. **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.\n\n3. **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.\n\n4. **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.\n\n5. **Environment Variable Support:** Configuration values are automatically set as environment variables, making it easier to use the configuration values in your application. Environment variable are set as uppercase. e.g. `APP_HOST` and `APP_PORT` or `PROJECT_APP_HOST` and `PROJECT_APP_PORT` if `env_prefix` is set to \"project\". This also works for nested values. ex: `TABLE_KEY_LEVEL1_KEY_LEVEL2_KEY`. This works for any level of nesting.**Environment variables set before the configuration is loaded will not be overwritten, but instead will overwrite the existing config value.**\n\n6. **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.\n\n7. **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.\n\n## Installation\n\nInstall with\n```bash\npip install simple-toml-configurator\n```\n\n## Usage Example\n\nSee [Usage](https://gilbn.github.io/Simple-TOML-Configurator/latest/usage-examples/) for more examples.\n\n```python\nimport os\nfrom simple_toml_configurator import Configuration\n\n# Define default configuration values\ndefault_config = {\n    \"app\": {\n        \"ip\": \"0.0.0.0\",\n        \"host\": \"\",\n        \"port\": 5000,\n        \"upload_folder\": \"uploads\",\n    },\n    \"mysql\": {\n        \"user\": \"root\",\n        \"password\": \"root\",\n        \"databases\": {\n            \"prod\": \"db1\",\n            \"dev\": \"db2\",\n            },\n    }\n}\n\n# Set environment variables\nos.environ[\"PROJECT_APP_UPLOAD_FOLDER\"] = \"overridden_uploads\"\n\n# Initialize the Simple TOML Configurator\nsettings = Configuration(config_path=\"config\", defaults=default_config, config_file_name=\"app_config\", env_prefix=\"project\")\n# Creates an `app_config.toml` file in the `config` folder at the current working directory.\n\n# Access and update configuration values\nprint(settings.app.ip)  # Output: '0.0.0.0'\nsettings.app.ip = \"1.2.3.4\"\nsettings.update()\nprint(settings.app_ip)  # Output: '1.2.3.4'\n\n# Access nested configuration values\nprint(settings.mysql.databases.prod)  # Output: 'db1'\nsettings.mysql.databases.prod = 'new_value'\nsettings.update()\nprint(settings.mysql.databases.prod)  # Output: 'new_value'\n\n# Access and update configuration values\nprint(settings.app_ip)  # Output: '1.2.3.4'\nsettings.update_config({\"app_ip\": \"1.1.1.1\"})\nprint(settings.app_ip)  # Output: '1.1.1.1'\n\n# Access all settings as a dictionary\nall_settings = settings.get_settings()\nprint(all_settings)\n# Output: {'app_ip': '1.1.1.1', 'app_host': '', 'app_port': 5000, 'app_upload_folder': 'overridden_uploads', 'mysql_user': 'root', 'mysql_password': 'root', 'mysql_databases': {'prod': 'new_value', 'dev': 'db2'}}\n\n# Modify values directly in the config dictionary\nsettings.config[\"mysql\"][\"databases\"][\"prod\"] = \"db3\"\nsettings.update()\nprint(settings.mysql_databases[\"prod\"])  # Output: 'db3'\n\n# Access environment variables\nprint(os.environ[\"PROJECT_MYSQL_DATABASES_PROD\"])  # Output: 'db3'\nprint(os.environ[\"PROJECT_APP_UPLOAD_FOLDER\"])  # Output: 'overridden_uploads'\n```\n\n**`app_config.toml` contents**\n\n```toml\n[app]\nip = \"1.1.1.1\"\nhost = \"\"\nport = 5000\nupload_folder = \"overridden_uploads\"\n\n[mysql]\nuser = \"root\"\npassword = \"root\"\n\n[mysql.databases]\nprod = \"db3\"\ndev = \"db2\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilbn%2Fsimple-toml-configurator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgilbn%2Fsimple-toml-configurator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilbn%2Fsimple-toml-configurator/lists"}