{"id":22863896,"url":"https://github.com/shadowy-pycoder/pyya","last_synced_at":"2025-05-04T04:52:32.666Z","repository":{"id":267143119,"uuid":"900364006","full_name":"shadowy-pycoder/pyya","owner":"shadowy-pycoder","description":"Convert YAML configuration files to Python objects","archived":false,"fork":false,"pushed_at":"2025-02-19T08:05:03.000Z","size":43,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-25T11:45:35.029Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/shadowy-pycoder.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}},"created_at":"2024-12-08T15:37:19.000Z","updated_at":"2025-02-19T08:04:26.000Z","dependencies_parsed_at":"2024-12-08T17:23:23.894Z","dependency_job_id":"3f4cbb50-262c-4655-887a-b7a0f90aa5d4","html_url":"https://github.com/shadowy-pycoder/pyya","commit_stats":null,"previous_names":["shadowy-pycoder/paya"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shadowy-pycoder%2Fpyya","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shadowy-pycoder%2Fpyya/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shadowy-pycoder%2Fpyya/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shadowy-pycoder%2Fpyya/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shadowy-pycoder","download_url":"https://codeload.github.com/shadowy-pycoder/pyya/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252122908,"owners_count":21698324,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-12-13T11:17:58.789Z","updated_at":"2025-05-04T04:52:32.649Z","avatar_url":"https://github.com/shadowy-pycoder.png","language":"Python","readme":"# pyya - Simple tool that converts YAML configuration files to Python objects\n\n![PyPI - Downloads](https://img.shields.io/pypi/dd/pyya)\n[![ClickPy Dashboard](https://img.shields.io/badge/clickpy-dashboard-orange)](https://clickpy.clickhouse.com/dashboard/pyya)\n![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/shadowy-pycoder/pyya/total)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyya)\n[![PyPI - Link](https://img.shields.io/badge/pypi-link-blue)](https://pypi.org/project/pyya/)\n![PyPI - Version](https://img.shields.io/pypi/v/pyya)\n![PyPI - Wheel](https://img.shields.io/pypi/wheel/pyya)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\n## Features\n\n- Very `lightweight` and `simple` API (currently it contains only one function)\n- `Easy` to use\n- Based on popular and well-tested libraries (like `camel-converter`, `PyYAML` and `munch`)\n- Automatically `merge` default and production configuration files\n- Convert keys in configuration files to `snake_case`\n\n\n## Installation\n\n```shell\npip install pyya\n```\n\nOr download a specific version from [Releases](https://github.com/shadowy-pycoder/pyya/releases) page and install it with:\n\n```shell    \npip install /path/to/pyya-[version]-py3-none-any.whl\n```\n\n\n## Usage\n\n### Example\n\nCreate YAML configuration files for your project:\n\n```yaml\n# default.config.yaml - this file usually goes to version control system\ndatabase:   \n    host: localhost\n    port: 5432\n    username: postgres\n    password: postgres\n\nredis:\n    host: localhost\n    port: 6379\n```\n\n```yaml\n# config.yaml - this file for production usage\ndatabase:   \n    username: username\n    password: password\n```\n\nImport configuration files in your Python code with `pyya`:\n\n```python\nimport json\n\nfrom pyya import init_config\n\nconfig = init_config(\n    'config.yaml', 'default.config.yaml', \n    merge_configs = True,\n    sections_ignored_on_merge = ['redis'], # do not include redis on your config\n    convert_keys_to_snake_case = False,\n    add_underscore_prefix_to_keywords = False\n    raise_error_non_identifiers = False)\nprint(json.dumps(config))\n\n# Output:\n# {database: {\"host\": \"localhost\", \"port\": 5432, \"username\": \"username\", \"password\": \"password\"}}\n\n```\n\nAs you can see, `pyya` automatically merges default config file with production config file.\n\nUnder the hood `pyya` uses [PyYAML](https://pypi.org/project/PyYAML/) to parse YAML files and [munch](https://pypi.org/project/munch/) library to create attribute-stylish dictionaries.\n\n\n### Flags\n\n```python \n# merge default and production configuration files\n# setting to `False` disables other flags and makes default config optional\n# `False` means \"open config file and apply `ymal.safe_load` and `munchify` with no formatting\"\nmerge_configs=True \n```\n```python\n# list of sections to ignore when merging configs\n# it is useful when you have examples in your default config but do not want to have in the main one\nsections_ignored_on_merge: Optional[List[str]] = None\n```\n```python \n# convert `camelCase` or `PascalCase` keys to `snake_case`\nconvert_keys_to_snake_case=True \n``` \n```python \n# add underscore prefix to keys that are Python keywords\nadd_underscore_prefix_to_keywords=True \n``` \n```python \n# raise error if key name is not valid Python identifier\nraise_error_non_identifiers=True \n```\n\n## Contributing\n\nAre you a developer?\n\n- Fork the repository `https://github.com/shadowy-pycoder/pyya/fork`\n- Clone the repository: `git clone https://github.com/\u003cyour-username\u003e/pyya.git \u0026\u0026 cd pyya`\n- Create your feature branch: `git switch -c my-new-feature`\n- Commit your changes: `git commit -am 'Add some feature'`\n- Push to the branch: `git push origin my-new-feature`\n- Submit a pull request\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshadowy-pycoder%2Fpyya","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshadowy-pycoder%2Fpyya","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshadowy-pycoder%2Fpyya/lists"}