Giter Site home page Giter Site logo

idlesign / envbox Goto Github PK

View Code? Open in Web Editor NEW
24.0 5.0 0.0 76 KB

Detect environment type and work within.

Home Page: https://github.com/idlesign/envbox

License: BSD 3-Clause "New" or "Revised" License

Python 97.51% Shell 2.49%
python environments environment dotenv django configuration-management envfile config settings configuration app-config environment-configuration 12factorapp

envbox's Introduction

envbox

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/

envbox's People

Contributors

idlesign avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

envbox's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.