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.0.1.tar.gz (5.7 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.0.1-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for gnvext-2.0.1.tar.gz
Algorithm Hash digest
SHA256 992e161a06ac9c9ccaab823dc6360447d9fa7f984d617328fce04c76b3083fc7
MD5 c8e6f2529e695b2d9c8ffba5e89faf6c
BLAKE2b-256 b54a6d2a3faffad66a4f316062f41920f92aaa72cb3dbbe7a7f0d5309e6fd9b3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gnvext-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.9 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.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 31aff4e13e5b5eee4ce7807a84798c0e59458061fa255c8e81f0154f46a99971
MD5 d57a602b44257876a5e65458878ca6c0
BLAKE2b-256 ba59f17a3a712f99d469dae2b1b7f7a9f89b0c622d61cb592d55bcee158b9de8

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