No project description provided
Project description
speckenv because a speck is a synonym for a dot and because Speck is awesome.
Usage
Read the settings contained in ./.env into os.environ (or a different mapping; pass a dict-like object as mapping):
from speckenv import read_speckenv read_speckenv()
Note that read_speckenv uses os.environ.setdefault to set new values, which means that if a particular key exists more than once in the file the first value is retained, not the last.
If the file is named differently or resides in a different path, pass the full path as first argument to read_speckenv.
Read individual values:
from speckenv import env SETTING1 = env('SETTING1') SETTING2 = env('SETTING2', default='bla') SETTING3 = env('SETTING3 ', required=True) # Fail hard if missing. # Different mapping: env('SOMETHING', mapping=...)
The following values are evaluated as Python literals:
BOOL=True # And False, None etc. NUMBER=42 SWEET_HOME=['localhost', '127.0.0.1']
Additional whitespace around the equals sign is supported. Empty lines and lines starting with a # are ignored.
NOTE! You should treat everything except for the first argument to both env and read_speckenv as keyword-only. Since speckenv still supports Python 2 this isn’t enforced by the code right now.
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
Hashes for speckenv-1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85ab779df3f3a75689e2675dfd2a6507848dc48c72f7a6b370d36c083e60ac24 |
|
MD5 | 67b0f5e3ee5000e2b5634bf7c00736a0 |
|
BLAKE2b-256 | 6bdcd5a04ca4cca30c2f383d2f505720abea0b34d316fe00f8e2cfca2e68fc1b |