{"id":37065899,"url":"https://github.com/cs0ip/toya","last_synced_at":"2026-01-14T07:43:47.194Z","repository":{"id":300475590,"uuid":"1006275951","full_name":"cs0ip/toya","owner":"cs0ip","description":"Configuration management with deferred binding and value templating","archived":false,"fork":false,"pushed_at":"2025-06-23T09:28:05.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-01T05:03:02.030Z","etag":null,"topics":["config","environment","python","python3","template","yaml"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cs0ip.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-21T22:18:14.000Z","updated_at":"2025-06-29T16:45:42.000Z","dependencies_parsed_at":"2025-06-21T23:35:27.202Z","dependency_job_id":null,"html_url":"https://github.com/cs0ip/toya","commit_stats":null,"previous_names":["cs0ip/toya"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cs0ip/toya","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cs0ip%2Ftoya","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cs0ip%2Ftoya/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cs0ip%2Ftoya/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cs0ip%2Ftoya/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cs0ip","download_url":"https://codeload.github.com/cs0ip/toya/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cs0ip%2Ftoya/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28413476,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T05:26:33.345Z","status":"ssl_error","status_checked_at":"2026-01-14T05:21:57.251Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["config","environment","python","python3","template","yaml"],"created_at":"2026-01-14T07:43:46.556Z","updated_at":"2026-01-14T07:43:47.180Z","avatar_url":"https://github.com/cs0ip.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Toya\n\n\u003c!-- TOC --\u003e\n* [EN](#en)\n  * [Project Integration](#project-integration)\n  * [Usage Example](#usage-example)\n    * [Explanation](#explanation)\n* [RU](#ru)\n  * [Подключение в проект](#подключение-в-проект-)\n  * [Пример использования](#пример-использования)\n    * [Пояснение](#пояснение)\n\u003c!-- TOC --\u003e\n\n## EN\nA minimalistic library for flexible configuration reading.\n\nAllows using the Jinja templating engine.\n\nValues are evaluated lazily, after complete reading and merging of all configuration sources.\n\n## Project Integration\n\nModule name: `toya`\n\nExample integration with Rye:\n```commandline\nrye add toya\n```\n\n## Usage Example\n\n`test4.yaml`:\n```yaml \nc1: v1\nc2: v2\nc3:\n  c31: v31\n  c32: v32\n  c33: !t \"{{ _.c1 }}/{{ _.c2 }}/{{ c31 }}/{{ c32 }}\"\n```\n\nEnvironment:\n```dotenv\nAPP__C2=e2\nAPP__C3__C32=e32\n```\n\nCode:\n```python\nfrom pathlib import Path\nfrom typing import Any, MutableMapping\n\nfrom toya.config import load_and_eval_config\nfrom toya.supplier.env_supplier import EnvSupplier\nfrom toya.supplier.mapping_supplier import MappingSupplier\nfrom toya.supplier.yaml_supplier import YamlSupplier\nfrom toya.tpl import create_tpl_type\n\nyaml_supplier = YamlSupplier(Path(\"test4.yaml\"))\nenv_supplier = EnvSupplier()\n\ntpl_type = create_tpl_type()\nmapping_supplier = MappingSupplier({\n    \"c3\": {\n        \"c32\": tpl_type(\"{{ _.c1 }}@{{ c31 }}\")\n    },\n})\n\ncfg: MutableMapping[str, Any] = load_and_eval_config([yaml_supplier, env_supplier, mapping_supplier])\n\nassert cfg[\"c3\"][\"c33\"] == \"v1/e2/v31/v1@v31\"\n```\n\n### Explanation\nConfiguration is read from the specified sources sequentially.\nA source specified later overwrites values from sources\nspecified earlier.\n\nThen the evaluation of values specified with the\n`!t` tag occurs (the tag can be specified during initialization). Values are evaluated\nsequentially, from top to bottom.\n\nIn templates, you can use all Jinja capabilities. Additionally, you can\nreference other variables.\n- If a variable name is specified without prefixes, it is considered to be a\n  variable from the same group. For example, `c33` references `c31`\n  without a prefix.\n- If you need to reference an arbitrary variable, you need to specify the full\n  path to it, using the `_` prefix as the root element. For example, `c33`\n  references `c1` by specifying the full path `_.c1`. The variable\n  `c33` itself will have the full path `_.c3.c33`.\n\nThe result is returned as a dictionary. It can be used, for example,\nwith Pydantic:\n```python\nfrom pydantic import BaseModel\n\nclass Config(BaseModel):\n    \n    c1: str\n    c2: str\n  \n    class C3(BaseModel):\n          c33: str\n\n    c3: C3\n    \nraw_cfg = load_and_eval_config([yaml_supplier, env_supplier, mapping_supplier])\ncfg = Config.model_validate(raw_cfg)\n```\n\n## RU\nМинималистичная библиотека для гибкого чтения конфигурации.\n\nПозволяется использовать шаблонизатор Jinja.\n\nЗначения вычисляются отложено, после полного прочтения и слияния всех источников конфигурации.  \n\n## Подключение в проект \n\nИмя модуля: `toya`\n\nПример подключения в Rye:\n```commandline\nrye add toya\n```\n\n## Пример использования\n\n`test4.yaml`:\n```yaml \nc1: v1\nc2: v2\nc3:\n  c31: v31\n  c32: v32\n  c33: !t \"{{ _.c1 }}/{{ _.c2 }}/{{ c31 }}/{{ c32 }}\"\n```\n\nEnvironment:\n```dotenv\nAPP__C2=e2\nAPP__C3__C32=e32\n```\n\nCode:\n```python\nfrom pathlib import Path\nfrom typing import Any, MutableMapping\n\nfrom toya.config import load_and_eval_config\nfrom toya.supplier.env_supplier import EnvSupplier\nfrom toya.supplier.mapping_supplier import MappingSupplier\nfrom toya.supplier.yaml_supplier import YamlSupplier\nfrom toya.tpl import create_tpl_type\n\nyaml_supplier = YamlSupplier(Path(\"test4.yaml\"))\nenv_supplier = EnvSupplier()\n\ntpl_type = create_tpl_type()\nmapping_supplier = MappingSupplier({\n    \"c3\": {\n        \"c32\": tpl_type(\"{{ _.c1 }}@{{ c31 }}\")\n    },\n})\n\ncfg: MutableMapping[str, Any] = load_and_eval_config([yaml_supplier, env_supplier, mapping_supplier])\n\nassert cfg[\"c3\"][\"c33\"] == \"v1/e2/v31/v1@v31\"\n```\n\n### Пояснение\nКонфигурация читается из указанных источников последовательно.\nИсточник, указанный позже, перезаписывает значения источников, \nуказанных раньше.\n\nДалее происходит вычисление значений, указанных с тегом\n`!t` (тег можно указать при инициализации). Значения вычисляются\nпоследовательно, сверху вниз.\n\nВ шаблонах можно использовать все возможности Jinja. Кроме того можно\nссылаться на другие переменные. \n- Если имя переменной указано без префиксов, то считается, что это \n  переменная из той же группы. Например, `c33` обращается к `с31`\n  без префикса.\n- Если нужно обратиться к произвольной переменной, то нужно указать полный\n  путь к ней, используя префикс `_` как корневой элемент. Например, `c33`\n  обращается к `c1` с указанием полного пути `_.c1`. Сама переменная \n  `с33` будет иметь полный путь `_.c3.c33`.\n\nРезультат возвращается в виде словаря. Его можно использовать, например, \nс Pydantic:\n```python\nfrom pydantic import BaseModel\n\nclass Config(BaseModel):\n    \n    c1: str\n    c2: str\n  \n    class C3(BaseModel):\n          c33: str\n\n    c3: C3\n    \nraw_cfg = load_and_eval_config([yaml_supplier, env_supplier, mapping_supplier])\ncfg = Config.model_validate(raw_cfg)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcs0ip%2Ftoya","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcs0ip%2Ftoya","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcs0ip%2Ftoya/lists"}