hierarchical-conf


Namehierarchical-conf JSON
Version 1.0.3 PyPI version JSON
download
home_pagehttps://github.com/quintoandar/hierarchical-conf
SummaryA tool for loading settings from files hierarchically
upload_time2023-06-14 22:42:18
maintainer
docs_urlNone
authorQuintoAndar
requires_python>=3.7, <4
license
keywords hierarchical-conf configuration by environment configuration files configuration as code hierarchical configuration
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # Hierarchical Conf
_A library for loading configurations (or other metadata) hierarchically based on the current environment_

<img height="200" src="hierarchical_conf_logo.png" />

[![Release](https://img.shields.io/github/v/release/quintoandar/hierarchical-conf)]((https://pypi.org/project/hierarchical-conf/))
![Python Version](https://img.shields.io/badge/python-3.7%20%7C%203.8-brightgreen.svg)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

| Source    | Downloads                                                                                                       | Page                                                 | Installation Command                       |
|-----------|-----------------------------------------------------------------------------------------------------------------|------------------------------------------------------|--------------------------------------------|
| **PyPi**  | [![PyPi Downloads](https://pepy.tech/badge/hierarchical-conf)](https://pypi.org/project/hierarchical-conf/) | [Link](https://pypi.org/project/hierarchical-conf/)        | `pip install hierarchical-conf `                  |

### Build status
| Develop                                                                     | Stable                                                                            | Documentation                                                                                                                                           | Sonar                                                                                                                                                                                                  |
|-----------------------------------------------------------------------------|-----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ![Test](https://github.com/quintoandar/hierarchical-conf/workflows/Test/badge.svg) | ![Publish](https://github.com/quintoandar/hierarchical-conf/workflows/Publish/badge.svg) | [![Documentation Status](https://readthedocs.org/projects/hierarchical-conf/badge/?version=latest)](https://hierarchical-conf.readthedocs.io/en/latest/?badge=latest) | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=quintoandar_hierarchical-conf&metric=alert_status)](https://sonarcloud.io/dashboard?id=quintoandar_hierarchical-conf) |


This library supports Python version 3.7+.

To check library main features you can check [Hierarchical Conf's Documentation](https://hierarchical-conf.readthedocs.io/en/latest/), which is hosted by Read the Docs.

### How to use

#### Short
An example of how to use the library getting configurations:

```python
from hierarchical_conf.hierarchical_conf import HierarchicalConf

hierarchical_conf = HierarchicalConf(searched_paths=[PROJECT_ROOT])
my_config = hierarchical_conf.get_config("my_config_key")
```

#### Long

This tool retrieve the configurations from (YAML) files according to the current
environment and files precedence.

It receives a list of paths and searches each one for environment configuration files in an **orderly 
fashion**, loading them when found and **overwriting duplicated** configuration keys by the value of the key 
available in the file loaded at last.
The YAML configuration files are expected to be named with prefixes based on the working environment, 
retrieved by the value of a pre-existent operational system environment's variable named `ENVIRONMENT`.


E.g.: Given the respective environments `dev` and `production` configuration files below:

dev_conf.yml:
```yaml
 foo: bar_dev
 foo2: bar_dev2
```

production_conf.yml:
```yaml
 foo: bar_prod
 foo2: bar_prod2
```

and given we are at development environment (`ENVIRONMENT=dev`), the following code will load the
configuration file from the development environment file (`/my_path/dev_conf.yml`).

```python
hconf = HierarchicalConf(conf_files_paths=['/my_path/'])
foo_conf = hconf.get_config("foo")
print(foo_conf)
# prints: bar_dev
```

Given `ENVIRONMENT=production`, the code above will load the configuration file from
the production environment file (`/my_path/production_conf.yml`) and print: `bar_prod`.

To learn more use cases in practice (and about the keys overwriting), see [Hierarchical Conf examples](https://github.com/quintoandar/hierarchical-conf/tree/main/examples)  

---

## Requirements and Installation
The Hierarchical Conf depends on **Python 3.7+**

[Python Package Index](https://pypi.org/project/hierarchical-conf/) hosts reference to a pip-installable module of this library, using it is as straightforward as including it on your project's requirements.

```bash
pip install hierarchical-conf
```

## License
[Apache License 2.0](https://github.com/quintoandar/hierarchical-conf/blob/main/LICENSE)

## Contributing
All contributions are welcome! Feel free to open Pull Requests. Check the development and contributing **guidelines** 
described in [CONTRIBUTING.md](https://github.com/quintoandar/hierarchical-conf/blob/main/CONTRIBUTING.md)

Made with :heart: by the **Data Engineering** team from [QuintoAndar](https://github.com/quintoandar/)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/quintoandar/hierarchical-conf",
    "name": "hierarchical-conf",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7, <4",
    "maintainer_email": "",
    "keywords": "hierarchical-conf,configuration by environment,configuration files,configuration as code,hierarchical configuration",
    "author": "QuintoAndar",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/3d/fb/b004d7e36330a66e8333beb534f3c6a0cea85e1d09284d0fb3a2ca7d8d59/hierarchical_conf-1.0.3.tar.gz",
    "platform": null,
    "description": "# Hierarchical Conf\n_A library for loading configurations (or other metadata) hierarchically based on the current environment_\n\n<img height=\"200\" src=\"hierarchical_conf_logo.png\" />\n\n[![Release](https://img.shields.io/github/v/release/quintoandar/hierarchical-conf)]((https://pypi.org/project/hierarchical-conf/))\n![Python Version](https://img.shields.io/badge/python-3.7%20%7C%203.8-brightgreen.svg)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n| Source    | Downloads                                                                                                       | Page                                                 | Installation Command                       |\n|-----------|-----------------------------------------------------------------------------------------------------------------|------------------------------------------------------|--------------------------------------------|\n| **PyPi**  | [![PyPi Downloads](https://pepy.tech/badge/hierarchical-conf)](https://pypi.org/project/hierarchical-conf/) | [Link](https://pypi.org/project/hierarchical-conf/)        | `pip install hierarchical-conf `                  |\n\n### Build status\n| Develop                                                                     | Stable                                                                            | Documentation                                                                                                                                           | Sonar                                                                                                                                                                                                  |\n|-----------------------------------------------------------------------------|-----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ![Test](https://github.com/quintoandar/hierarchical-conf/workflows/Test/badge.svg) | ![Publish](https://github.com/quintoandar/hierarchical-conf/workflows/Publish/badge.svg) | [![Documentation Status](https://readthedocs.org/projects/hierarchical-conf/badge/?version=latest)](https://hierarchical-conf.readthedocs.io/en/latest/?badge=latest) | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=quintoandar_hierarchical-conf&metric=alert_status)](https://sonarcloud.io/dashboard?id=quintoandar_hierarchical-conf) |\n\n\nThis library supports Python version 3.7+.\n\nTo check library main features you can check [Hierarchical Conf's Documentation](https://hierarchical-conf.readthedocs.io/en/latest/), which is hosted by Read the Docs.\n\n### How to use\n\n#### Short\nAn example of how to use the library getting configurations:\n\n```python\nfrom hierarchical_conf.hierarchical_conf import HierarchicalConf\n\nhierarchical_conf = HierarchicalConf(searched_paths=[PROJECT_ROOT])\nmy_config = hierarchical_conf.get_config(\"my_config_key\")\n```\n\n#### Long\n\nThis tool retrieve the configurations from (YAML) files according to the current\nenvironment and files precedence.\n\nIt receives a list of paths and searches each one for environment configuration files in an **orderly \nfashion**, loading them when found and **overwriting duplicated** configuration keys by the value of the key \navailable in the file loaded at last.\nThe YAML configuration files are expected to be named with prefixes based on the working environment, \nretrieved by the value of a pre-existent operational system environment's variable named `ENVIRONMENT`.\n\n\nE.g.: Given the respective environments `dev` and `production` configuration files below:\n\ndev_conf.yml:\n```yaml\n foo: bar_dev\n foo2: bar_dev2\n```\n\nproduction_conf.yml:\n```yaml\n foo: bar_prod\n foo2: bar_prod2\n```\n\nand given we are at development environment (`ENVIRONMENT=dev`), the following code will load the\nconfiguration file from the development environment file (`/my_path/dev_conf.yml`).\n\n```python\nhconf = HierarchicalConf(conf_files_paths=['/my_path/'])\nfoo_conf = hconf.get_config(\"foo\")\nprint(foo_conf)\n# prints: bar_dev\n```\n\nGiven `ENVIRONMENT=production`, the code above will load the configuration file from\nthe production environment file (`/my_path/production_conf.yml`) and print: `bar_prod`.\n\nTo learn more use cases in practice (and about the keys overwriting), see [Hierarchical Conf examples](https://github.com/quintoandar/hierarchical-conf/tree/main/examples)  \n\n---\n\n## Requirements and Installation\nThe Hierarchical Conf depends on **Python 3.7+**\n\n[Python Package Index](https://pypi.org/project/hierarchical-conf/) hosts reference to a pip-installable module of this library, using it is as straightforward as including it on your project's requirements.\n\n```bash\npip install hierarchical-conf\n```\n\n## License\n[Apache License 2.0](https://github.com/quintoandar/hierarchical-conf/blob/main/LICENSE)\n\n## Contributing\nAll contributions are welcome! Feel free to open Pull Requests. Check the development and contributing **guidelines** \ndescribed in [CONTRIBUTING.md](https://github.com/quintoandar/hierarchical-conf/blob/main/CONTRIBUTING.md)\n\nMade with :heart: by the **Data Engineering** team from [QuintoAndar](https://github.com/quintoandar/)\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A tool for loading settings from files hierarchically",
    "version": "1.0.3",
    "project_urls": {
        "Homepage": "https://github.com/quintoandar/hierarchical-conf"
    },
    "split_keywords": [
        "hierarchical-conf",
        "configuration by environment",
        "configuration files",
        "configuration as code",
        "hierarchical configuration"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aa3ca607cb243eee6686c62d37621016c00ead6bfa30b830f68a094d6d7d8452",
                "md5": "4c8057b892b57b9fb70c32659dd985f8",
                "sha256": "29f9c0bea36b63193001707b392f4c8cfbe934fcc480b3f839cf3a0f7c08e5ff"
            },
            "downloads": -1,
            "filename": "hierarchical_conf-1.0.3-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4c8057b892b57b9fb70c32659dd985f8",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.7, <4",
            "size": 4854,
            "upload_time": "2023-06-14T22:42:16",
            "upload_time_iso_8601": "2023-06-14T22:42:16.921350Z",
            "url": "https://files.pythonhosted.org/packages/aa/3c/a607cb243eee6686c62d37621016c00ead6bfa30b830f68a094d6d7d8452/hierarchical_conf-1.0.3-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3dfbb004d7e36330a66e8333beb534f3c6a0cea85e1d09284d0fb3a2ca7d8d59",
                "md5": "8a5ee52b811a3895da1e4f4f546500c6",
                "sha256": "3231b0a95be8db847c7a8750bd07ddde10649eef34357b5b64490b631ee64637"
            },
            "downloads": -1,
            "filename": "hierarchical_conf-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "8a5ee52b811a3895da1e4f4f546500c6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7, <4",
            "size": 4774,
            "upload_time": "2023-06-14T22:42:18",
            "upload_time_iso_8601": "2023-06-14T22:42:18.820466Z",
            "url": "https://files.pythonhosted.org/packages/3d/fb/b004d7e36330a66e8333beb534f3c6a0cea85e1d09284d0fb3a2ca7d8d59/hierarchical_conf-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-14 22:42:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "quintoandar",
    "github_project": "hierarchical-conf",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "lcname": "hierarchical-conf"
}
        
Elapsed time: 0.11716s