Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

speckenv-1.3.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

speckenv-1.3.1-py2.py3-none-any.whl (4.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file speckenv-1.3.1.tar.gz.

File metadata

  • Download URL: speckenv-1.3.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.6

File hashes

Hashes for speckenv-1.3.1.tar.gz
Algorithm Hash digest
SHA256 75e4b9ac8e08aff7bbbbc31fa8c8cecb5c447a17836ea7c5414b37ac982e1415
MD5 3906271144089968c7f576e0bfb97b16
BLAKE2b-256 05832d1576ca87a5aef1dca4191bed560363970801abd934d2e1becff0b03368

See more details on using hashes here.

File details

Details for the file speckenv-1.3.1-py2.py3-none-any.whl.

File metadata

  • Download URL: speckenv-1.3.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.6

File hashes

Hashes for speckenv-1.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 caba8e13a4d8529680e261113b2dc82b6fd213be4d441696ee55d7ffae55eaaa
MD5 8988f7f714c320fbeb7373658237670d
BLAKE2b-256 c572f7bbd3d401c1da9ebfb3d130d8469cc32df31bc935f8f423bb80df79c838

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