Creates a class used to query environmental variables with typehinting a conversion to basic Python types.
Project description
EnvProxy
EnvProxy
provides a class used to query environmental variables with typehinting a conversion to basic Python types.
You can query your environment easily and keep your typehinting.
Installation
Using pip
:
pip install env-proxy
Using poetry
:
poetry add env-proxy
Example
# Import EnvProxy
from env_proxy import EnvProxy
# Basic examples
## Environment variable "DATABASE_HOST"
database_host = EnvProxy.get_str("database-host")
## If you want the function to fail if the value does not exist, use methods with `_strict` suffix
database_nonsene = EnvProxy.get_str_strict("database-nonsense")
### ValueError: No value for key DATABASE_NONSENSE in environment
## Specify default for the (non-zero) variable "DATABASE_PORT"
database_port = EnvProxy.get_int("database-port") or 5432
# Specify custom prefix
class MyProxy(EnvProxy):
env_prefix: Optional[str] = "MYAPP"
## Now all variables are expected to be prefixed with MYAPP_
database_host = EnvProxy.get_str("database-host")
### Searches for MYAPP_DATABASE_HOST variable
Documentation
See docs
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
env-proxy-0.1.1.tar.gz
(2.3 kB
view details)
Built Distribution
File details
Details for the file env-proxy-0.1.1.tar.gz
.
File metadata
- Download URL: env-proxy-0.1.1.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.5 CPython/3.8.3 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de8bc8ce0136a84d841f412521ecd3d49f5e5fc522c3a9226dc28818719a336e |
|
MD5 | 5f1a3dae53ff71336373567470edca72 |
|
BLAKE2b-256 | 5ba35e86839d4db9bce5704242d05e1cf47259bf5b0dbec974799fc4bf666307 |
File details
Details for the file env_proxy-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: env_proxy-0.1.1-py3-none-any.whl
- Upload date:
- Size: 2.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.5 CPython/3.8.3 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba029c44c71cd6c81b3375b26edfc65e249b8874ce8b26a353f5cde72e68084e |
|
MD5 | 52ba74a0108ebc9621c223e88f35d8f0 |
|
BLAKE2b-256 | eb5c31ac4eb128609b32e0a826bbd6fd97df941c80b82983a5c1dd6058cb3704 |