| Name | yamja JSON |
| Version |
0.2.0
JSON |
| download |
| home_page | None |
| Summary | Opinionated library for handling yaml configuration files and jinja2 templates |
| upload_time | 2025-09-08 20:04:52 |
| maintainer | None |
| docs_url | None |
| author | None |
| requires_python | >=3.12 |
| license | None |
| keywords |
configuration
jinja2
templates
yaml
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# Yamja
WARNING: This is pre-release software.
Yamja is an opinionated library for handling yaml configuration files and jinja2 templates - designed for configuration driven development.
It was created after I've realized that I'm repeating the same pattern in many projects. It's not big (around 100 lines of code) but it offers a consistent and ergonomic way to handle configuration files.
example usage:
```python
cfg = yamja2.load_config("./game_v1.yaml")
character = cfg.lookup('characters.marcus')
game_prompt = cfg.render('game_prompt', character=character)
```
## Features
- Load YAML configuration files
- Use Jinja2 templates within your configuration
- Support for nested configuration lookups using dot notation
- Support for environmental variables overriding lookups
- Support for jinja2 macros
## Installation
```bash
pip install yamja
```
## Usage
### Basic Configuration Loading
```python
from yamja import load_config
# Load a configuration file
config = load_config('config.yaml')
# Access values using dot notation
value = config.lookup('section.subsection.key')
# Access with default value
value = config.lookup('section.subsection.key', default='fallback')
# Access with environmental variable override
value = config.lookup('other_section.key', default=123, env_var='OTHER_KEY', cast=int)
```
### Defaults and precedence
- **Omitting `default` (or passing `...`)**: raises `KeyError` when the key is missing.
- **Precedence**: environment variable (if present) > config value > default.
- **Casting**: `cast` is applied to the selected source (env/config/default).
### Template Rendering
```yaml
# config.yaml
templates:
greeting: "Hello {{ name }}!"
```
```python
# Render a template with variables
greeting = config.render('greeting', name='World')
```
### Including Other Config Files
```yaml
# main.yaml
include:
- common.yaml
- specific.yaml
additional_settings:
key: value
```
## Requirements
- Python >= 3.12
- Jinja2 >= 3.1.4
- PyYAML >= 6.0.2
## License
MIT License - see [LICENSE](LICENSE) for details.
## Links
- [GitHub Repository](https://github.com/mobarski/yamja)
Raw data
{
"_id": null,
"home_page": null,
"name": "yamja",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": "configuration, jinja2, templates, yaml",
"author": null,
"author_email": "mobarski <mobarski@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/c4/52/a8ca47a02d28e0d21f2f654d2ce45e05f97f2a2c6d63dae9df96d4f7587f/yamja-0.2.0.tar.gz",
"platform": null,
"description": "# Yamja\n\nWARNING: This is pre-release software.\n\nYamja is an opinionated library for handling yaml configuration files and jinja2 templates - designed for configuration driven development.\n\nIt was created after I've realized that I'm repeating the same pattern in many projects. It's not big (around 100 lines of code) but it offers a consistent and ergonomic way to handle configuration files.\n\nexample usage:\n```python\ncfg = yamja2.load_config(\"./game_v1.yaml\")\ncharacter = cfg.lookup('characters.marcus')\ngame_prompt = cfg.render('game_prompt', character=character)\n```\n\n\n## Features\n\n- Load YAML configuration files\n- Use Jinja2 templates within your configuration\n- Support for nested configuration lookups using dot notation\n- Support for environmental variables overriding lookups\n- Support for jinja2 macros\n\n## Installation\n\n```bash\npip install yamja\n```\n\n## Usage\n\n### Basic Configuration Loading\n\n```python\nfrom yamja import load_config\n\n# Load a configuration file\nconfig = load_config('config.yaml')\n\n# Access values using dot notation\nvalue = config.lookup('section.subsection.key')\n\n# Access with default value\nvalue = config.lookup('section.subsection.key', default='fallback')\n\n# Access with environmental variable override\nvalue = config.lookup('other_section.key', default=123, env_var='OTHER_KEY', cast=int)\n\n```\n\n### Defaults and precedence\n\n- **Omitting `default` (or passing `...`)**: raises `KeyError` when the key is missing.\n- **Precedence**: environment variable (if present) > config value > default.\n- **Casting**: `cast` is applied to the selected source (env/config/default).\n\n### Template Rendering\n\n```yaml\n# config.yaml\ntemplates:\n greeting: \"Hello {{ name }}!\"\n```\n\n```python\n# Render a template with variables\ngreeting = config.render('greeting', name='World')\n```\n\n\n### Including Other Config Files\n\n```yaml\n# main.yaml\ninclude:\n - common.yaml\n - specific.yaml\n\nadditional_settings:\n key: value\n```\n\n## Requirements\n\n- Python >= 3.12\n- Jinja2 >= 3.1.4\n- PyYAML >= 6.0.2\n\n## License\n\nMIT License - see [LICENSE](LICENSE) for details.\n\n## Links\n\n- [GitHub Repository](https://github.com/mobarski/yamja)\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Opinionated library for handling yaml configuration files and jinja2 templates",
"version": "0.2.0",
"project_urls": {
"Bug Tracker": "https://github.com/mobarski/yamja/issues",
"Documentation": "https://github.com/mobarski/yamja#readme",
"Homepage": "https://github.com/mobarski/yamja",
"Repository": "https://github.com/mobarski/yamja.git"
},
"split_keywords": [
"configuration",
" jinja2",
" templates",
" yaml"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "5c84b1b88f7fea211f0556d370bcc2d53f8b4450e3ca98eac4b36c6e210ce233",
"md5": "c2599246a5908b1193ef70a3d9d12349",
"sha256": "e4758309d95d6748c96b9d2ba6acbf3175a01090ef713f035881ef390d842e85"
},
"downloads": -1,
"filename": "yamja-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c2599246a5908b1193ef70a3d9d12349",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 4787,
"upload_time": "2025-09-08T20:04:51",
"upload_time_iso_8601": "2025-09-08T20:04:51.853823Z",
"url": "https://files.pythonhosted.org/packages/5c/84/b1b88f7fea211f0556d370bcc2d53f8b4450e3ca98eac4b36c6e210ce233/yamja-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "c452a8ca47a02d28e0d21f2f654d2ce45e05f97f2a2c6d63dae9df96d4f7587f",
"md5": "70f9e631c3354dcbddfe0642787350e5",
"sha256": "9b997700cf977bf363fc0533e77269cb038456ddcdfb05f372d490c6075e9c74"
},
"downloads": -1,
"filename": "yamja-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "70f9e631c3354dcbddfe0642787350e5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 15493,
"upload_time": "2025-09-08T20:04:52",
"upload_time_iso_8601": "2025-09-08T20:04:52.818958Z",
"url": "https://files.pythonhosted.org/packages/c4/52/a8ca47a02d28e0d21f2f654d2ce45e05f97f2a2c6d63dae9df96d4f7587f/yamja-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-08 20:04:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mobarski",
"github_project": "yamja",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "yamja"
}