Friendlier way to write your config.
Project description
What is iubeo?
Friendlier way to write your config.
What is it good for?
You write how you want to read your config.
from iubeo import config
def list_from_string(val):
return val.split(',')
CONFIG = config(
{
'DATABASE': {
'USER': str,
'PASSWORD': str,
'HOST': str,
'PORT': str,
},
'ALLOWED_HOSTS': list_from_string,
},
# prefix = '', # default
# sep = '__', # default
)
with the above config, environment variables like
DATABASE__USER=example
DATABASE__PASSWORD=example-password
DATABASE__HOST=localhost
DATABASE__PORT=5432
ALLOWED_HOSTS=example.com,api.example.com,www.example.com
are read from the environment.
CONFIG.DATABASE.USER # "example-user"
CONFIG.DATABASE.PASSWORD # "example-password"
CONFIG.DATABASE.HOST # "localhost"
CONFIG.DATABASE.PORT # "5432"
CONFIG.ALLOWED_HOSTS # ["example.com", "api.example.com", "www.example.com"]
You can also change the separator and add a prefix to manage your environment variables better
CONFIG = config({
'SECRETS': {
'API_KEY': str,
},
}, prefix='APP1', sep='-')
which would be read from
APP1-SECRETS-API_KEY=isik_kaplan_api_key
Iubeo also comes with a couple of pre-configured functions to read common environment variable types:
from iubeo import config, comma_separated_list, boolean
CONFIG = config({
'DATABASE': {
'USER': str,
'PASSWORD': str,
'HOST': str,
'PORT': str,
},
'ALLOWED_HOSTS': comma_separated_list,
'DEBUG': boolean,
})
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
iubeo-0.3.0.tar.gz
(4.2 kB
view details)
Built Distribution
iubeo-0.3.0-py3-none-any.whl
(5.1 kB
view details)
File details
Details for the file iubeo-0.3.0.tar.gz
.
File metadata
- Download URL: iubeo-0.3.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | be2f4bf000ae15ab61b62be6f9c04bc93d1a38e593118a97b37dd6dcceaee500 |
|
MD5 | 10d877161f418448454f14d68212f535 |
|
BLAKE2b-256 | c39e10cd123b1cced98435d5a7023a0adec16b049f299a16792ac121fccb2a62 |
File details
Details for the file iubeo-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: iubeo-0.3.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7bc600a9128cef472fcace0415e43315fe2090ca0fcfb6c7028b34202de4311 |
|
MD5 | a152046365db84a34b6c36d0dd366df1 |
|
BLAKE2b-256 | 3a32968ea7b4b51d34ea384fd16aa8f781988d323ad6e28464b95d23379a011f |