whaox-wconfig


Namewhaox-wconfig JSON
Version 1.0.3 PyPI version JSON
download
home_pagehttps://github.com/topanim/WApi
SummaryLibrary to simplify working with the environment
upload_time2024-04-15 12:54:07
maintainerNone
docs_urlNone
authorWHAOX
requires_pythonNone
licenseMIT LICENSE, see LICENSE file
keywords python env environment config
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # WConfig: Library to simplify working with the environment

[![PyPI version](https://badge.fury.io/py/whaox-wconfig.svg)](https://badge.fury.io/py/whaox-wconfig)

## Libraries used
 * [dotenv](https://github.com/theskumar/python-dotenv)

## Installation

```commandline
pip install whaox-wconfig
```

## Features
* Modularity
* Type conversion
* Auto-return or handling

## Setup

> First, let's set up ours `.env` file

```dotenv
API_KEY=YOUR_API_KEY

API_URL=https://example.com

LOGGING=False
```

## Usage
> Not forget add this lines to your `main.py` file
 ```python
from dotenv import load_dotenv

load_dotev()
```
> Now let's create a config class

```python
class Config:
    
    @VAR("API_KEY")
    def api_key(self): pass
```

> You can easily get variables from your `.env` file

```python
config = Config()
config.api_key()

>>> YOUR_API_KEY
```

## Type conversion

> You can cast the value to the desired type, to do this, specify the type in the `_T` parameter
>
> NOTE: Supported types are `str, bool, int, float` 

```python
class Config:
    
    @VAR("LOGGING", bool)
    def logging(self) -> bool: pass
```

## Handling

> You can handle the received value if you need by setting the `handle` flag to `True`.

```python
class Config:
    
    @VAR("API_KEY", handle=True)
    def api_key(self, var): 
        return 'prefix-' + var
```

## Modularity
> You can split your config class into modules

```python
@Config("API")
class Api:
    
    @VAR("KEY")
    def key(self): pass
    
    @VAR("URL")
    def url(self): pass


class Config:
    api = Api()
    
    @VAR("LOGGING", bool)
    def logging(self): pass   
```

```python
config = Config()

config.api.key()
config.logging()
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/topanim/WApi",
    "name": "whaox-wconfig",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "python, env, environment, config",
    "author": "WHAOX",
    "author_email": "gorogannisan641@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/fc/08/97c8545b0fd37d0af6a0d12b6e254a02faea74e3f3a5b70c41017cedd060/whaox-wconfig-1.0.3.tar.gz",
    "platform": null,
    "description": "# WConfig: Library to simplify working with the environment\r\n\r\n[![PyPI version](https://badge.fury.io/py/whaox-wconfig.svg)](https://badge.fury.io/py/whaox-wconfig)\r\n\r\n## Libraries used\r\n * [dotenv](https://github.com/theskumar/python-dotenv)\r\n\r\n## Installation\r\n\r\n```commandline\r\npip install whaox-wconfig\r\n```\r\n\r\n## Features\r\n* Modularity\r\n* Type conversion\r\n* Auto-return or handling\r\n\r\n## Setup\r\n\r\n> First, let's set up ours `.env` file\r\n\r\n```dotenv\r\nAPI_KEY=YOUR_API_KEY\r\n\r\nAPI_URL=https://example.com\r\n\r\nLOGGING=False\r\n```\r\n\r\n## Usage\r\n> Not forget add this lines to your `main.py` file\r\n ```python\r\nfrom dotenv import load_dotenv\r\n\r\nload_dotev()\r\n```\r\n> Now let's create a config class\r\n\r\n```python\r\nclass Config:\r\n    \r\n    @VAR(\"API_KEY\")\r\n    def api_key(self): pass\r\n```\r\n\r\n> You can easily get variables from your `.env` file\r\n\r\n```python\r\nconfig = Config()\r\nconfig.api_key()\r\n\r\n>>> YOUR_API_KEY\r\n```\r\n\r\n## Type conversion\r\n\r\n> You can cast the value to the desired type, to do this, specify the type in the `_T` parameter\r\n>\r\n> NOTE: Supported types are `str, bool, int, float` \r\n\r\n```python\r\nclass Config:\r\n    \r\n    @VAR(\"LOGGING\", bool)\r\n    def logging(self) -> bool: pass\r\n```\r\n\r\n## Handling\r\n\r\n> You can handle the received value if you need by setting the `handle` flag to `True`.\r\n\r\n```python\r\nclass Config:\r\n    \r\n    @VAR(\"API_KEY\", handle=True)\r\n    def api_key(self, var): \r\n        return 'prefix-' + var\r\n```\r\n\r\n## Modularity\r\n> You can split your config class into modules\r\n\r\n```python\r\n@Config(\"API\")\r\nclass Api:\r\n    \r\n    @VAR(\"KEY\")\r\n    def key(self): pass\r\n    \r\n    @VAR(\"URL\")\r\n    def url(self): pass\r\n\r\n\r\nclass Config:\r\n    api = Api()\r\n    \r\n    @VAR(\"LOGGING\", bool)\r\n    def logging(self): pass   \r\n```\r\n\r\n```python\r\nconfig = Config()\r\n\r\nconfig.api.key()\r\nconfig.logging()\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT LICENSE, see LICENSE file",
    "summary": "Library to simplify working with the environment",
    "version": "1.0.3",
    "project_urls": {
        "Homepage": "https://github.com/topanim/WApi"
    },
    "split_keywords": [
        "python",
        " env",
        " environment",
        " config"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fc0897c8545b0fd37d0af6a0d12b6e254a02faea74e3f3a5b70c41017cedd060",
                "md5": "6f4a583bce0ee95ed726b41243a0c08c",
                "sha256": "45649435b9c6dcf12af006d2311991efcaf871c969b517d5a2b6d39df9063a75"
            },
            "downloads": -1,
            "filename": "whaox-wconfig-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "6f4a583bce0ee95ed726b41243a0c08c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5013,
            "upload_time": "2024-04-15T12:54:07",
            "upload_time_iso_8601": "2024-04-15T12:54:07.255587Z",
            "url": "https://files.pythonhosted.org/packages/fc/08/97c8545b0fd37d0af6a0d12b6e254a02faea74e3f3a5b70c41017cedd060/whaox-wconfig-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-15 12:54:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "topanim",
    "github_project": "WApi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "whaox-wconfig"
}
        
Elapsed time: 0.25553s