[![Supported Python Versions](https://img.shields.io/pypi/pyversions/rich/13.2.0)](https://pypi.org/project/python-ezconfig) [![PyPI version](https://badge.fury.io/py/python-ezconfig.svg)](https://badge.fury.io/py/python-ezconfig)
[![my telegram](https://img.shields.io/badge/my-telegram-blue)](https://t.me/zrxmax) [![xcrypto telegram](https://img.shields.io/badge/xcrypto%20+=%20dev-telegram-blue)](https://t.me/+vx4yLtrRcvAyZWM0)
![Logo](https://i.imgur.com/mbH37Fx.png)
[English readme](https://github.com/textualize/rich/blob/master/README.md)
### `ezconfig` is a Python library for easy formatting config file right from the terminal.
Press `ENTER` and run your code, **or change varialables right there!**
ezconfig can also use different variable types, use different styles, and highlight mistakes, if there are any.
![da](https://i.imgur.com/oF4ArPE.jpg)
## Installing
Requires Python 3.7 or later.
Install with pip or your favorite PyPI package manager.
```sh
pip install python-ezconfig
```
## Get started with 2 lines of code
```python
from ezconfig import EzConfig
ez = EzConfig("VAR1", "VAR2", ...)
ez.configure()
print(ez.config)
# {'VAR1': ..., 'VAR2': ...}
```
## Advanced usage
If you want to set **default value**, or prevent the user from leaving the **variable empty**, or set **value type** (instance) - use KeyPrompt
```python
from ezconfig import EzConfig, KeyPrompt
ez = EzConfig(
KeyPrompt("DELAY", value_type=float, default_value=5),
KeyPrompt("LINK", value_type=str, can_be_empty=False),
KeyPrompt("USE_PROXY", value_type=bool, can_be_empty=False),
KeyPrompt("USE_CACHE", value_type=bool, can_be_empty=False, default_value=False),
)
ez.configure()
```
If user will input string value in DELAY, then he will get this warning:
![](https://i.imgur.com/PhDSCwq.jpg)
And it works with many other types, such as `int`, `bool`, `float`, `str`...
As well, if you pass argument `can_be_empty=False`, the user will not be able to run your script without filling this field.
![](https://i.imgur.com/AFr112n.jpg)
Then you can access this variables
```python
print(ez.config['DELAY'])
# 28 # Note, you get a right types, int, not "28"
print(ez.config['USE_PROXY'])
# False
print(type(ez.config['USE_PROXY']))
# bool
```
Note: You always able to access configuration from config file as well
![](https://i.imgur.com/bt5VbhD.png)
you can change this file by passing `saving_json={file}` to `EzConfig()`
## Documentation
#### class - `ezconfig.EzConfig`
Allows super easy access to configuration file
To user, using easy interface,
and to you, just by 'EzConfig.config' dictionary <3
Arguments:
*key_prompts (KeyPrompt | str), Prompts, to ask user for. Required.
saving_json (Path | str, optional): path to json file to save config into. Defaults to "config.json".
show_index (bool, optional): True/False to show numbers column for rows. Defaults to True.
show_lines (bool, optional): True/False to show separation horizontal lines. Defaults to False.
clean_console (bool, optional): True/False to clean up console between printing. Defaults to True.
title (str, optional): The title of the table rendered at the top.. Defaults to None.
caption (str, optional): The table caption rendered below.. Defaults to None.
headers (Union[str, str], optional): Column headers, example: ("Key", "Value"). Defaults to None.
box (box.Box, optional): One of the constants in box.py used to draw the edges (see :ref:`appendix_box`), or ``None`` for no box lines. Defaults to box.ROUNDED.
style (StyleType, optional): Default style for the table. Defaults to "bold white".
column_styles (Union[StyleType, StyleType], optional): Union of 2 row styles. Defaults to ("bold cyan", "bold green").
console (Console, optional): Optional <rich.console.Console> object, if you want to use your custom rich console. Defaults to None.
configure_text (str, optional): Text that shows up when the configure method is used. Defaults to None.
EzConfig class methods:
`ezconfig.EzConfig.configure()` - Main method, prints configuration table and enables editing mode.
`ezconfig.EzConfig.print_config()` - Just prints config table, nothing more.
#### class - `ezconfig.KeyPrompt`
Defines a key-value prompt for EzConfig.
Arguments:
key (str): Key name, must be str.
default_value (str, optional): Will be default value if there are no saved values. Defaults to None.
can_be_empty (bool, optional): True/False. Defaults to True.
value_type (ValueType, optional): Value will be passed instance. Defaults to str.
there is no methods for this class.
##### That's all, thank you for your attention <3, here u can buy me a coffee
Any crypto network: `0x753846BF882046c5Edc3cefED30A4E6Bf8F99999`
<p><a href="https://www.buymeacoffee.com/zrxmax"> <img align="left" src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" height="50" width="210" alt="zrxmax" /></a><a href="https://ko-fi.com/zrxmax"> <img align="left" src="https://cdn.ko-fi.com/cdn/kofi3.png?v=3" height="50" width="210" alt="zrxmax" /></a></p><br><br></p>
Raw data
{
"_id": null,
"home_page": "https://github.com/zrxmax/python-ezconfig",
"name": "python-ezconfig",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "ezconfig,python-ezconfig,easyconfig,easy,pretty,beatiful,beauti,config,env",
"author": "zrxmax",
"author_email": "zrxmax@icloud.com",
"download_url": "https://files.pythonhosted.org/packages/2b/92/b07854ea1d9325d9c6f0ef0022f4ead048a34d7a5cdf0c194a4b946bb7d0/python-ezconfig-0.2.0.tar.gz",
"platform": null,
"description": "[![Supported Python Versions](https://img.shields.io/pypi/pyversions/rich/13.2.0)](https://pypi.org/project/python-ezconfig) [![PyPI version](https://badge.fury.io/py/python-ezconfig.svg)](https://badge.fury.io/py/python-ezconfig) \n\n[![my telegram](https://img.shields.io/badge/my-telegram-blue)](https://t.me/zrxmax) [![xcrypto telegram](https://img.shields.io/badge/xcrypto%20+=%20dev-telegram-blue)](https://t.me/+vx4yLtrRcvAyZWM0)\n\n![Logo](https://i.imgur.com/mbH37Fx.png)\n\n[English readme](https://github.com/textualize/rich/blob/master/README.md)\n\n### `ezconfig` is a Python library for easy formatting config file right from the terminal.\n\nPress `ENTER` and run your code, **or change varialables right there!** \n\nezconfig can also use different variable types, use different styles, and highlight mistakes, if there are any.\n\n![da](https://i.imgur.com/oF4ArPE.jpg)\n\n## Installing\n\nRequires Python 3.7 or later.\n\nInstall with pip or your favorite PyPI package manager.\n\n```sh\npip install python-ezconfig\n```\n\n## Get started with 2 lines of code\n\n```python\nfrom ezconfig import EzConfig\n\nez = EzConfig(\"VAR1\", \"VAR2\", ...)\nez.configure()\n\nprint(ez.config)\n# {'VAR1': ..., 'VAR2': ...}\n```\n\n## Advanced usage\n\nIf you want to set **default value**, or prevent the user from leaving the **variable empty**, or set **value type** (instance) - use KeyPrompt\n\n```python\nfrom ezconfig import EzConfig, KeyPrompt\n\nez = EzConfig(\n KeyPrompt(\"DELAY\", value_type=float, default_value=5),\n KeyPrompt(\"LINK\", value_type=str, can_be_empty=False),\n KeyPrompt(\"USE_PROXY\", value_type=bool, can_be_empty=False),\n KeyPrompt(\"USE_CACHE\", value_type=bool, can_be_empty=False, default_value=False),\n)\nez.configure()\n```\nIf user will input string value in DELAY, then he will get this warning:\n\n![](https://i.imgur.com/PhDSCwq.jpg)\nAnd it works with many other types, such as `int`, `bool`, `float`, `str`...\n\nAs well, if you pass argument `can_be_empty=False`, the user will not be able to run your script without filling this field.\n\n![](https://i.imgur.com/AFr112n.jpg)\n\nThen you can access this variables\n```python\nprint(ez.config['DELAY'])\n# 28 # Note, you get a right types, int, not \"28\"\nprint(ez.config['USE_PROXY'])\n# False\nprint(type(ez.config['USE_PROXY']))\n# bool\n```\n\nNote: You always able to access configuration from config file as well\n\n![](https://i.imgur.com/bt5VbhD.png)\nyou can change this file by passing `saving_json={file}` to `EzConfig()`\n\n## Documentation\n\n#### class - `ezconfig.EzConfig`\n\n Allows super easy access to configuration file\n\n To user, using easy interface,\n and to you, just by 'EzConfig.config' dictionary <3\n\n Arguments:\n *key_prompts (KeyPrompt | str), Prompts, to ask user for. Required.\n saving_json (Path | str, optional): path to json file to save config into. Defaults to \"config.json\".\n show_index (bool, optional): True/False to show numbers column for rows. Defaults to True.\n show_lines (bool, optional): True/False to show separation horizontal lines. Defaults to False.\n clean_console (bool, optional): True/False to clean up console between printing. Defaults to True.\n title (str, optional): The title of the table rendered at the top.. Defaults to None.\n caption (str, optional): The table caption rendered below.. Defaults to None.\n headers (Union[str, str], optional): Column headers, example: (\"Key\", \"Value\"). Defaults to None.\n box (box.Box, optional): One of the constants in box.py used to draw the edges (see :ref:`appendix_box`), or ``None`` for no box lines. Defaults to box.ROUNDED.\n style (StyleType, optional): Default style for the table. Defaults to \"bold white\".\n column_styles (Union[StyleType, StyleType], optional): Union of 2 row styles. Defaults to (\"bold cyan\", \"bold green\").\n console (Console, optional): Optional <rich.console.Console> object, if you want to use your custom rich console. Defaults to None.\n configure_text (str, optional): Text that shows up when the configure method is used. Defaults to None.\n\nEzConfig class methods:\n\n`ezconfig.EzConfig.configure()` - Main method, prints configuration table and enables editing mode.\n\n`ezconfig.EzConfig.print_config()` - Just prints config table, nothing more.\n\n\n\n#### class - `ezconfig.KeyPrompt`\n\n Defines a key-value prompt for EzConfig.\n\n Arguments:\n key (str): Key name, must be str.\n default_value (str, optional): Will be default value if there are no saved values. Defaults to None.\n can_be_empty (bool, optional): True/False. Defaults to True.\n value_type (ValueType, optional): Value will be passed instance. Defaults to str.\n\nthere is no methods for this class.\n\n##### That's all, thank you for your attention <3, here u can buy me a coffee\nAny crypto network: `0x753846BF882046c5Edc3cefED30A4E6Bf8F99999`\n<p><a href=\"https://www.buymeacoffee.com/zrxmax\"> <img align=\"left\" src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" height=\"50\" width=\"210\" alt=\"zrxmax\" /></a><a href=\"https://ko-fi.com/zrxmax\"> <img align=\"left\" src=\"https://cdn.ko-fi.com/cdn/kofi3.png?v=3\" height=\"50\" width=\"210\" alt=\"zrxmax\" /></a></p><br><br></p>\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Super easy access to configuration file, by pretty interface",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/zrxmax/python-ezconfig"
},
"split_keywords": [
"ezconfig",
"python-ezconfig",
"easyconfig",
"easy",
"pretty",
"beatiful",
"beauti",
"config",
"env"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2b92b07854ea1d9325d9c6f0ef0022f4ead048a34d7a5cdf0c194a4b946bb7d0",
"md5": "14312806b16910cea203068af9c3c866",
"sha256": "f84c4ab800427bb9e85deb2cb68be0c20e579ec4f2b3ed8294bebd022441597d"
},
"downloads": -1,
"filename": "python-ezconfig-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "14312806b16910cea203068af9c3c866",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 8732,
"upload_time": "2023-11-11T20:39:28",
"upload_time_iso_8601": "2023-11-11T20:39:28.008054Z",
"url": "https://files.pythonhosted.org/packages/2b/92/b07854ea1d9325d9c6f0ef0022f4ead048a34d7a5cdf0c194a4b946bb7d0/python-ezconfig-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-11 20:39:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "zrxmax",
"github_project": "python-ezconfig",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "python-ezconfig"
}