Skip to main content

A tool to easily get typed values out of strings stored in environment variables.

Project description

LiEnv: A simple yet useful library

CI PyPi Latest Release

LiEnv is a tool to easily get typed values out of strings stored in environment variables.

  • Simplifies the sometimes tedious task of parsing strings to typed variables
  • Provides a way to do it uniformly througout the project
  • Aims to prevent unwanted behaviour caused by typos, errors or malicious content in environment variables

Currently supported Python types:

  • Integers and Floats
  • Dicts
  • Lists
  • Tuples
  • Booleans

Example

>>> import lienv
>>> integer = lienv.get(int, "SOME_INTEGER") # SOME_INTEGER="42"
>>> decimal = lienv.get(float, "SOME_FLOAT") # SOME_FLOAT="2.4"
>>> dictionary = lienv.get(dict, "SOME_DICT") # SOME_DICT="{'lienv': 42}"

>>> print(f"{integer} => {type(integer)}")
42 => <class 'int'>

>>> print(f"{decimal} => {type(decimal)}")
2.4 => <class 'float'>

>>> print(f"{dictionary} => {type(dictionary)}")
{'lienv': 42} => <class 'dict'>

Setup

Install the latest version with:

pip install lienv

TODO

  • Parse types without directly using python's eval
  • Implement unit tests in Rust
  • Figure out how to test the Python module
  • Change default integers and floats to 32 bit based on architecture
  • Add wrappers for unsigned integer parsing
  • Add wrappers for 8 and 16 bit numbers

Contributing

I'll gladly accept feedback and contributions.

Although this project's purpose was to solve problems that at first seemed too simple, the practicality it provided to me was motivation enough to turn it into a library so maybe more people could benefit from it.

I am yet to be proficient in Rust, so pardon my silly mistakes.

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

lienv-0.5.0.tar.gz (9.0 kB view hashes)

Uploaded Source

Built Distributions

lienv-0.5.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

lienv-0.5.0-pp310-pypy310_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

lienv-0.5.0-pp310-pypy310_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

lienv-0.5.0-pp310-pypy310_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

lienv-0.5.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

lienv-0.5.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl (1.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ i686

lienv-0.5.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

lienv-0.5.0-pp39-pypy39_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

lienv-0.5.0-pp39-pypy39_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

lienv-0.5.0-pp39-pypy39_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

lienv-0.5.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

lienv-0.5.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl (1.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ i686

lienv-0.5.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

lienv-0.5.0-pp38-pypy38_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

lienv-0.5.0-pp38-pypy38_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

lienv-0.5.0-pp38-pypy38_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

lienv-0.5.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

lienv-0.5.0-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.whl (1.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ i686

lienv-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

lienv-0.5.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.3 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ s390x

lienv-0.5.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.3 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ppc64le

lienv-0.5.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.2 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARMv7l

lienv-0.5.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

lienv-0.5.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl (1.2 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.5+ i686

lienv-0.5.0-cp311-none-win_amd64.whl (148.8 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

lienv-0.5.0-cp311-none-win32.whl (144.3 kB view hashes)

Uploaded CPython 3.11 Windows x86

lienv-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

lienv-0.5.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.4 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ s390x

lienv-0.5.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.3 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ppc64le

lienv-0.5.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.2 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARMv7l

lienv-0.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

lienv-0.5.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl (1.2 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.5+ i686

lienv-0.5.0-cp311-cp311-macosx_11_0_arm64.whl (282.7 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

lienv-0.5.0-cp311-cp311-macosx_10_7_x86_64.whl (287.1 kB view hashes)

Uploaded CPython 3.11 macOS 10.7+ x86-64

lienv-0.5.0-cp310-none-win_amd64.whl (148.8 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

lienv-0.5.0-cp310-none-win32.whl (144.3 kB view hashes)

Uploaded CPython 3.10 Windows x86

lienv-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

lienv-0.5.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.4 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ s390x

lienv-0.5.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.3 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ppc64le

lienv-0.5.0-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.2 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARMv7l

lienv-0.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

lienv-0.5.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl (1.2 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.5+ i686

lienv-0.5.0-cp310-cp310-macosx_11_0_arm64.whl (282.7 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

lienv-0.5.0-cp310-cp310-macosx_10_7_x86_64.whl (287.1 kB view hashes)

Uploaded CPython 3.10 macOS 10.7+ x86-64

lienv-0.5.0-cp39-none-win_amd64.whl (148.8 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

lienv-0.5.0-cp39-none-win32.whl (144.2 kB view hashes)

Uploaded CPython 3.9 Windows x86

lienv-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

lienv-0.5.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.4 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ s390x

lienv-0.5.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.3 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ppc64le

lienv-0.5.0-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARMv7l

lienv-0.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

lienv-0.5.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl (1.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.5+ i686

lienv-0.5.0-cp39-cp39-macosx_11_0_arm64.whl (282.7 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

lienv-0.5.0-cp39-cp39-macosx_10_7_x86_64.whl (287.1 kB view hashes)

Uploaded CPython 3.9 macOS 10.7+ x86-64

lienv-0.5.0-cp38-none-win_amd64.whl (148.5 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

lienv-0.5.0-cp38-none-win32.whl (144.5 kB view hashes)

Uploaded CPython 3.8 Windows x86

lienv-0.5.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

lienv-0.5.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.4 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ s390x

lienv-0.5.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.3 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ppc64le

lienv-0.5.0-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.2 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARMv7l

lienv-0.5.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

lienv-0.5.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl (1.2 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.5+ i686

lienv-0.5.0-cp38-cp38-macosx_11_0_arm64.whl (282.8 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

lienv-0.5.0-cp38-cp38-macosx_10_7_x86_64.whl (287.3 kB view hashes)

Uploaded CPython 3.8 macOS 10.7+ x86-64

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