# Project Title
YAML substitution
## Project Shields
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Supported Python Versions][img_pyversions]][url_pyversions]
[![PyPI Releases][img_pypi]][url_pypi]
[img_pyversions]: https://img.shields.io/pypi/pyversions/yamlsub.svg
[url_pyversions]: https://pypi.python.org/pypi/yamlsub
[img_pypi]: https://img.shields.io/badge/PyPI-wheels-green.svg
[url_pypi]: https://pypi.org/project/yamlsub/#files
## Table of Contents
- [Project Title](#project-title)
- [Project Shields](#project-shields)
- [Table of Contents](#table-of-contents)
- [About ](#about-)
- [Getting Started ](#getting-started-)
- [Prerequisites](#prerequisites)
- [Installing](#installing)
- [Usage ](#usage-)
## About <a name = "about"></a>
A wrapper around the [dotenv](https://pypi.org/project/dotenv/) and [pyaml-env](https://pypi.org/project/pyaml-env/) packages.
## Getting Started <a name = "getting_started"></a>
This project just serves as a wrapper to load environment variables from a .env file, and then update a YAML configuration file with environment variables as needed / required.
It's important to view the documentation for the [pyaml-env](https://pypi.org/project/pyaml-env/) and [dotenv](https://pypi.org/project/dotenv/) projects.
### Prerequisites
* python, version 3.11+
* python's [build package](https://pypi.org/project/build/): ```pip install build```
### Installing
To install using pip:
```
pip install yamlsub
```
To include the package from VCS in a project, you can follow the [pip documentation](https://pip.pypa.io/en/latest/topics/vcs-support/#vcs-support) to import a GitHub project.
For example:
```
pip install yamlsub@git+https://github.com/willmorejg/yamlsub.git
```
## Usage <a name = "usage"></a>
Review the documentation for the [pyaml-env](https://pypi.org/project/pyaml-env/) and [dotenv](https://pypi.org/project/dotenv/) projects for additioanl information on how best to incorporate this project into other projects.
Using an example .env file containing the following ...
```
DB_HOST=localhost
DB_USER=root
DB_PASS=123456
```
... and a sample config.yaml file ...
```
database:
host: !ENV ${DB_HOST}
user: !ENV ${DB_USER}
pass: !ENV ${DB_PASS}
```
... and the following code ...
```
from yamlsub.config import Config
cfg = Config(env_path='.env', yaml_path='config.yaml')
```
, you can access configuration values as follows:
```
database_config = cfg.get_config_key('database')
dbhost = database_config['host']
dbuser = database_config['user']
dbpass = database_config['pass']
print(f'Host: {dbhost}, User: {dbuser}, Pass: {dbpass}')
```
Raw data
{
"_id": null,
"home_page": "https://github.com/willmorejg/yamlsub",
"name": "yamlsub",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.7",
"maintainer_email": null,
"keywords": "yaml, config, environment",
"author": "James G Willmore",
"author_email": "willmorejg@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/0d/60/762c963abfd391df3ad782c3f2b18217d2f332b2b03b691864cc7d3ac519/yamlsub-1.3.8.tar.gz",
"platform": null,
"description": "# Project Title\n\nYAML substitution\n\n## Project Shields\n\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Supported Python Versions][img_pyversions]][url_pyversions]\n[![PyPI Releases][img_pypi]][url_pypi]\n\n[img_pyversions]: https://img.shields.io/pypi/pyversions/yamlsub.svg\n[url_pyversions]: https://pypi.python.org/pypi/yamlsub\n[img_pypi]: https://img.shields.io/badge/PyPI-wheels-green.svg\n[url_pypi]: https://pypi.org/project/yamlsub/#files\n\n## Table of Contents\n\n- [Project Title](#project-title)\n - [Project Shields](#project-shields)\n - [Table of Contents](#table-of-contents)\n - [About ](#about-)\n - [Getting Started ](#getting-started-)\n - [Prerequisites](#prerequisites)\n - [Installing](#installing)\n - [Usage ](#usage-)\n\n## About <a name = \"about\"></a>\n\nA wrapper around the [dotenv](https://pypi.org/project/dotenv/) and [pyaml-env](https://pypi.org/project/pyaml-env/) packages.\n\n## Getting Started <a name = \"getting_started\"></a>\n\nThis project just serves as a wrapper to load environment variables from a .env file, and then update a YAML configuration file with environment variables as needed / required.\n\nIt's important to view the documentation for the [pyaml-env](https://pypi.org/project/pyaml-env/) and [dotenv](https://pypi.org/project/dotenv/) projects.\n\n### Prerequisites\n\n* python, version 3.11+\n* python's [build package](https://pypi.org/project/build/): ```pip install build```\n\n### Installing\n\nTo install using pip:\n```\npip install yamlsub\n```\n\nTo include the package from VCS in a project, you can follow the [pip documentation](https://pip.pypa.io/en/latest/topics/vcs-support/#vcs-support) to import a GitHub project.\n\nFor example:\n```\npip install yamlsub@git+https://github.com/willmorejg/yamlsub.git\n```\n\n## Usage <a name = \"usage\"></a>\nReview the documentation for the [pyaml-env](https://pypi.org/project/pyaml-env/) and [dotenv](https://pypi.org/project/dotenv/) projects for additioanl information on how best to incorporate this project into other projects.\n\nUsing an example .env file containing the following ...\n```\nDB_HOST=localhost\nDB_USER=root\nDB_PASS=123456\n```\n... and a sample config.yaml file ...\n```\ndatabase:\n host: !ENV ${DB_HOST}\n user: !ENV ${DB_USER}\n pass: !ENV ${DB_PASS}\n```\n... and the following code ...\n\n```\nfrom yamlsub.config import Config\n\ncfg = Config(env_path='.env', yaml_path='config.yaml')\n\n```\n, you can access configuration values as follows:\n```\ndatabase_config = cfg.get_config_key('database')\ndbhost = database_config['host']\ndbuser = database_config['user']\ndbpass = database_config['pass']\n\nprint(f'Host: {dbhost}, User: {dbuser}, Pass: {dbpass}')\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "A sample project that uses a YAML config file",
"version": "1.3.8",
"project_urls": {
"Homepage": "https://github.com/willmorejg/yamlsub"
},
"split_keywords": [
"yaml",
" config",
" environment"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bf7a6dd709d3b770402ecde674bcc065d4fe6862d91d7495b706ef5a7a73231f",
"md5": "6e465ee0d74f81af440184c8a04b7d8c",
"sha256": "bcb6dd3fa903f82743a1f65ba9ca68546fcf0e239a6fa99cc8b142b7d51f5233"
},
"downloads": -1,
"filename": "yamlsub-1.3.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6e465ee0d74f81af440184c8a04b7d8c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.7",
"size": 7289,
"upload_time": "2024-03-24T10:05:58",
"upload_time_iso_8601": "2024-03-24T10:05:58.960181Z",
"url": "https://files.pythonhosted.org/packages/bf/7a/6dd709d3b770402ecde674bcc065d4fe6862d91d7495b706ef5a7a73231f/yamlsub-1.3.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0d60762c963abfd391df3ad782c3f2b18217d2f332b2b03b691864cc7d3ac519",
"md5": "9ef34f988ea29c821ef5e9188b8a2ccb",
"sha256": "f8839063b1e93471328c0f50be28b972155283daa0ab4a2416a2239c1165cfd9"
},
"downloads": -1,
"filename": "yamlsub-1.3.8.tar.gz",
"has_sig": false,
"md5_digest": "9ef34f988ea29c821ef5e9188b8a2ccb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.7",
"size": 7407,
"upload_time": "2024-03-24T10:06:00",
"upload_time_iso_8601": "2024-03-24T10:06:00.753109Z",
"url": "https://files.pythonhosted.org/packages/0d/60/762c963abfd391df3ad782c3f2b18217d2f332b2b03b691864cc7d3ac519/yamlsub-1.3.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-24 10:06:00",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "willmorejg",
"github_project": "yamlsub",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "yamlsub"
}