grigode-env-2 is a library for reading and managing key-value pairs from .env files in your projects.
Project description
grigode-env-2
grigode-env-2 is a library for reading and managing key-value pairs from .env files in your projects.
Installation
pip install grigode-env-2
If you need to use system environment variables and want to add more environment variables without having to configure them manually or modify the system variables, you can choose to add grigode_env to your application to load the configuration from one or more .env files:
from grigodeenv2 import datetime, Env, read_environ
read_environ('.env')
env = Env(
EMAIL_PORT=(int, 45),
ANY_DATETIME=(datetime, None, {"format": '%d/%m/%y %H:%M:%S'})
)
SECRET_KEY = env('SECRET_KEY') # str
DEBUG = env.bool('DEBUG') # bool
SERVER_PORT = env.int('SERVER_PORT') #int
EMAIL_PORT = env('EMAIL_PORT') #int
HOSTS = env.list('HOSTS') # list
ANY_DATETIME = env('ANY_DATETIME') # datetime
The syntax of the .env file
# App Config
SECRET_KEY=mi_clave_secreta
DEBUG=true
# Server Config
SERVER_PORT=3000
HOSTS=["localhost"]
# Configuración de correo electrónico
EMAIL_HOST=smtp.example.com
EMAIL_PORT=587
EMAIL_USER=usuario@example.com
EMAIL_PASSWORD=mi_password_secreto
# Other
ANY_DATETIME=15/03/24 13:55:26
Available data types
STRING = env.str('STRING') # str
BYTES = env.bytes('BYTES') # bytes
BOOLEAN = env.bool('BOOLEAN') # bool
INTEGER = env.int('INTEGER') # int
FLOAT = env.float('FLOAT') # float
JSON = env.json('JSON') # dict
LIST = env.list('LIST') # list
TUPLE = env.tuple('TUPLE') # tuple
DICTIONARY = env.dict('DICTIONARY') # dict
DATETIME = env.datetime('DATETIME') # datetime.datetime
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file grigode_env_2-1.0.tar.gz.
File metadata
- Download URL: grigode_env_2-1.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8231d546ec962d380338b4c9f49a5eaec6bc6fcbad11d51f07e354b49329e42e
|
|
| MD5 |
bb838f32aacd36d1ff6ae44bbab17897
|
|
| BLAKE2b-256 |
9276c7ff665d7b9ad00c98a0ba1d6090999e1665e918df2f5c170654106e2585
|
File details
Details for the file grigode_env_2-1.0-py3-none-any.whl.
File metadata
- Download URL: grigode_env_2-1.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c01a998b234d0f6af98586f1fca2cb3c2300562c46b982c7717cd6ff11a62798
|
|
| MD5 |
c582dd94429b942ff110bfa6b6c247c6
|
|
| BLAKE2b-256 |
0b55a4f600636c360449f7a05494c5d35041436d17054d3d2545a603aad28e6c
|