loadenv


Nameloadenv JSON
Version 0.1.1 PyPI version JSON
download
home_page
SummaryAutomatically load environment variables into structured Python data
upload_time2021-09-22 22:19:41
maintainer
docs_urlNone
author
requires_python>=3.6
license
keywords env envvar environ environment environment variable
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # loadenv

Automatically load environment variables into structured Python data

Loadenv makes it easy to pull environment variables into your program. It centralizes and hides the
task of loading environment variables and asserting necessary variables are set, while assigning
default values for those that are not required.

Loaded variables are cast to python objects based on type annotations and stored as identifiers, not
strings. So typo bugs are easier to catch and names are easier to autocomplete. It does all this
during startup, making bad invocations quit as soon as possible and with a clear error message,
rather than deep in business logic from strange Exceptions.


## Getting Started

Define an `EnvEnum` where each member is named exactly as the environment variable you wish to
capture. It should be annotated with the type you would like the member to be. You will have to
assign some value to the member to actually create it. For required environment variable this value
does not matter; values such as `()` or `...` are good choices.

```python
from loadenv import EnvEnum


# values are taken from the environment when the class is created
class Secrets(EnvEnum):
    USERNAME: str = ()
    USERPASS: str = ()
    USERAPIKEY: str = ()


# later on
requests.post(prod, headers={"Authorization": f"TOK:{Secrets.USERAPIKEY}"})
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "loadenv",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "env,envvar,environ,environment,environment variable",
    "author": "",
    "author_email": "Jeremiah Paige <ucodery@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/d7/a2/4ef0013d1683cdcd29ea254e3a02ac43f25323842fc8d59983eb17608f47/loadenv-0.1.1.tar.gz",
    "platform": "",
    "description": "# loadenv\n\nAutomatically load environment variables into structured Python data\n\nLoadenv makes it easy to pull environment variables into your program. It centralizes and hides the\ntask of loading environment variables and asserting necessary variables are set, while assigning\ndefault values for those that are not required.\n\nLoaded variables are cast to python objects based on type annotations and stored as identifiers, not\nstrings. So typo bugs are easier to catch and names are easier to autocomplete. It does all this\nduring startup, making bad invocations quit as soon as possible and with a clear error message,\nrather than deep in business logic from strange Exceptions.\n\n\n## Getting Started\n\nDefine an `EnvEnum` where each member is named exactly as the environment variable you wish to\ncapture. It should be annotated with the type you would like the member to be. You will have to\nassign some value to the member to actually create it. For required environment variable this value\ndoes not matter; values such as `()` or `...` are good choices.\n\n```python\nfrom loadenv import EnvEnum\n\n\n# values are taken from the environment when the class is created\nclass Secrets(EnvEnum):\n    USERNAME: str = ()\n    USERPASS: str = ()\n    USERAPIKEY: str = ()\n\n\n# later on\nrequests.post(prod, headers={\"Authorization\": f\"TOK:{Secrets.USERAPIKEY}\"})\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Automatically load environment variables into structured Python data",
    "version": "0.1.1",
    "split_keywords": [
        "env",
        "envvar",
        "environ",
        "environment",
        "environment variable"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d0bae29b2a5d12d5fad9c037ad7d5c3dffb22864d6511310bffa414c56408995",
                "md5": "a4dab4cec4da4b23a54df20636bee999",
                "sha256": "e06a1d86ea1ad89a96aeb470d27de8d569a980ad7c6fd0dd0ee416cc11919853"
            },
            "downloads": -1,
            "filename": "loadenv-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a4dab4cec4da4b23a54df20636bee999",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 6899,
            "upload_time": "2021-09-22T22:19:32",
            "upload_time_iso_8601": "2021-09-22T22:19:32.260220Z",
            "url": "https://files.pythonhosted.org/packages/d0/ba/e29b2a5d12d5fad9c037ad7d5c3dffb22864d6511310bffa414c56408995/loadenv-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d7a24ef0013d1683cdcd29ea254e3a02ac43f25323842fc8d59983eb17608f47",
                "md5": "f93e47f6c9b59f47e0c751c3335c344d",
                "sha256": "8dde4a80cf733323880c118659685d822f9d1311fa15b3d7e1e2aa28223aba29"
            },
            "downloads": -1,
            "filename": "loadenv-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "f93e47f6c9b59f47e0c751c3335c344d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 7456,
            "upload_time": "2021-09-22T22:19:41",
            "upload_time_iso_8601": "2021-09-22T22:19:41.369937Z",
            "url": "https://files.pythonhosted.org/packages/d7/a2/4ef0013d1683cdcd29ea254e3a02ac43f25323842fc8d59983eb17608f47/loadenv-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-09-22 22:19:41",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "loadenv"
}
        
Elapsed time: 0.02418s