{
"info": {
"author": "Rick Harris",
"author_email": "rconradharris@gmail.com",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 4 - Beta",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Software Development :: Libraries :: Python Modules"
],
"description": "envparse\n========\n``envparse`` is a simple utility to parse environment variables.\n\nIf you use Heroku and/or subscribe to the tenets of the\n`12 Factor App `_\nyou'll be using a lot of environment variable-based configuration in your app.\n``os.environ`` is a great choice to start off with but over time you'll find\nyourself duplicating quite a bit of code around handling raw environment\nvariables.\n\n``envparse`` aims to eliminate this duplicated, often inconsistent parsing\ncode and instead provide a single, easy-to-use wrapper.\n\nIdeas, and code portions, have been taken from `django-environ\n`_ project but made framework\nagnostic.\n\n\nInstalling\n----------\nThrough PyPI::\n\n $ pip install envparse\n\nManually::\n\n $ pip install git+https://github.com/rconradharris/envparse.git\n OR\n $ git clone https://github.com/rconradharris/envparse && cd envparse\n $ python setup.py install\n\n\nUsage\n-----\nIn your settings or configuration module, first either import the standard\nparser or one with a schema::\n\n # Standard\n from envparse import env\n\n # Schema\n from envparse import Env\n env = Env(BOOLEAN_VAR=bool, LIST_VAR=dict(type=list, subtype=int))\n\n\n``env`` can then be called in two ways:\n\n* Type explicit: ``env('ENV_VAR_NAME', type=TYPE, ...)``\n* Type implicit (for Python builtin types only): ``env.TYPE('ENV_VAR_NAME', ...)``\nIf type is not specified, explicitly or implicitly, then the default\ntype is ``str``.\n\n\nCasting to a specified type::\n\n # Environment variable: MAIL_ENABLED=1\n\n mail_enabled = env('MAIL_ENABLED', type=bool)\n # OR mail_enabled = env.bool('MAIL_ENABLED')\n assert mail_enabled is True\n\nCasting nested types::\n\n # Environment variable: FOO=1,2,3\n foo = env('FOO'), subtype=int)\n # OR: foo = env('FOO', type=list, subtype=int)\n # Note that there is no way to implicitly call subtypes.\n assert foo == [1, 2, 3]\n\nSpecifying defaults::\n\n # Environment variable MAX_ROWS has not been defined\n\n max_rows = env.int('MAX_ROWS', default=100)\n assert max_rows == 100\n\nProxying values, useful in Heroku for wiring up the environment variables they\nprovide to the ones that your app actually uses::\n\n # Environment variables: MAILGUN_SMTP_LOGIN=foo,\n # SMTP_LOGIN='{{MAILGUN_SMTP_LOGIN}}'\n\n smtp_login = env('SMTP_LOGIN')\n assert smtp_login == 'foo'\n\nNow if you switch to using Mandrill as an email provider, instead of having to\nmodify your app, you can simply make a configuration change::\n\n SMTP_LOGIN='{{MANDRILL_UESRNAME}}'\n\nThere are also a few convenience methods:\n\n* ``env.json``: parses JSON and returns a dict.\n* ``env.url``: parses a url and returns a ``urlparse.ParseResult`` object.\n\n\nType specific notes:\n\n* list: the expected environment variable format is ``FOO=1,2,3`` and may\n contain spaces between the commas as well as preceding or trailing whitespace.\n* dict: the expected environment variable format is ``FOO='key1=val1,\n key2=val2``. Spaces are also allowed.\n* json: a regular JSON string such as ``FOO='{\"foo\": \"bar\"}'`` is expected.\n\n\nSchemas\n~~~~~~~\nDefine a schema so you can only need to provide the type, subtype, and defaults\nonce::\n\n # Environment variables: MAIL_ENABLED=0, LIST_INT='1,2,3'\n\n # Bind schema to Env object to get schema-based lookups\n env = Env(MAIL_ENABLED=bool, SMTP_LOGIN=dict(type=str, default='foo'),\n LIST_INT=dict(type=list, subtype=int))\n assert env('MAIL_ENABLED') is False\n assert env('SMTP_LOGIN') == 'foo' # Not defined so uses default\n assert env('LIST_INT') == [1, 2, 3]\n\nThe ``Env`` constructor takes values in the form of either: ``VAR_NAME=type``\nor ``VAR_NAME=dict`` where ``dict`` is a dictionary with either one or more of\nthe following keys specified: ``type``, ``subtype``, ``default``.\n\n\nPre- and Postprocessors\n~~~~~~~~~~~~~~~~~~~~~~~\nPreprocessors are callables that are run on the environment variable string\nbefore any type casting takes place::\n\n # Environment variables: FOO=bar\n\n # Preprocessor to change variable to uppercase\n to_upper = lambda v: v.upper()\n foo = env('FOO', preprocessor=to_upper)\n assert foo == 'BAR'\n\nPostprocessors are callables that are run after the type casting takes place.\nAn example of one might be returning a datastructure expected by a framework::\n\n # Environment variable: REDIS_URL='redis://:redispass@127.0.0.1:6379/0'\n def django_redis(url):\n return {'BACKEND': 'django_redis.cache.RedisCache',\n 'LOCATION': '{}:{}:{}'.format(url.hostname, url.port, url.path.strip('/')),\n 'OPTIONS': {'PASSWORD': url.password}}\n\n redis_config = env('REDIS_URL', postprocessor=django_redis)\n assert redis_config == {'BACKEND': 'django_redis.cache.RedisCache',\n 'LOCATION': '127.0.0.1:6379:0', 'OPTIONS': {'PASSWORD': 'redispass'}}\n\n\nEnvironment File\n~~~~~~~~~~~~~~~~\nRead from a .env file (line delimited KEY=VALUE)::\n\n # This recurses up the directory tree until a file called '.env' is found.\n env.read_env()\n\n # Manually specifying a path\n env.read_env('/config/.myenv')\n\n # Values can be read as normal\n env.int('FOO')\n\n\nTests\n-----\n.. image:: https://secure.travis-ci.org/rconradharris/envparse.png?branch=master\n\nTo run the tests install tox::\n\n pip install tox\n\nThen run them with::\n\n make test",
"description_content_type": null,
"docs_url": null,
"download_url": "UNKNOWN",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/rconradharris/envparse",
"keywords": null,
"license": "MIT",
"maintainer": null,
"maintainer_email": null,
"name": "envparse",
"package_url": "https://pypi.org/project/envparse/",
"platform": "any",
"project_url": "https://pypi.org/project/envparse/",
"project_urls": {
"Download": "UNKNOWN",
"Homepage": "https://github.com/rconradharris/envparse"
},
"release_url": "https://pypi.org/project/envparse/0.2.0/",
"requires_dist": null,
"requires_python": null,
"summary": "Simple environment variable parsing",
"version": "0.2.0"
},
"last_serial": 1870292,
"releases": {
"0.1.0": [
{
"comment_text": "",
"digests": {
"md5": "56ab1742a0986ee3bf4dc7c2ee0b2a38",
"sha256": "bcc997a2f9d0ea861caad4b3a259f92d1cba2bfcc4309e0a45ba794c75d5d41e"
},
"downloads": -1,
"filename": "envparse-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "56ab1742a0986ee3bf4dc7c2ee0b2a38",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 2838,
"upload_time": "2012-10-26T23:19:05",
"url": "https://files.pythonhosted.org/packages/fe/0f/6314abe973b1ecd1d3eb8614e3fce1af23fa3a1470ca85c6143275615429/envparse-0.1.0.tar.gz"
}
],
"0.1.1": [
{
"comment_text": "",
"digests": {
"md5": "fcc25365d5438f38fa3451b0a7a4e3b1",
"sha256": "d64e92b6a4e608f5ee4c0d72bbb1c350489fcc40eb078084696008bfffabea58"
},
"downloads": -1,
"filename": "envparse-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "fcc25365d5438f38fa3451b0a7a4e3b1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 2855,
"upload_time": "2012-10-27T00:06:40",
"url": "https://files.pythonhosted.org/packages/9b/10/4ee30b0cc31a3fcc48800767a3dbad27739e5723470b1a8f6e2052f665fe/envparse-0.1.1.tar.gz"
}
],
"0.1.2": [
{
"comment_text": "",
"digests": {
"md5": "9856562f9e9fc5287e3d02e23565c652",
"sha256": "eeb37a6f4e02f7d58f94cb551ca8d4f21eaad667671c1a33adda5f2af55b3258"
},
"downloads": -1,
"filename": "envparse-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "9856562f9e9fc5287e3d02e23565c652",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 2922,
"upload_time": "2012-10-27T00:23:25",
"url": "https://files.pythonhosted.org/packages/3b/4d/4209f6a0129624540142bc6dd43f8aa4a80df7017122ee75f8c21cf69635/envparse-0.1.2.tar.gz"
}
],
"0.1.3": [
{
"comment_text": "",
"digests": {
"md5": "01a23db95e329a265db20fae89b03c47",
"sha256": "acee9a672814a7983607eac861ca9aabca9e02ebe3cfb963aeab5211dccc8a34"
},
"downloads": -1,
"filename": "envparse-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "01a23db95e329a265db20fae89b03c47",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3144,
"upload_time": "2012-11-05T04:59:42",
"url": "https://files.pythonhosted.org/packages/b2/dd/d60ea914d5ec18ca3786c796149af30d37af7c21c10b57ab7b8c1ff07351/envparse-0.1.3.tar.gz"
}
],
"0.1.4": [
{
"comment_text": "",
"digests": {
"md5": "c4ccada090376d76ce6060e695996210",
"sha256": "d92d6a777c7043d261d603cd5e41549ac3beca952ddbfe7ccfc1fa2913c7a44d"
},
"downloads": -1,
"filename": "envparse-0.1.4.tar.gz",
"has_sig": false,
"md5_digest": "c4ccada090376d76ce6060e695996210",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3146,
"upload_time": "2012-12-18T04:46:50",
"url": "https://files.pythonhosted.org/packages/79/1c/e8f2f6fd626ae3a67d7ed836dccc8458266a0e05e574083a520ca9e733a4/envparse-0.1.4.tar.gz"
}
],
"0.1.5": [
{
"comment_text": "",
"digests": {
"md5": "e136d2f0c76af982921c5c1780283248",
"sha256": "9d4d6259969d4c30abc837b3504d9c8332ce1aac4f8a525cbab5aedb79aae2ef"
},
"downloads": -1,
"filename": "envparse-0.1.5.tar.gz",
"has_sig": false,
"md5_digest": "e136d2f0c76af982921c5c1780283248",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3142,
"upload_time": "2012-12-18T05:06:34",
"url": "https://files.pythonhosted.org/packages/db/b3/7ef6729b2b13a81eae99fcea01c998c92e008afa3f7187f39546acca0a9f/envparse-0.1.5.tar.gz"
}
],
"0.1.6": [
{
"comment_text": "",
"digests": {
"md5": "2b2d556f195a0d502b8213b767fa55c8",
"sha256": "c69b6e07947660705a981a1c7d2bcd95c31f8c863e54acaec9d0235cffe32199"
},
"downloads": -1,
"filename": "envparse-0.1.6.tar.gz",
"has_sig": false,
"md5_digest": "2b2d556f195a0d502b8213b767fa55c8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4135,
"upload_time": "2015-05-25T18:19:42",
"url": "https://files.pythonhosted.org/packages/27/83/4839190da401b4cb29bcd807bcb3578964897130e38d0fa0e760177595f2/envparse-0.1.6.tar.gz"
}
],
"0.2.0": [
{
"comment_text": "",
"digests": {
"md5": "c236ef17971aea885d6d934d7ddeb144",
"sha256": "4f3b9a27bb55d27f124eb4adf006fec05e4588891c9a054a183a112645056eb7"
},
"downloads": -1,
"filename": "envparse-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "c236ef17971aea885d6d934d7ddeb144",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7576,
"upload_time": "2015-12-19T17:24:03",
"url": "https://files.pythonhosted.org/packages/2f/8d/bee8a59732c169a455627ff1557d0db180f7c352b0274480267ad3e46875/envparse-0.2.0.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "c236ef17971aea885d6d934d7ddeb144",
"sha256": "4f3b9a27bb55d27f124eb4adf006fec05e4588891c9a054a183a112645056eb7"
},
"downloads": -1,
"filename": "envparse-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "c236ef17971aea885d6d934d7ddeb144",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7576,
"upload_time": "2015-12-19T17:24:03",
"url": "https://files.pythonhosted.org/packages/2f/8d/bee8a59732c169a455627ff1557d0db180f7c352b0274480267ad3e46875/envparse-0.2.0.tar.gz"
}
]
}