Skip to main content

Wrapper for converting environment variables to any python type

Project description

gnvext

Wrapper for converting environment variables to any python type


Installing

Python 3.10+ is required

[!NOTE] It's recommended to activate Virtual Environment before installing gnvext

To clone and install required packages use the following command:

# linux/macOS
$ python3 -m pip install gnvext

# windows
$ py -3 -m pip install gnvext

Quick example

import gnvext

# you can load .env file here

# if "PRINT_HELLO_WORLD" env variable exists,
# then extracts it, otherwise, raises ValueError.
# (raises only if default is a subclass of BaseException (or its instance),
#  in another case, returns default as-is)
PRINT_HELLO_WORLD = gnvext.BooleanEnvVariable(
    name="PRINT_HELLO_WORLD",
    default=ValueError("we don't know if we should greet world or not :("),
).value

if PRINT_HELLO_WORLD:
    print("Hello, world!")

# output for PRINT_HELLO_WORLD=True
# Hello, world!

# output for PRINT_HELLO_WORLD=False
#

# output for PRINT_HELLO_WORLD=None
# ValueError: could not convert "None" to bool

# output for undeclared env var PRINT_HELLO_WORLD
# ValueError: we don't know if we should greet world or not :(

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

gnvext-2.1.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gnvext-2.1.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file gnvext-2.1.1.tar.gz.

File metadata

  • Download URL: gnvext-2.1.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for gnvext-2.1.1.tar.gz
Algorithm Hash digest
SHA256 28a398c0e031753ba63bca0622bf577e9d60831c48fe1975523f7a6be44a9dfb
MD5 3dd16f8e5a3cac14c94338615135662d
BLAKE2b-256 25dfb8bf0c610cb498855699395ecd2fe5bc565492dc1e695e693f7fdad62c7a

See more details on using hashes here.

File details

Details for the file gnvext-2.1.1-py3-none-any.whl.

File metadata

  • Download URL: gnvext-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for gnvext-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 18ea13fd4714aedf60978dea3ed7d9d63e8875b5a22c2ada991ad54ac477521a
MD5 234c8eb97e2bcf9e270c83bbd042affb
BLAKE2b-256 6ee260ccea8e8ddf217652b45a1c6d7acce925f45209195ce2b5a67347fe193b

See more details on using hashes here.

Supported by

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