Skip to main content

Detect environment type and work within.

Project description

https://github.com/idlesign/envbox

release lic coverage

Description

Detect environment type and work within.

Features

  • Environment type detection (extendable system);

  • Support for .env files;

  • Convenient os.environ proxying (with optional values casting into Python natives);

  • Automatic submodule-for-environment import tool;

  • Cosy per-thread settings container with environment var support;

  • CLI for environment probing.

Code sample

from envbox import get_environment

# Detect current environment type
# and get its object.
#
# Default detection sources:
# 1. ``PYTHON_ENV`` env variable
# 2. ``environment`` file contents
#
# By default this function will also try to read env variables from .env files.
env = get_environment()

env.name
# >> development

env.is_production
# >> False

env.get('HOME')
# The same as env['HOME'] and env.HOME
# >> /home/idle/

env.getmany('PYTHON')
# {'UNBUFFERED': '1', 'IOENCODING': 'UTF-8', 'PATH': ...}

Now you may want to put your environment vars into .env files (e.g.: .env, .env.development .env.production) to be read by envbox:

MY_VAR_1 = value1
HOME = /home/other/

# comments are ignored, just as lines without definitions

# mathing quotes (" and ') are stripped
MY_QUOTED = "some quoted "

# ${VARNAME} will be replaced by value from env (if available)
MY_VAR_2 = ${MY_QUOTED}

# multiline with dangling quotes
MULTI_1 = "
line1
line2
"

# multiline classic
MULTI_2 = "line1
line2
line3"

# multiline as one line
MULTI_3 = "one\ntwo"

Read the docs for more examples.

CLI

$ envbox probe
# >> Detected environment type: development (Development)

$ envbox show
# >> [...]
# >> SHELL = /bin/bash
# >> [...]

Note: envbox CLI requires click package available.

Documentation

http://envbox.readthedocs.org/

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

envbox-1.3.0.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

envbox-1.3.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file envbox-1.3.0.tar.gz.

File metadata

  • Download URL: envbox-1.3.0.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.8

File hashes

Hashes for envbox-1.3.0.tar.gz
Algorithm Hash digest
SHA256 0b0f3bde0039dfed19b09f1064621bdf8be90bc22e9d617c67bedebf38185e34
MD5 b387e355e519434edc31e86ea1eac9e2
BLAKE2b-256 948a907100708b896882e69baf6634010aafd7006ed235a184eccc1a39bbfed0

See more details on using hashes here.

File details

Details for the file envbox-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: envbox-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.8

File hashes

Hashes for envbox-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6964a23bbdcf2c66bc43d9a6576d0ad242da298badac07f5ec351efd7056ae58
MD5 2507e536bd14fc485786a7dee6731f68
BLAKE2b-256 ed9cb3084e2d78fc5ff2f5453ab73f231e5583751482415f2e67545ef8c85eef

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