envconfig2 is a simple library to make it easier to read config settings from
the environment. It is modeled loosely after Kelsey Hightower's
[
envconfig](
https://github.com/kelseyhightower/envconfig) for Go.
>>> os.environ['DB_HOST'] = 'localhost'
>>> os.environ['DB_PORT'] = '5432'
>>> envconfig2.string('DB_HOST')
>>> envconfig2.integer('DB_PORT')
>>> os.environ['DEBUG'] = 'true'
>>> envconfig2.boolean('DEBUG')
>>> os.environ['USERS'] = 'user1,user2,user3'
>>> envconfig2.list('USERS')
['user1', 'user2', 'user3']
>>> os.environ['JSON'] = '{"debug": true}'
>>> envconfig2.json('JSON')
>>> envconfig2.string('API_KEY', required=True)
ValueError: required environmnet variable API_KEY not set
>>> envconfig2.string('DB_HOST', default='localhost')
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA