{ "info": { "author": "Hugo Rodger-Brown", "author_email": "hugo@yunojuno.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.6" ], "description": ".. image:: https://travis-ci.org/yunojuno/python-env-utils.svg?branch=master\n :target: https://travis-ci.org/yunojuno/python-env-utils\n\n.. image:: https://badge.fury.io/py/python-env-utils.svg\n :target: https://badge.fury.io/py/python-env-utils\n\n.. image:: https://codecov.io/gh/yunojuno/python-env-utils/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/yunojuno/python-env-utils\n\nenv utils\n=========\n\nThis library extends the standard library's ``getenv`` function, allowing\nyou to coerce the return value into a type.\n\nAnd that's it.\n\nIt's been released as a library because every project we have includes the\nsame requirements - read in environment variables, coerce them into the\ncorrect type.\n\nThe problem is that environment variables are always stored as strings, but\nPython will evaluate any string (even \"\") as True if cast to a boolean. This\nis almost never the desired behaviour. If you set an environment variable to\n\"\", \"0\" or \"False\", you want it to be False.\n\n.. code:: python\n\n >>> os.environ['foo'] = \"0\"\n >>> val = os.getenv('foo')\n >>> val\n \"0\"\n >>> bool(val)\n True\n\n``env_utils.get_env`` will coerce the value into the type you require. The package contains basic helper functions that coerce booleans, integers, decimals, floats, dates, lists and dictionaries.\n\n.. code:: python\n\n # FOO=0\n >>> env_utils.get_env('FOO')\n \"0\"\n >>> env_utils.get_bool('FOO')\n False\n >>> env_utils.get_int('FOO')\n 0\n\n # FOO=foo,bar\n >>> env_utils.get_list('FOO', separator=',')\n ['foo', 'bar']\n\n # FOO='{\"foo\": true}'\n >>> env_utils.get_dict('FOO')\n {'foo': True}\n\n # FOO=2016-11-23\n >>> env_utils.get_date('FOO')\n datetime.date(2016, 11, 23)\n\nYou can supply any function you like to coerce the value, e.g.:\n\n.. code:: python\n\n >>> import os\n >>> os.getenv('FOO_NAME')\n 'bob'\n >>> class Foo(object):\n ... def __init__(self, name):\n ... self.name = name\n >>> coerce = lambda x: Foo(x)\n >>> import env_utils\n >>> foo = env_utils.get_env('FOO_NAME', coerce=coerce)\n >>> foo.name\n >>> 'bob'\n\n\nInstallation\n------------\n\nThe library is available at pypi as 'python-env-utils', and can installed using pip::\n\n $ pip install python-env-utils\n\nTests\n-----\n\nThe tests can be run using ``tox``:\n\n.. code:: shell\n\n $ tox", "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/yunojuno/python-env-utils", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "python-env-utils", "package_url": "https://pypi.org/project/python-env-utils/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/python-env-utils/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/yunojuno/python-env-utils" }, "release_url": "https://pypi.org/project/python-env-utils/0.4.1/", "requires_dist": null, "requires_python": null, "summary": "Utility functions to make it easier to work with os.environ", "version": "0.4.1" }, "last_serial": 2764353, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "6f1637cf02138ba9d8a07da39beced73", "sha256": "c0e9eb571a2a442b4c119a337c9cf0694984b6d1e0db198f2dcd85dc539a726b" }, "downloads": -1, "filename": "python-env-utils-0.1.0.macosx-10.12-intel.tar.gz", "has_sig": false, "md5_digest": "6f1637cf02138ba9d8a07da39beced73", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4707, "upload_time": "2016-11-24T11:21:39", "url": "https://files.pythonhosted.org/packages/21/93/18121078485411524be9abf0eb9ba0b80c2f5e0100e0928a641e4031c630/python-env-utils-0.1.0.macosx-10.12-intel.tar.gz" }, { "comment_text": "", "digests": { "md5": "2ac3bb945cb2894c6e34e771f4b6c968", "sha256": "e6f365df557ac85db44c3c6b4bbf8cd298ef6053d22e76d6ea4b88c9663ed02c" }, "downloads": -1, "filename": "python-env-utils-0.1.0.tar.gz", "has_sig": false, "md5_digest": "2ac3bb945cb2894c6e34e771f4b6c968", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4454, "upload_time": "2016-11-24T11:20:58", "url": "https://files.pythonhosted.org/packages/99/09/e1fdcf5a43b0f532a481cc7fa7776e7c96aa285504d4901baba5537c938c/python-env-utils-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "323fccbd6cf2b0bf30e5259fdea10f01", "sha256": "101cbbb3317a51b7f1acc3902bfe7626301fc4b0dee98f0d441c495290c567c1" }, "downloads": -1, "filename": "python-env-utils-0.1.1.tar.gz", "has_sig": false, "md5_digest": "323fccbd6cf2b0bf30e5259fdea10f01", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4463, "upload_time": "2016-11-24T11:31:33", "url": "https://files.pythonhosted.org/packages/87/27/20ad3cc85a967279ed20012778544a50684ad4e21138cc45a68f091bd713/python-env-utils-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "7591c70d420c7812cb52637e66016572", "sha256": "43d7ff2478aba602f855a21ccbfe0ed9adf2f0108d2f5da6fdcd5442420bd391" }, "downloads": -1, "filename": "python-env-utils-0.2.0.macosx-10.12-intel.tar.gz", "has_sig": false, "md5_digest": "7591c70d420c7812cb52637e66016572", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4696, "upload_time": "2016-11-24T12:21:03", "url": "https://files.pythonhosted.org/packages/c6/7d/134b6ae77a8216d3af66d553127beb31f2e6494adf6af51425435e717371/python-env-utils-0.2.0.macosx-10.12-intel.tar.gz" }, { "comment_text": "", "digests": { "md5": "fda1286669caa0d2448308ee4889b645", "sha256": "7603a0dddb706b735127fd8e59ea4b8ffc8071fe03f5fa59425e121425f82a3b" }, "downloads": -1, "filename": "python-env-utils-0.2.0.tar.gz", "has_sig": false, "md5_digest": "fda1286669caa0d2448308ee4889b645", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4458, "upload_time": "2016-11-24T12:21:05", "url": "https://files.pythonhosted.org/packages/4d/94/0c0fcd6a1ace79e774b8c59a6866f9234a6face51b9d3df76f7ebf121ebf/python-env-utils-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "0a7a7b51ce28a367158c8a0d014f3228", "sha256": "28095d139b4754d0ae471b6b32b700a8c3b5b8052573abeeed19f9fc2896ae88" }, "downloads": -1, "filename": "python_env_utils-0.3.0-py2-none-any.whl", "has_sig": false, "md5_digest": "0a7a7b51ce28a367158c8a0d014f3228", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 5600, "upload_time": "2017-01-10T17:40:00", "url": "https://files.pythonhosted.org/packages/a7/29/7ce38e13a1c433488be7e05032cec949ac04835354dcdeaedae70d9b42a0/python_env_utils-0.3.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b89d81f7293aee9f42288d78d3407be1", "sha256": "745a569ed83cb1019bcc3a4513a7b4e14757afaafba6c09281c651e172208d3c" }, "downloads": -1, "filename": "python-env-utils-0.3.0.tar.gz", "has_sig": false, "md5_digest": "b89d81f7293aee9f42288d78d3407be1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4602, "upload_time": "2017-01-10T17:40:02", "url": "https://files.pythonhosted.org/packages/31/66/b79b46182492811e095924cdb3ba27af702abaf5ea99845881e09c237e43/python-env-utils-0.3.0.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "9022e20e80a6f24b102f0b8bc2a69fce", "sha256": "dfee50c0c5bd6b313bf7bda56f19c8cc9a625122e11439e6b5ac274ec8e89be5" }, "downloads": -1, "filename": "python_env_utils-0.4-py2-none-any.whl", "has_sig": false, "md5_digest": "9022e20e80a6f24b102f0b8bc2a69fce", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 8669, "upload_time": "2017-04-09T16:35:02", "url": "https://files.pythonhosted.org/packages/25/9e/0af13856c33dbe6e29581ce806e2dfde96f544b37e524a050d6af04af4db/python_env_utils-0.4-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c7f17cf5a1c591b22415b37334bc7a27", "sha256": "9e30230209fa94c910c3149e8ecbdbf42e4d2aa3975fec0c5123f630486c5c31" }, "downloads": -1, "filename": "python-env-utils-0.4.tar.gz", "has_sig": false, "md5_digest": "c7f17cf5a1c591b22415b37334bc7a27", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5644, "upload_time": "2017-04-09T16:35:00", "url": "https://files.pythonhosted.org/packages/fe/e4/0ee4a5a026e85347e1f99e2698d004d859bfca78badf9c99b5b58ddfe997/python-env-utils-0.4.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "6b1be03cf922cb0dfe798ef08aa6fc6d", "sha256": "7706f7a05af68aefba4b142ae8de970016bfee98c03d3de93d5b049fd12a4688" }, "downloads": -1, "filename": "python_env_utils-0.4.1-py2-none-any.whl", "has_sig": false, "md5_digest": "6b1be03cf922cb0dfe798ef08aa6fc6d", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 8744, "upload_time": "2017-04-09T18:44:02", "url": "https://files.pythonhosted.org/packages/d5/16/c39469945067a0b675f2cc0ae6b8e37f68e77d846ae216d05a0f7e7c9323/python_env_utils-0.4.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d695740e7095b2e1242138a9a9e9da62", "sha256": "6357d9ae024e5039158ce337bafeca662453f41cd7789a4517217c1a9093ce57" }, "downloads": -1, "filename": "python-env-utils-0.4.1.tar.gz", "has_sig": false, "md5_digest": "d695740e7095b2e1242138a9a9e9da62", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5711, "upload_time": "2017-04-09T18:43:59", "url": "https://files.pythonhosted.org/packages/57/96/c49c675b9a8cfb79b7377bb5e357feafb810dd2831201cde4e499c0a5e52/python-env-utils-0.4.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6b1be03cf922cb0dfe798ef08aa6fc6d", "sha256": "7706f7a05af68aefba4b142ae8de970016bfee98c03d3de93d5b049fd12a4688" }, "downloads": -1, "filename": "python_env_utils-0.4.1-py2-none-any.whl", "has_sig": false, "md5_digest": "6b1be03cf922cb0dfe798ef08aa6fc6d", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 8744, "upload_time": "2017-04-09T18:44:02", "url": "https://files.pythonhosted.org/packages/d5/16/c39469945067a0b675f2cc0ae6b8e37f68e77d846ae216d05a0f7e7c9323/python_env_utils-0.4.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d695740e7095b2e1242138a9a9e9da62", "sha256": "6357d9ae024e5039158ce337bafeca662453f41cd7789a4517217c1a9093ce57" }, "downloads": -1, "filename": "python-env-utils-0.4.1.tar.gz", "has_sig": false, "md5_digest": "d695740e7095b2e1242138a9a9e9da62", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5711, "upload_time": "2017-04-09T18:43:59", "url": "https://files.pythonhosted.org/packages/57/96/c49c675b9a8cfb79b7377bb5e357feafb810dd2831201cde4e499c0a5e52/python-env-utils-0.4.1.tar.gz" } ] }