confhub


Nameconfhub JSON
Version 0.1.0.7a0 PyPI version JSON
download
home_pageNone
SummaryConfiguration add-on to Dynaconf
upload_time2024-06-27 19:27:07
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseNone
keywords cfg confhub config configuration dynaconf setting settings
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![logo_confhub](https://github.com/morington/ConfHub/blob/main/logo.png?raw=true)

<p align="center">
    <img alt="PyPI - Status" src="https://img.shields.io/pypi/status/confhub">
    <img alt="PyPI - Version" src="https://img.shields.io/pypi/v/confhub">
    <img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/confhub">
    <img alt="PyPI - License" src="https://img.shields.io/pypi/l/confhub">
</p>

*********
## About
<b>Сonfhub</b> is a library that relieves developers of the tedious task of creating and managing configuration files. Instead of wasting valuable time writing configurations, developers can focus on building the site's functionality.

### History
Based on our own experience and the experience of our colleagues, we realized that the process of working with configurations had become a real burden. We wanted something simple and effective. After several weeks of testing our MVP, we identified the strengths and weaknesses and presented the first alpha version of confhub to the world. Despite its shortcomings, it showed prospects for development.

### Updated version (>= 0.1.0.5a)
We currently offer a significantly improved version of confhub, which has extensive functionality. You can now dynamically generate configurations from model classes, greatly simplifying the process. In addition, the library supports developer mode, which speeds up the process of replacing configurations several times.

*********
## Documentation

### Getting started with confhub

*********
**Installation and initialization**

To get started with confhub, you need to create a project and install the Python virtual environment. Then install the confhub library into the virtual environment.

```bash
pip install confhub
```

After installing the library, initialize it in your project with the following command:

```bash
confhub init <folder>
```

Where `<folder>` is the name of the folder where the entire configuration structure will be placed. For example:

```bash
confhub init configurations
```

This command will create the following structure in the root of your project:

- `.service.yml`: Contains basic settings such as paths to configs and models. The file is automatically added to `.gitignore`.
- `configurations/`: A folder created at your request.
  - `config/`: A folder to store the generated configuration files.
  - `models.py`: A file for describing models. Initially contains an example PostgreSQL model.

*********
**Creating Models**

In `models.py` you can describe your models. For example:

```python
from confhub import BlockCore, field

class PostgreSQL(BlockCore):
    __block__ = 'postgresql'

    scheme = field(str)
    host = field(str, development_mode=True)
    port = field(int, secret=True)
    user = field(str, secret=True)
    password = field(str, secret=True)
    path = field(str, secret=True)

class ItemBlock(BlockCore):
    __block__ = 'item_block'

    item_name = field(str)

class TestBlock(BlockCore):
    __block__ = 'test_block'

    item_block = ItemBlock()
    illuminati = field(str, filename='illuminati')
    admins = field(str)
```

*********
**Generation of configuration files**

After creating models, you can generate configuration files using the command:

```bash
confhub generate_models
```

This command converts your models into configuration files with a `.yml` extension.

Confhub generates two main files: `settings` and `.secrets`. The secrets are automatically added to `.gitignore`. You can also specify `filename` in models to create additional files in the `config` folder.

__Do not use `secrets` and `filename` at the same time. There may be unexpected consequences at this point!__

This documentation will help you get started with confhub and use its features to simplify the process of working with configurations in your project.

*********
**Filling configurations**

Fill in the configurations, e.g:

```yaml
postgresql:
  password: str; qwer
  path: str; db_confhub
  port: int; 5432
  user: str; morington
```

The data type is specified before the value. Available types: `str`, `int`, `bool`, `float`. YML also supports lists, in models we prescribe a type for the value of each element in a list, and with YML we make a list:

```yaml
admins:
  - str; Adam
  - str; John
  - str; Saly
```

*********
**Read configurations**

To read configurations, use the following code:

```python
import structlog
from confhub import Confhub
from confhub.setup_logger import LoggerReg

logger = structlog.get_logger(__name__)

if __name__ == '__main__':
    config = Confhub(developer_mode=True, logger_regs=[
        LoggerReg(name="", level=LoggerReg.Level.DEBUG,)
    ]).data

    logger.info("PostgreSQL", host=config.postgresql.host)
    logger.info("Admins", host=config.test.admins)
```

*********
**Logging Configuration**

Sonfhub uses `structlog` for logging. You can configure loggers using ``LoggerReg``:

```python
LoggerReg(name="", level=LoggerReg.Level.DEBUG)
```

*********
**developer_mode**

The `developer_mode` argument is available both in the `Confhub` class and in the `.service.yml` file. The class argument takes precedence over the file.

*********
## Main developers

### [Adam Morington](https://github.com/morington)

*********
## License
[Сonfhub](https://github.com/morington/confhub) is distributed under the [MIT license](https://github.com/morington/confhub/blob/main/LICENSE). This means that you are free to use, modify and distribute the library for any purpose, including commercial use.
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "confhub",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "cfg, confhub, config, configuration, dynaconf, setting, settings",
    "author": null,
    "author_email": "Adam Morington <morington.mail@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/ff/43/b56bd67c7da9fec80dcde5013c52b2ddfbd77fa5825820e0a14559df8bf4/confhub-0.1.0.7a0.tar.gz",
    "platform": null,
    "description": "![logo_confhub](https://github.com/morington/ConfHub/blob/main/logo.png?raw=true)\n\n<p align=\"center\">\n    <img alt=\"PyPI - Status\" src=\"https://img.shields.io/pypi/status/confhub\">\n    <img alt=\"PyPI - Version\" src=\"https://img.shields.io/pypi/v/confhub\">\n    <img alt=\"PyPI - Python Version\" src=\"https://img.shields.io/pypi/pyversions/confhub\">\n    <img alt=\"PyPI - License\" src=\"https://img.shields.io/pypi/l/confhub\">\n</p>\n\n*********\n## About\n<b>\u0421onfhub</b> is a library that relieves developers of the tedious task of creating and managing configuration files. Instead of wasting valuable time writing configurations, developers can focus on building the site's functionality.\n\n### History\nBased on our own experience and the experience of our colleagues, we realized that the process of working with configurations had become a real burden. We wanted something simple and effective. After several weeks of testing our MVP, we identified the strengths and weaknesses and presented the first alpha version of confhub to the world. Despite its shortcomings, it showed prospects for development.\n\n### Updated version (>= 0.1.0.5a)\nWe currently offer a significantly improved version of confhub, which has extensive functionality. You can now dynamically generate configurations from model classes, greatly simplifying the process. In addition, the library supports developer mode, which speeds up the process of replacing configurations several times.\n\n*********\n## Documentation\n\n### Getting started with confhub\n\n*********\n**Installation and initialization**\n\nTo get started with confhub, you need to create a project and install the Python virtual environment. Then install the confhub library into the virtual environment.\n\n```bash\npip install confhub\n```\n\nAfter installing the library, initialize it in your project with the following command:\n\n```bash\nconfhub init <folder>\n```\n\nWhere `<folder>` is the name of the folder where the entire configuration structure will be placed. For example:\n\n```bash\nconfhub init configurations\n```\n\nThis command will create the following structure in the root of your project:\n\n- `.service.yml`: Contains basic settings such as paths to configs and models. The file is automatically added to `.gitignore`.\n- `configurations/`: A folder created at your request.\n  - `config/`: A folder to store the generated configuration files.\n  - `models.py`: A file for describing models. Initially contains an example PostgreSQL model.\n\n*********\n**Creating Models**\n\nIn `models.py` you can describe your models. For example:\n\n```python\nfrom confhub import BlockCore, field\n\nclass PostgreSQL(BlockCore):\n    __block__ = 'postgresql'\n\n    scheme = field(str)\n    host = field(str, development_mode=True)\n    port = field(int, secret=True)\n    user = field(str, secret=True)\n    password = field(str, secret=True)\n    path = field(str, secret=True)\n\nclass ItemBlock(BlockCore):\n    __block__ = 'item_block'\n\n    item_name = field(str)\n\nclass TestBlock(BlockCore):\n    __block__ = 'test_block'\n\n    item_block = ItemBlock()\n    illuminati = field(str, filename='illuminati')\n    admins = field(str)\n```\n\n*********\n**Generation of configuration files**\n\nAfter creating models, you can generate configuration files using the command:\n\n```bash\nconfhub generate_models\n```\n\nThis command converts your models into configuration files with a `.yml` extension.\n\nConfhub generates two main files: `settings` and `.secrets`. The secrets are automatically added to `.gitignore`. You can also specify `filename` in models to create additional files in the `config` folder.\n\n__Do not use `secrets` and `filename` at the same time. There may be unexpected consequences at this point!__\n\nThis documentation will help you get started with confhub and use its features to simplify the process of working with configurations in your project.\n\n*********\n**Filling configurations**\n\nFill in the configurations, e.g:\n\n```yaml\npostgresql:\n  password: str; qwer\n  path: str; db_confhub\n  port: int; 5432\n  user: str; morington\n```\n\nThe data type is specified before the value. Available types: `str`, `int`, `bool`, `float`. YML also supports lists, in models we prescribe a type for the value of each element in a list, and with YML we make a list:\n\n```yaml\nadmins:\n  - str; Adam\n  - str; John\n  - str; Saly\n```\n\n*********\n**Read configurations**\n\nTo read configurations, use the following code:\n\n```python\nimport structlog\nfrom confhub import Confhub\nfrom confhub.setup_logger import LoggerReg\n\nlogger = structlog.get_logger(__name__)\n\nif __name__ == '__main__':\n    config = Confhub(developer_mode=True, logger_regs=[\n        LoggerReg(name=\"\", level=LoggerReg.Level.DEBUG,)\n    ]).data\n\n    logger.info(\"PostgreSQL\", host=config.postgresql.host)\n    logger.info(\"Admins\", host=config.test.admins)\n```\n\n*********\n**Logging Configuration**\n\nSonfhub uses `structlog` for logging. You can configure loggers using ``LoggerReg``:\n\n```python\nLoggerReg(name=\"\", level=LoggerReg.Level.DEBUG)\n```\n\n*********\n**developer_mode**\n\nThe `developer_mode` argument is available both in the `Confhub` class and in the `.service.yml` file. The class argument takes precedence over the file.\n\n*********\n## Main developers\n\n### [Adam Morington](https://github.com/morington)\n\n*********\n## License\n[\u0421onfhub](https://github.com/morington/confhub) is distributed under the [MIT license](https://github.com/morington/confhub/blob/main/LICENSE). This means that you are free to use, modify and distribute the library for any purpose, including commercial use.",
    "bugtrack_url": null,
    "license": null,
    "summary": "Configuration add-on to Dynaconf",
    "version": "0.1.0.7a0",
    "project_urls": {
        "Repository": "https://github.com/morington/confhub/"
    },
    "split_keywords": [
        "cfg",
        " confhub",
        " config",
        " configuration",
        " dynaconf",
        " setting",
        " settings"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "00f31c0e3ae1c87e6e463784126ff005d76be98c582355179591566b27c52f16",
                "md5": "0b104e488053f91b5eac8b91fa9a7311",
                "sha256": "35a31587e188a624b09bc8dc746a0c2d89b54e54e9020e84e90dc97e6424d2b9"
            },
            "downloads": -1,
            "filename": "confhub-0.1.0.7a0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0b104e488053f91b5eac8b91fa9a7311",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 17881,
            "upload_time": "2024-06-27T19:27:05",
            "upload_time_iso_8601": "2024-06-27T19:27:05.623674Z",
            "url": "https://files.pythonhosted.org/packages/00/f3/1c0e3ae1c87e6e463784126ff005d76be98c582355179591566b27c52f16/confhub-0.1.0.7a0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ff43b56bd67c7da9fec80dcde5013c52b2ddfbd77fa5825820e0a14559df8bf4",
                "md5": "11b348927fb716a4ecfd72c0565ff640",
                "sha256": "fff61ba965b3ebf05225fd5590e2514f753414164b873cec1dd6678a0452db82"
            },
            "downloads": -1,
            "filename": "confhub-0.1.0.7a0.tar.gz",
            "has_sig": false,
            "md5_digest": "11b348927fb716a4ecfd72c0565ff640",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 47530,
            "upload_time": "2024-06-27T19:27:07",
            "upload_time_iso_8601": "2024-06-27T19:27:07.504809Z",
            "url": "https://files.pythonhosted.org/packages/ff/43/b56bd67c7da9fec80dcde5013c52b2ddfbd77fa5825820e0a14559df8bf4/confhub-0.1.0.7a0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-27 19:27:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "morington",
    "github_project": "confhub",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "confhub"
}
        
Elapsed time: 0.32019s