Typed dotenv parser
Project description
Getting Started
Use pip install parsenv
.
Reads .env
file on import, then reads other env-files from $ENVPATH
(comma separated).
Example
import env
assert env.get("TOKEN") == "abc123"
assert env.get("X", None) is None
assert env.get_int("PORT") == 123
assert env.get_strs("KEYS", []) == ["word1", "F402", "12"]
assert env.get_ints("ADMIN_IDS") == [1, 2, 3]
assert env.get_ints("X", [0]) == [0]
assert env.get_bool("T_BOOL")
assert not env.get_bool("F_BOOL")
try:
env.get("X")
except Exception as e:
assert str(e) == 'Mandatory environment variable "X" is missing'
try:
env.get_ints("BAD_NUMS")
except Exception as e:
assert str(e) == 'Failed to cast "1,2,a" (variable name "BAD_NUMS") to list'
try:
env.get_bool("BAD_BOOL")
except Exception as e:
assert str(e) == 'Failed to cast "ok" (variable name "BAD_BOOL") to bool'
assert env.raw.float("FLOAT") == 1.45
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
parsenv-0.2.2.tar.gz
(1.8 kB
view details)
Built Distribution
File details
Details for the file parsenv-0.2.2.tar.gz
.
File metadata
- Download URL: parsenv-0.2.2.tar.gz
- Upload date:
- Size: 1.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.4.9 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 110f03736d51b64d4f966afce6f812c3b24f7d73ae36b6f2da028cc303cd6295 |
|
MD5 | 4c72d9ff6f5423541221f5d6063d7dd8 |
|
BLAKE2b-256 | ed800f3f5dee6774a129e61f82d1e3643e629f573f03a21cd3247bf870f95674 |
File details
Details for the file parsenv-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: parsenv-0.2.2-py3-none-any.whl
- Upload date:
- Size: 2.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.4.9 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a3c72aded2571e5a5226ff1eff78d33dedc0c393b0aa272f408ab38c5a5febd |
|
MD5 | 3292661551142bc20e7fea760bc20708 |
|
BLAKE2b-256 | 931694511225d2090f042cc7acf7bf542b7104d90e6f8d5aaaf675a586917e0c |