tomlenv


Nametomlenv JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://github.com/joaonsantos/tomlenv
SummaryEnvironment Wrapped TOML
upload_time2023-01-27 10:54:09
maintainer
docs_urlNone
authorJoão Santos
requires_python>=3.11,<4.0
licenseMIT
keywords toml environment variables config
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # TOMLenv
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/joaonsantos/tomlenv/python-publish.yml)
![PyPI - Version](https://img.shields.io/pypi/v/tomlenv)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tomlenv)
![PyPI - Downloads](https://img.shields.io/pypi/dm/tomlenv)
![License](https://img.shields.io/github/license/joaonsantos/tomlenv)

Environment wrapped TOML. 

Package available in [PyPI](https://pypi.org/project/tomlenv/).

## Getting Started

### Install the library

Using pip:
```sh
$ pip install tomlenv
```

Using pipenv:
```sh
$ pipenv install tomlenv
```

Using poetry:
```sh
$ poetry add tomlenv
```

### Basic Usage

Tomlenv takes advantage of modern Python features such as `dataclasses` and
`tomllib` to create a simple yet powerful configuration library.

By default, tomlenv looks for a `config.toml` file in your project root:
```toml
token = "dev"
debug = false
```

Assuming this environment variable is set:
```sh
TOMLENV_DEBUG=true
```

Create your configuration dataclass and parse config and env into it:
```python
import tomlenv
from dataclasses import dataclass

@dataclass
class Config:
    token: str = ''
    debug: bool = False

config = Config()
parser = tomlenv.Parser()

parser.load(config)

# You can now access the fields of your fully typed config Class
# that contains values from a TOML config file and the environment.

# For example:

token = config.token
debug = config.debug
print(token) # prints "dev"
print(debug) # prints True
```

## Configuration

To configure the location of your toml file, set `TOMLENV_CONF_FILEPATH`.

For example if your config file is in `configs/config.toml` relative to the project root, then set `TOMLENV_CONF_FILEPATH=configs/config.toml`

## Tests

This project uses [Poetry](https://python-poetry.org/) and [GNU Make](https://www.gnu.org/software/make/).

Run tests from the project root with:
```sh
$ make test
```

To get a coverage report:
```sh
$ make cov
```

## Issues

Feel free to send issues or suggestions to https://github.com/joaonsantos/tomlenv/issues.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/joaonsantos/tomlenv",
    "name": "tomlenv",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11,<4.0",
    "maintainer_email": "",
    "keywords": "TOML,environment,variables,config",
    "author": "Jo\u00e3o Santos",
    "author_email": "joaopns05@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/4b/b1/9390fde3564e44e14e012d02ef81786332f54e14a735b64d953644ee7c70/tomlenv-0.2.2.tar.gz",
    "platform": null,
    "description": "# TOMLenv\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/joaonsantos/tomlenv/python-publish.yml)\n![PyPI - Version](https://img.shields.io/pypi/v/tomlenv)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tomlenv)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/tomlenv)\n![License](https://img.shields.io/github/license/joaonsantos/tomlenv)\n\nEnvironment wrapped TOML. \n\nPackage available in [PyPI](https://pypi.org/project/tomlenv/).\n\n## Getting Started\n\n### Install the library\n\nUsing pip:\n```sh\n$ pip install tomlenv\n```\n\nUsing pipenv:\n```sh\n$ pipenv install tomlenv\n```\n\nUsing poetry:\n```sh\n$ poetry add tomlenv\n```\n\n### Basic Usage\n\nTomlenv takes advantage of modern Python features such as `dataclasses` and\n`tomllib` to create a simple yet powerful configuration library.\n\nBy default, tomlenv looks for a `config.toml` file in your project root:\n```toml\ntoken = \"dev\"\ndebug = false\n```\n\nAssuming this environment variable is set:\n```sh\nTOMLENV_DEBUG=true\n```\n\nCreate your configuration dataclass and parse config and env into it:\n```python\nimport tomlenv\nfrom dataclasses import dataclass\n\n@dataclass\nclass Config:\n    token: str = ''\n    debug: bool = False\n\nconfig = Config()\nparser = tomlenv.Parser()\n\nparser.load(config)\n\n# You can now access the fields of your fully typed config Class\n# that contains values from a TOML config file and the environment.\n\n# For example:\n\ntoken = config.token\ndebug = config.debug\nprint(token) # prints \"dev\"\nprint(debug) # prints True\n```\n\n## Configuration\n\nTo configure the location of your toml file, set `TOMLENV_CONF_FILEPATH`.\n\nFor example if your config file is in `configs/config.toml` relative to the project root, then set `TOMLENV_CONF_FILEPATH=configs/config.toml`\n\n## Tests\n\nThis project uses [Poetry](https://python-poetry.org/) and [GNU Make](https://www.gnu.org/software/make/).\n\nRun tests from the project root with:\n```sh\n$ make test\n```\n\nTo get a coverage report:\n```sh\n$ make cov\n```\n\n## Issues\n\nFeel free to send issues or suggestions to https://github.com/joaonsantos/tomlenv/issues.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Environment Wrapped TOML",
    "version": "0.2.2",
    "split_keywords": [
        "toml",
        "environment",
        "variables",
        "config"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "691521bb30a4480c885004a99746f489fcb53bac598faab8cea20514f22c295b",
                "md5": "6649801e84ddddef31463a2bb1905d0c",
                "sha256": "05525cd3f026c8f1624dc2e5c1704c38d8877598ece4961a9f4640b335410a41"
            },
            "downloads": -1,
            "filename": "tomlenv-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6649801e84ddddef31463a2bb1905d0c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11,<4.0",
            "size": 4542,
            "upload_time": "2023-01-27T10:54:08",
            "upload_time_iso_8601": "2023-01-27T10:54:08.583234Z",
            "url": "https://files.pythonhosted.org/packages/69/15/21bb30a4480c885004a99746f489fcb53bac598faab8cea20514f22c295b/tomlenv-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4bb19390fde3564e44e14e012d02ef81786332f54e14a735b64d953644ee7c70",
                "md5": "5643c6e67874b85fefa11ca17d7b0f31",
                "sha256": "79c2a81ee7b84a2917747a087f61ffaf89c8d74ab3a785c768bc97cc32548cd7"
            },
            "downloads": -1,
            "filename": "tomlenv-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "5643c6e67874b85fefa11ca17d7b0f31",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11,<4.0",
            "size": 4484,
            "upload_time": "2023-01-27T10:54:09",
            "upload_time_iso_8601": "2023-01-27T10:54:09.653905Z",
            "url": "https://files.pythonhosted.org/packages/4b/b1/9390fde3564e44e14e012d02ef81786332f54e14a735b64d953644ee7c70/tomlenv-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-27 10:54:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "joaonsantos",
    "github_project": "tomlenv",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "tomlenv"
}
        
Elapsed time: 0.09226s