This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

A module for reading values from OS environment variables.

Compared to using os.getenv(), this module provides convenience functions, for parsing basic datatypes. It also allows specifying optional default values if the environment variable does not exist. Basic environment variable parsing and sanitizing is also performed.

Usage

import os
import envitro

# fails when environment variables are missing
bool_required = envitro.bool("BOOL_ENV")
int_required = envitro.int("INTEGER_ENV")
float_required = envitro.float("FLOAT_ENV")
str_required = envitro.str("STRING_ENV")

# basic sanitizing
os.environ["STR_ENV"] = "  var with spaces  "
envitro.str("STR_ENV") # returns "var with spaces"

# falls back to defaults
bool_default = envitro.bool("BOOL_NOT_FOUND", False)
int_default = envitro.int("INTEGER_NOT_FOUND", 42)
float_default = envitro.float("FLOAT_NOT_FOUND", 42.44)
str_default = envitro.str("STRING_NOT_FOUND", "my_default")

# get and set raw environment variables
envitro.set("EXISTING_VAR", None) # clear the environment variable
envitro.set("RAW_STRING", " raw_string ")
envitro.get("RAW_STRING") # returns " raw_string "
envitro.get("MISSING_RAW_STRING", " defaultval ") # returns " defaultval "

# lists
os.environ["LIST_ENV"] = "item1,item2,item3"
list_required = envitro.list("LIST_ENV") # returns ["item1", "item2", "item3"]
os.environ["LIST_ENV2"] = "item1;item2;item3"
list_required2 = envitro.list("LIST_ENV2", separator=";") # returns ["item1", "item2", "item3"]

# utility functions
envitro.isset("MAYBE_SET_VARIABLE") # return True/False

Decorators

There are also decorators available to selectively enable or disable functions based on environment variables.

import envitro

@envitro.decorators.isset('ALLOW_FOO')
def foo():
    return "Hello World"

envitro.set('ALLOW_FOO', '1')
foo() # allowed

envitro.set('ALLOW_FOO', None)
foo() # return "None" and is not executed

@envitro.decorators.bool('ALLOW_REMOTE')
def get_remote(arg1, arg2):
    return call_remote_service(arg1, arg2)

envitro.set('ALLOW_REMOTE', 'True')
get_remote('hello', 'world') # calls remote service

envitro.set('ALLOW_REMOTE', 'False')
get_remote('hello', 'world') # returns "None" and is not executed
Release History

Release History

0.4.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
envitro-0.4.2-py2.py3-none-any.whl (7.7 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Jul 25, 2016
envitro-0.4.2.tar.gz (4.9 kB) Copy SHA256 Checksum SHA256 Source Jul 25, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting