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]
with env.prefix("BOOL"):
assert env.get_bool("T")
assert not env.get_bool("F")
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.3.0.tar.gz
(1.9 kB
view details)
Built Distribution
File details
Details for the file parsenv-0.3.0.tar.gz
.
File metadata
- Download URL: parsenv-0.3.0.tar.gz
- Upload date:
- Size: 1.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.5.3 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 396380632f993f2325f3cf593187ef873267bab7afaa7a2b309d218e692c7bf1 |
|
MD5 | 13e78d5c8459d4d66227543c9a2d7cce |
|
BLAKE2b-256 | 6101c10010e0f2b0f74169673cc57595142d72409d33ffadd96700ac9a9c0a95 |
File details
Details for the file parsenv-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: parsenv-0.3.0-py3-none-any.whl
- Upload date:
- Size: 2.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.5.3 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4d6d2941c41474a83171cb9e4a7611cb022b7159eb7c2d011176050bb058728 |
|
MD5 | a30e406c7c8770908b27d811c356afcd |
|
BLAKE2b-256 | 1780f9a42a3a994a488328b61cb45b67b606c685de2d5c6a171877d5dee65c67 |