Releases: GilbN/Simple-TOML-Configurator
1.3.0
What's Changed
[1.3.0] - 2024-07-14
Added
Added new method get_envs
that returns all the environment variables set in a dict.
>>> defaults = {...}
>>> settings = Configuration()
>>> settings.init_config("config", defaults, "app_config"))
>>> settings.get_envs()
{'PREFIX_APP_IP': '0.0.0.0'}
Fixed
Fixed docstring indentation.
Full Changelog: 1.2.2...1.3.0
1.2.2
[1.2.2] - 2024-03-10
New Release v.1.2.2
Fixes
Fixes TypeError: unsupported operand type(s) for |: 'type' and 'type'.
error when using Python version < 3.10
Full Changelog: 1.2.1...1.2.2
1.2.1
1.2.1 - 2024-02-04
New Release: v1.2.1 - Set environment variables from configuration.
What's New
Environment variable are now automatically set from the configuration. This makes it easier to use the configuration values in your application.
Env variables of all config keys are set as uppercase. e.g. APP_HOST
and APP_PORT
or APP_CONFIG_APP_HOST
and APP_CONFIG_APP_PORT
if env_prefix
is set to "app_config".
It will also try and convert the values to the correct type. e.g. APP_PORT
will be set as an integer if the env value is 8080
Nested values can also be accessed. ex: TABLE_KEY_LEVEL1_KEY_LEVEL2_KEY
. This works for any level of nesting.
Any existing env variables that matches will not be overwritten, but instead will overwrite the existing config value.
import os
from simple_toml_configurator import Configuration
os.environ["PROJECT_APP_PORT"] = "1111"
default = {"app": {"host": "localhost", "port": 8080}}
config = Configuration(
config_path="config_folder",
defaults=default,
config_file_name="app_settings",
env_prefix="project")
print(os.environ["PROJECT_APP_HOST"]) # Output: 'localhost'
print(os.environ["PROJECT_APP_PORT"]) # Output: '1111'
Fixes
- Fixed a bug where update_config() would not update the attributes of the Configuration object.
1.1.0
1.1.0 - 2024-01-28
New Release: v1.1.0 - True Nested Configuration Attribute Access
This release introduces a significant new feature: Nested Configuration Attribute Access.
What's New
Nested Configuration Attribute Access: In previous versions, accessing and updating nested configuration values required dictionary-style access. With this release, we've made it easier and more intuitive to work with nested configuration values. Now, you can access and update these values using attribute-style access, similar to how you would interact with properties of an object in JavaScript.
Here's an 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": {
"databases": {
"prod": "db1",
"dev": "db2"
}
}
}
# Initialize the Simple TOML Configurator
settings = Configuration()
settings.init_config("config", default_config, "app_config")
# Access nested configuration values
print(settings.mysql.databases.prod) # Output: 'db1'
settings.mysql.databases.prod = 'new_value'
settings.update()
print(settings.mysql.databases.prod) # Output: 'new_value'
See Usage examples for more information.
Full Changelog: 1.0.1...1.1.0
1.0.1
Just bumping for docs
Full Changelog: 1.0.0...1.0.1
1.0.0
Initial release
Full Changelog: https://github.com/GilbN/Simple-TOML-Configurator/commits/1.0.0