Skip to main content

No project description provided

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


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.1.tar.gz (1.8 kB view details)

Uploaded Source

Built Distribution

parsenv-0.2.1-py3-none-any.whl (2.4 kB view details)

Uploaded Python 3

File details

Details for the file parsenv-0.2.1.tar.gz.

File metadata

  • Download URL: parsenv-0.2.1.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

Hashes for parsenv-0.2.1.tar.gz
Algorithm Hash digest
SHA256 43f8c51328790deb124a5b1b320d16c338b7329e4ef3b85aa8844e168726f5d0
MD5 e67cf746f2096232822e0b9844f5ea15
BLAKE2b-256 c795d6ee6a55c403c5bc6fe473df9f86375025455f637cf66360f2560f7ba10c

See more details on using hashes here.

File details

Details for the file parsenv-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: parsenv-0.2.1-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

Hashes for parsenv-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2c89334bb0e768aaf64fab1d2f236439d296c826f8bd9d886c5fdc00995c2ab3
MD5 3e9ccedc36cdb8e2265df23f85298a0a
BLAKE2b-256 2aee8403e3987a3a92477e868db1c5d905c89c909e6bae07925efbec70435467

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page