.env file handler. required for django, docker, etc
Project description
Install
$ [sudo] pip install env-file
Classes
env_file.EnvFile
- .env file class
Functions
function | __doc__ |
---|---|
env_file.get(variable, default=None) |
return the value for variable if variable is in the file, else default |
env_file.load(path='.env') |
load .env file variables and return a dictionary |
env_file.setup(path='.env') |
load .env file variables and set environment variables |
env_file.update(**kwargs) |
update .env file |
CLI
usage | __doc__ |
---|---|
python -m env_file variable [value] |
get/set .env variable |
usage: env-file variable [value]
Examples
Django example
.env
DJANGO_SETTINGS_MODULE = project.settings
DJANGO_SECRETKEY = somerandomkey
DB_NAME=dbname
DB_PASS=secret
manage.py
import env_file
import sys
if __name__ == "__main__":
# os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
env_file.setup()
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
library example
>>> import env_file
>>> env_file.get('DB_NAME')
'DB_NAME'
>>> env_file.load(['.env','dev.env'])
cli example
$ env-file DB_NAME
dbname
readme-md - README.md generator
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
env-file-2019.1.29.tar.gz
(2.7 kB
view hashes)
Built Distribution
Close
Hashes for env_file-2019.1.29-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00222f2a92c36a75a8375d924ecc799d8bd377f7441fc4bd1772f61f68c585fc |
|
MD5 | fd775d70975bfa5ba6420b216d5735ff |
|
BLAKE2b-256 | 6382d7e23d0b0a9a99d053bb9cd4de5565205e135ce04502b7698fe4c50110ca |