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. SETTING4 = env('SETTING4', coerce=bool) # Coercion is also applied # to default values # 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
File details
Details for the file speckenv-1.2.tar.gz
.
File metadata
- Download URL: speckenv-1.2.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c772daf1b8349db2dada91b980a910c22c171d53e1c1382b380e1fe7ac11b94 |
|
MD5 | 38259d0ce50c8e839cf5959500586257 |
|
BLAKE2b-256 | 851e53a1f41fa7446a65afc246b60a0c0869082e8b941edb250104f30ba253ee |
File details
Details for the file speckenv-1.2-py2.py3-none-any.whl
.
File metadata
- Download URL: speckenv-1.2-py2.py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a08b6ce581c6aa3b0701a19e1e4db4a4e9dac48ac8d54cebb7d1658bd2ee5271 |
|
MD5 | d15db5d3f982282a46933347fcb5ecca |
|
BLAKE2b-256 | c8801ae32f7e7899df60b1b15ea7ecddd89a08e9fd2a8e8aa165740ba73d48c6 |