{ "info": { "author": "Caleb Hattingh", "author_email": "caleb.hattingh@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8" ], "description": ".. image:: https://img.shields.io/badge/stdlib--only-yes-green.svg\n :target: https://img.shields.io/badge/stdlib--only-yes-green.svg\n\n.. image:: https://travis-ci.org/cjrh/biodome.svg?branch=master\n :target: https://travis-ci.org/cjrh/biodomebiodome\n\n.. image:: https://coveralls.io/repos/github/cjrh/biodome/badge.svg?branch=master\n :target: https://coveralls.io/github/cjrh/biodome?branch=master\n\n.. image:: https://img.shields.io/pypi/pyversions/biodome.svg\n :target: https://pypi.python.org/pypi/biodome\n\n.. image:: https://img.shields.io/github/tag/cjrh/biodome.svg\n :target: https://img.shields.io/github/tag/cjrh/biodome.svg\n\n.. image:: https://img.shields.io/badge/install-pip%20install%20biodome-ff69b4.svg\n :target: https://img.shields.io/badge/install-pip%20install%20biodome-ff69b4.svg\n\n.. image:: https://img.shields.io/pypi/v/biodome.svg\n :target: https://img.shields.io/pypi/v/biodome.svg\n\n.. image:: https://img.shields.io/badge/calver-YYYY.MM.MINOR-22bfda.svg\n :target: http://calver.org/\n\nbiodome\n=======\n\n*Controlled environments*\n\nReading environment variables with ``os.environ`` is pretty easy, but after\na while one gets pretty tired of having to cast variables to the right types\nand handling fallback to defaults.\n\nThis library provides a clean way read environment variables and fall back\nto defaults in a sane way.\n\n**How you were doing it:**\n\n.. code:: python\n\n import os\n\n try:\n TIMEOUT = int(os.environ.get('TIMEOUT', 10))\n except ValueError:\n TIMEOUT = 10\n\nWordy, boilerplate, DRY violation, etc.\n\n**How you will be doing it:**\n\n.. code:: python\n\n import biodome\n\n TIMEOUT = biodome.environ.get('TIMEOUT', 10)\n\nThat's right, it becomes a single line. But there's a magic trick here: how\ndoes ``biodome`` know that ``TIMEOUT`` should be set to an ``int``? It knows\nbecause it looks at the type of the default arguments. This works for a bunch\nof different things:\n\n.. code:: python\n\n # Lists\n os.environ['IGNORE_KEYS'] = '[1, 2, 3]'\n biodome.environ.get('TIMEOUT', []) == [1, 2, 3]\n\n # Dicts\n os.environ['SETTINGS'] = '{\"a\": 1, \"b\": 2}'\n biodome.environ.get('SETTINGS', {}) == dict(a=1, b=2)\n\nIf you look carefully at the above, you can see that we *set* the data via\nthe stdlib ``os.environ`` dictionary; that's right, ``biodome.environ`` is a\n**drop-in replacement** for ``os.environ``. You don't even have to switch out\nyour entire codebase, you can do it piece by piece.\n\nAnd while we're on the subject of *setting* env vars, with ``biodome`` you\ndon't have to cast them first, it does string casting internally automatically,\nunlike ``os.environ``:\n\n.. code:: python\n\n # Dicts\n biodome.environ['SETTINGS'] = dict(b=2, a=1) # No cast required\n biodome.environ.get('SETTINGS', {}) == dict(a=1, b=2)\n\nLoading env files\n-----------------\n\n``biodome`` also provides a function to load a file which specifies the\nvalues of environment variables. An example of such an *env* file::\n\n # myconfig.env\n # This sets the log level for all the loggers in the program\n LOGGER_LEVEL=info\n\n # Hourly backups are stored at this path and named with a timestamp.\n BACKUP_PATH=/data/backups/\n\n # The number of times to retry outgoing HTTP requests if the status\n # code is > 500\n RETRY_TIME=5\n\nThe name of the environment variable must be on the left and the value\non the right. Each variable must be on its own line. Lines starting with\na ``#`` are considered comments and are ignored.\n\nThis *env* file can be loaded like this:\n\n.. code-block:: python\n\n >>> import biodome\n >>> biodome.load_env_file('myconfig.env')\n >>> print(biodome.environ['RETRY_TIME'])\n 5\n\nTrue and False\n--------------\n\nI don't know about you, but I use bool settings a LOT in environment variables,\nso handling this properly is really important to me. When calling\n``biodome.environ.get('SETTING', default=)``, the default value\ncan also be a bool, i.e., ``True`` or ``False``. In this case, *any of the\nfollowing values*, **and** their upper- or mixed-case equivalents will be\nrecognized as ``True``:\n\n.. code:: python\n\n ['1', 'y', 'yes', 'on', 'active', 'activated', 'enabled', 'true',\n 't', 'ok', 'yeah']\n\nAnything not in this list will be considered as ``False``. Do you have ideas\nfor more things that should be considered as ``True``? I take PRs!\n\nCallables\n---------\n\nFor explictness it is often convenient to declare and load environment\nvariables at the top of the module in which they're used:\n\n.. code:: python\n\n \"\"\" My new module \"\"\"\n import biodome\n\n ENABLE_SETTING_XYZ = biodome.environ.get('ENABLE_SETTING_XYZ', True)\n\n def blah():\n print(ENABLE_SETTING_XYZ)\n\nYou *could* call ``environ.get()`` inside the functions and methods where it\nis used, but then you would lose the convenience of documenting all the\navailable environment variables at the top of the module. As a solution to\nthis problem, *biodome* provides a way to produce a callable for a particular\nsetting. An extra advantage of doing this is that it becomes quite easy to\nmake use of changes in environment variables on the fly. Here's the\nmodified example:\n\n.. code:: python\n\n \"\"\" My new module \"\"\"\n import biodome\n\n ENABLE_SETTING_XYZ = biodome.environ.get_callable(\n # Same as before\n 'ENABLE_SETTING_XYZ', True\n )\n\n def blah():\n print(ENABLE_SETTING_XYZ()) # Now a callable!\n\nHow it works internally\n-----------------------\n\nThe key theme here is that the *type* of the default value is used to determine\nhow to cast the input value. This works for the following types:\n\n- ``int``\n- ``float``\n- ``str``\n- ``list``\n- ``dict``\n- ``set`` (**NOTE**: only supported in Python 3+ due to ``ast.literal_eval()``)\n- ``tuple``\n\nFor the containers, we use ``ast.literal_eval()`` which is much safer than\nusing ``eval()`` because code is not evaluated. Safety first! (thanks to\n@nickdirienzo for the tip)\n", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/cjrh/biodome", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "biodome", "package_url": "https://pypi.org/project/biodome/", "platform": "", "project_url": "https://pypi.org/project/biodome/", "project_urls": { "Homepage": "https://github.com/cjrh/biodome" }, "release_url": "https://pypi.org/project/biodome/2019.7.1/", "requires_dist": [ "typing; python_version < '3.5'" ], "requires_python": "", "summary": "biodome", "version": "2019.7.1" }, "last_serial": 5530596, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "4e71b27ba34d4e78017e223064cee9cc", "sha256": "bcf3d6f6590b33649c9fdf4164207aebc9049408f1bd5423ef256c1e822d3cab" }, "downloads": -1, "filename": "biodome-0.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "4e71b27ba34d4e78017e223064cee9cc", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 13373, "upload_time": "2017-06-28T13:06:18", "url": "https://files.pythonhosted.org/packages/a3/11/8863eb08add3e17300c95cc74476172bdae537af128ba417108d385ecaff/biodome-0.0.1-py2.py3-none-any.whl" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "1a2f1a94fc989f1664cab7ec7c9ab879", "sha256": "b3d943fe7811c4d8eb30c92a72499e36fa07563f519a312dc1fe6a2a4ef14bc9" }, "downloads": -1, "filename": "biodome-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1a2f1a94fc989f1664cab7ec7c9ab879", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 14153, "upload_time": "2017-06-28T13:08:30", "url": "https://files.pythonhosted.org/packages/f4/16/d6ec4e4ad20f1d1f858003fbf0c112e7d616d2c8890ff93515ab468c7d76/biodome-0.1.0-py2.py3-none-any.whl" } ], "2017.12.1": [ { "comment_text": "", "digests": { "md5": "6fc9aa513fc1352cf18035b42cf76eb2", "sha256": "ad5927219c366868987510ad893218370debfc5b441a3d4f1d52a07a15e4f121" }, "downloads": -1, "filename": "biodome-2017.12.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "6fc9aa513fc1352cf18035b42cf76eb2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17251, "upload_time": "2017-12-08T02:11:22", "url": "https://files.pythonhosted.org/packages/21/5b/9dbbcfef67909128ab2785026edf290615c87ee0ebfbc902f92a5d4070a6/biodome-2017.12.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "608eeb43651df98edfd5e230007a8438", "sha256": "4c9be591441a61a069308aa38eab79c7721ae2315de628a80acbb0a21c075ab7" }, "downloads": -1, "filename": "biodome-2017.12.1.tar.gz", "has_sig": false, "md5_digest": "608eeb43651df98edfd5e230007a8438", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9935, "upload_time": "2017-12-08T02:11:24", "url": "https://files.pythonhosted.org/packages/9d/33/a288f1fb1a3959439ca25095c89d88cfe070292755d02c61d29e1fa5b4e7/biodome-2017.12.1.tar.gz" } ], "2017.6.0": [ { "comment_text": "", "digests": { "md5": "c4477209e56511d8db6383db4600ca5c", "sha256": "12fbc082af9ac12588ba44b9677c695a37fb857792118fce5ee65b80c884eff3" }, "downloads": -1, "filename": "biodome-2017.6.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c4477209e56511d8db6383db4600ca5c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 14305, "upload_time": "2017-06-28T14:47:04", "url": "https://files.pythonhosted.org/packages/91/46/239a20eea46ce683229daa2dd11c90e1399797460ea28edf29ef771b9d1d/biodome-2017.6.0-py2.py3-none-any.whl" } ], "2017.6.1": [ { "comment_text": "", "digests": { "md5": "c5a2810a732f363fca65456380743939", "sha256": "2af04541a1fb426416136916b236156df468ede5ca51312777d91ed03bae2011" }, "downloads": -1, "filename": "biodome-2017.6.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c5a2810a732f363fca65456380743939", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 14311, "upload_time": "2017-06-28T23:09:26", "url": "https://files.pythonhosted.org/packages/d0/c4/caa0ea2aaa61537b5695e16ad07e7f350fa3637f0e051676c561e634347f/biodome-2017.6.1-py2.py3-none-any.whl" } ], "2017.6.2": [ { "comment_text": "", "digests": { "md5": "084f1d4bc32949936797bf049403800a", "sha256": "968f85524c55e2b24c0016af442947e057cb59f85e67af4e42ac41ec9e873aa6" }, "downloads": -1, "filename": "biodome-2017.6.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "084f1d4bc32949936797bf049403800a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 14346, "upload_time": "2017-06-28T23:25:55", "url": "https://files.pythonhosted.org/packages/3f/f9/38bd059ab0b7728ed584dfea03fab22e81419d57f9512444774e9eb6ceca/biodome-2017.6.2-py2.py3-none-any.whl" } ], "2017.6.3": [ { "comment_text": "", "digests": { "md5": "f3da3d77e23fc06fe68b74ee73786cfa", "sha256": "ecfe64fd3b5350127b6363e1dc1a1e1e30d2424cc5e02ee4a5177cb008eab3bd" }, "downloads": -1, "filename": "biodome-2017.6.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f3da3d77e23fc06fe68b74ee73786cfa", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 14349, "upload_time": "2017-06-28T23:34:32", "url": "https://files.pythonhosted.org/packages/c5/fb/bddae40e819441747b7fe0f34263a5d3a581cd8fa049f2553f8be8670d66/biodome-2017.6.3-py2.py3-none-any.whl" } ], "2017.6.5": [ { "comment_text": "", "digests": { "md5": "1a7cf8a724a883aa26951744c7e8d305", "sha256": "dcb6522807c042e7f8faf266db75c67ece6586e8959cd3cc274ea2750d03672c" }, "downloads": -1, "filename": "biodome-2017.6.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1a7cf8a724a883aa26951744c7e8d305", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 15706, "upload_time": "2017-07-01T01:46:57", "url": "https://files.pythonhosted.org/packages/ae/e5/c1bd9ea62076271c1ab60c0b4b5723ef2bd62339a26514cf997aadbe5896/biodome-2017.6.5-py2.py3-none-any.whl" } ], "2017.8.1": [ { "comment_text": "", "digests": { "md5": "89dcf3d1a2a97974d4cc8528199fa30d", "sha256": "c80a794a0a6b8d2d0433c6ee64455b2c058dbb3fe4cff1c5bfe2559075deba5f" }, "downloads": -1, "filename": "biodome-2017.8.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "89dcf3d1a2a97974d4cc8528199fa30d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 16500, "upload_time": "2017-08-01T11:44:44", "url": "https://files.pythonhosted.org/packages/cf/a5/ad91fd6488299c2509f963d7502e067298307b8b5210f000d0310187bbf2/biodome-2017.8.1-py2.py3-none-any.whl" } ], "2017.8.2": [ { "comment_text": "", "digests": { "md5": "bcc829ca59a015f30a3fbb0641fd3f70", "sha256": "bd3eb5719b433ccb6aa1727db60ffef89275ca59bcad5938efb50310df470f45" }, "downloads": -1, "filename": "biodome-2017.8.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "bcc829ca59a015f30a3fbb0641fd3f70", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 16952, "upload_time": "2017-08-02T21:52:37", "url": "https://files.pythonhosted.org/packages/90/21/4c1a869c864601d0c651843e62698aba5dd2c0f7715d877548507615f8db/biodome-2017.8.2-py2.py3-none-any.whl" } ], "2018.8.2": [ { "comment_text": "", "digests": { "md5": "79f53ad06cb00cd3a762826840128c44", "sha256": "acb2a0f537613b8c2639ecf03c48dda100ffb51b5851b63c0101fd028562d6d6" }, "downloads": -1, "filename": "biodome-2018.8.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "79f53ad06cb00cd3a762826840128c44", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17695, "upload_time": "2018-08-13T12:22:55", "url": "https://files.pythonhosted.org/packages/86/59/0f12365743151e3fa2c8a1bceaa03358eb380a3742a832c8f8ad325d6354/biodome-2018.8.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "db6573e6c1d8b8a037773a849749a9c7", "sha256": "6cde4045752ed52d2b2c51504b40d17450130adf1674ad620f1b726adf1e7222" }, "downloads": -1, "filename": "biodome-2018.8.2.tar.gz", "has_sig": false, "md5_digest": "db6573e6c1d8b8a037773a849749a9c7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9846, "upload_time": "2018-08-13T12:23:04", "url": "https://files.pythonhosted.org/packages/1f/c6/5a2c6cb067f0f657fed622ae561e410ef27a00aa6a1b880c7fd6f4a01036/biodome-2018.8.2.tar.gz" } ], "2018.8.3": [ { "comment_text": "", "digests": { "md5": "d12c0e36d8841aa1d443fc6dd93b9698", "sha256": "f65f32a088f74df32d43f8f2e8c5eadaa806c1a439408de89f8bbc7ca72cbc02" }, "downloads": -1, "filename": "biodome-2018.8.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d12c0e36d8841aa1d443fc6dd93b9698", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17678, "upload_time": "2018-08-17T09:05:20", "url": "https://files.pythonhosted.org/packages/2f/2e/61a08dbd22d4230a407cf44f7a407ed5e932057d297d2e923a1e6aa7b7d2/biodome-2018.8.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1ad7f75f6aa6df351397682300678cd3", "sha256": "b33523c48ab99ee4e7d46ac1baa659cd92416161bd5781aa41b4cad80e09f58e" }, "downloads": -1, "filename": "biodome-2018.8.3.tar.gz", "has_sig": false, "md5_digest": "1ad7f75f6aa6df351397682300678cd3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9832, "upload_time": "2018-08-17T09:05:23", "url": "https://files.pythonhosted.org/packages/e9/28/b0594f0524626dc8a05bdd416cde2fa2a5141b92c9799f4ad841d233d278/biodome-2018.8.3.tar.gz" } ], "2019.7.1": [ { "comment_text": "", "digests": { "md5": "4109f05e0b85ae1411ddfa55ebe8e4b2", "sha256": "cc424b4af34fcc829abdbd8cb501ac4df5cf07d51adf3e1b3d0152aa8f53eb8c" }, "downloads": -1, "filename": "biodome-2019.7.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "4109f05e0b85ae1411ddfa55ebe8e4b2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 19642, "upload_time": "2019-07-14T10:13:33", "url": "https://files.pythonhosted.org/packages/ed/9c/f8884b36051447f63430da0e04bc4b90cbae3a5851be649eb2c610901235/biodome-2019.7.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3139e8b5ee24286a46b6273790fe6636", "sha256": "fbe6bfcd611a6cbdc82ca72a9d07701b41ea8dfd56c1e5d0b730366f231f7611" }, "downloads": -1, "filename": "biodome-2019.7.1.tar.gz", "has_sig": false, "md5_digest": "3139e8b5ee24286a46b6273790fe6636", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10840, "upload_time": "2019-07-14T10:13:36", "url": "https://files.pythonhosted.org/packages/c5/a4/341cbd05c4f51e6bd59d41c5c5f585f150fb416bbe24e226821a3edfe141/biodome-2019.7.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4109f05e0b85ae1411ddfa55ebe8e4b2", "sha256": "cc424b4af34fcc829abdbd8cb501ac4df5cf07d51adf3e1b3d0152aa8f53eb8c" }, "downloads": -1, "filename": "biodome-2019.7.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "4109f05e0b85ae1411ddfa55ebe8e4b2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 19642, "upload_time": "2019-07-14T10:13:33", "url": "https://files.pythonhosted.org/packages/ed/9c/f8884b36051447f63430da0e04bc4b90cbae3a5851be649eb2c610901235/biodome-2019.7.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3139e8b5ee24286a46b6273790fe6636", "sha256": "fbe6bfcd611a6cbdc82ca72a9d07701b41ea8dfd56c1e5d0b730366f231f7611" }, "downloads": -1, "filename": "biodome-2019.7.1.tar.gz", "has_sig": false, "md5_digest": "3139e8b5ee24286a46b6273790fe6636", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10840, "upload_time": "2019-07-14T10:13:36", "url": "https://files.pythonhosted.org/packages/c5/a4/341cbd05c4f51e6bd59d41c5c5f585f150fb416bbe24e226821a3edfe141/biodome-2019.7.1.tar.gz" } ] }