enviparse help you manage your application properties using environment variabl
Project description
Enviparse
Description
Enviparse let you simply create dataclasses from environment variable.
Supported types are :
- int
- float
- str
- bool
- optional
- list
- enum (with int or string values only)
@attr
annotated class@dataclasses.dataclass
annotated class
Example
With following environment variables :
DATABASE_CONFIG_USERNAME=postgres
DATABASE_CONFIG_PASSWORD=password
DATABASE_CONFIG_HOST=127.0.0.1
DATABASE_CONFIG_PORT=5432
DATABASE_CONFIG_DATABASE_NAME=appdb
You can parse environment variable with :
import dataclasses
from enviparse import Enviparse
@dataclasses.dataclass
class DatabaseConfig:
username: str
password: str
host: str
port: int
database_name: str
db_config = Enviparse().parse("DATABASE_CONFIG", DatabaseConfig)
print(db_config)
You should get the following result :
DatabaseConfig(username='postgres', password='password', host='127.0.0.1', port=5432, database_name='appdb')
For more example see the test folder.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
enviparse-2.0.1.tar.gz
(14.6 kB
view details)
Built Distribution
File details
Details for the file enviparse-2.0.1.tar.gz
.
File metadata
- Download URL: enviparse-2.0.1.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dde9ad3411022605215e999ca2bf1282ce366f67287e54234a35562f28cdd0e2 |
|
MD5 | 12f32250fcabe83e4d9b213647313ce2 |
|
BLAKE2b-256 | c0c1d4ce843eb3d2d639ea7176163419e92f467599416672896f85584de76eed |
File details
Details for the file enviparse-2.0.1-py3-none-any.whl
.
File metadata
- Download URL: enviparse-2.0.1-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60343608ff18f87f378aa8e5a9faa1f0d808b9624fe281898489d80f8da08b02 |
|
MD5 | 8c4bcc9c38226aaca6e846113309764b |
|
BLAKE2b-256 | f217dd61de2837fc027c5fe2464abc4c1924d58a83e780ca0fe31e06599e7dd7 |