Skip to main content

A Python package to easily work with environment variables, inspired by the method used in Laravel framework to read the .env file.

Project description

EnvEase

Persian Immortal Studios presents, A Python package to easily work with environment variables, inspired by the method used in Laravel framework to read the .env file.

Installation

You can install envease via pip:

pip install envease

Usage

if you only want to use a single .env file where the python file is located then you can import the package like this:

from envease import env

then the usage is gonna be simple:

# inside the .env file
KEY="Hello, World"
print(env('KEY')) # prints the "Hello, World" message

else if you want to use other environment variable files than .env you can use the package like this:

from envease import *

load_env_file('file_name')
print('KEY') # this prints the value inside the 'KEY' inside the 'file_name' file

you can even dynamically call different environment variable files

from envease import *
env_files = {
    "first": ".first.env",
    "second": ".second.env",
    "third": ".third.env",
}

load_multiple(env_files)

print(dynamic_env('first', 'KEY')) # this will print the value addressed with 'KEY' inside the .first.env file

Notice: you can as well handle default values if the returned value is null!

print('KEY', 'default value') # this prints the value addressed with 'KEY' inside the environment variables. if it was null it will print 'default value' as a string
print(dynamic_env('first', 'KEY'), 'default value') # this prints the value addressed with 'KEY' inside the environment variables addressed with 'first' key in the dictionary. if it was null it will print 'default value' as a string

Contributing

Contributions are welcome! If you have any suggestions, feature requests, or bug reports, please open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

envease-1.0.4.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

envease-1.0.4-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file envease-1.0.4.tar.gz.

File metadata

  • Download URL: envease-1.0.4.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for envease-1.0.4.tar.gz
Algorithm Hash digest
SHA256 64393f584d51b499c249a2e6dd572b916690d8a301c5ddb78e921fef1d99e957
MD5 7b8dbcc58aa42815389583e7138d9e06
BLAKE2b-256 e7bc380332f3df2ce35d13a1fb629e991cc7acfc6414853c770178d71f8616ed

See more details on using hashes here.

File details

Details for the file envease-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: envease-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for envease-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 cc942efa2d62a11b7cd108583ef85527020359e16742e5b6489dd474d789f0e9
MD5 67d1cf0087ffb41e09cf6d3f5f6d80df
BLAKE2b-256 71a9ec4347e07437d6676d8d2c0799d9f0a8f93e3f4a435b102d9bf0b5d90971

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