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

As the name says, this package enters the crowded field of environment related packages. The main goal of this package is to provide you with the ability to populate your environment with a a source (by default reading a .env file) and then use a simple function in your configuration files to read these values or use defaults.

It’s worth noting that this software is under active development and interfaces will change without warning.

Usage

Usage is simple. Early in the execution of your project, or in a dedicated module for configuration, import populate_env from the yaep package. Running this will populate your environment with values from your .env file. You can alternatively set the env_file argument or the ENV_FILE environment variable to read from another env file.

from yaev import populate_env populate_env()

Now you can setup your configuration. For example, in a settings.py or config.py:

from yaev import env DATABASE_URL = env(‘DATABASE_URL’, ‘sqlite://:memory:’)

The env function has a few other useful tricks. For example, allowing for a default that is “sticky” - meaning if it is employed it is set in the environment.

os.getenv(‘foo’) # Returns None FOO = env(‘FOO’, ‘bar’, sticky=True) os.getenv(‘FOO’) # Returns ‘bar’

Additionally, you can by default allow for boolean-like values to be changed to booleans on the fly.

os.getenv(‘SOMETHING’) # Returns ‘True’ env(‘SOMETHING’) # Returns True

By default a case-insensitive comparison to ‘True’ and ‘False’ is done, along with 1 and 0. You can change the available values by passing in a new boolean map:

env(‘pony’, boolean_map={True: [‘True’, ‘1’, ‘Pony’]}) # Returns True

On the subject of 1s and 0s - you might consider that if you are intending to get an integer that you will instead end up with ‘True’ or ‘False’ - you can overcome this by setting convert_booleans to False. Additionally, you can cast your return value explicitly by setting the type_class, though note that if convert_booleans is True that will override your type_class. Some examples:

# SOMETHING is set to ‘1’ in the environment env(‘SOMETHING’) # Returns True env(‘SOMETHING’, convert_booleans=False) # Returns ‘1’ env(‘SOMETHING’, convert_booleans=False, type_class=int) # Returns 1

Finally, you can also raise an exception if a value is not set in your environment:

env(‘IMPORTANT’, default=yaep.exceptions.UnsetException) # Raises yaep.exceptions.UnsetException

Using Other Environment Sources

A goal of the project is to be able to override or add to the default of pulling values in from an env file. Supporting alternate sources such as credential servers is the goal.

Work in this area is slated for a future release.

A list of versions and changes to the project:

  • v0.0.6 - Remove setup_requires dependency on pypandoc.
  • v0.0.5 - Fix install error when installing from sdist (missing README)
  • v0.0.4 - Fix issue with pypandoc usage.
  • v0.0.3 - Fixed issue with boolean defaults, allow for type_class and UnsetExceptions.
  • v0.0.2 - Fixed issue with ConfigParser lowercasing keys.
  • v0.0.1 - Initial commit to GitHub.
Release History

Release History

0.0.6

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.0.5

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.0.4

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.0.3

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
yaep-0.0.6-py2-none-any.whl (6.5 kB) Copy SHA256 Checksum SHA256 py2 Wheel Apr 14, 2016
yaep-0.0.6.tar.gz (5.8 kB) Copy SHA256 Checksum SHA256 Source Apr 14, 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