{"id":21849250,"url":"https://github.com/pasaopasen/py-env-parser","last_synced_at":"2025-03-15T15:42:31.963Z","repository":{"id":195358906,"uuid":"692761644","full_name":"PasaOpasen/py-env-parser","owner":"PasaOpasen","description":"environment to python dictionary parser util","archived":false,"fork":false,"pushed_at":"2025-01-09T08:52:17.000Z","size":45,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-23T11:05:19.883Z","etag":null,"topics":["converter","environment","environment-variables","pypi-package","python","python-utility","syntax"],"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/PasaOpasen.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":"2023-09-17T14:04:31.000Z","updated_at":"2025-01-13T09:36:19.000Z","dependencies_parsed_at":"2023-09-17T16:28:40.512Z","dependency_job_id":"cef8abd6-529c-4500-a910-b0ec65ba40fa","html_url":"https://github.com/PasaOpasen/py-env-parser","commit_stats":null,"previous_names":["pasaopasen/py-env-parser"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PasaOpasen%2Fpy-env-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PasaOpasen%2Fpy-env-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PasaOpasen%2Fpy-env-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PasaOpasen%2Fpy-env-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PasaOpasen","download_url":"https://codeload.github.com/PasaOpasen/py-env-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243753995,"owners_count":20342537,"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":["converter","environment","environment-variables","pypi-package","python","python-utility","syntax"],"created_at":"2024-11-28T00:12:00.344Z","updated_at":"2025-03-15T15:42:31.939Z","avatar_url":"https://github.com/PasaOpasen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![PyPI version](https://badge.fury.io/py/env2dict.svg)](https://pypi.org/project/env2dict/)\n[![Downloads](https://pepy.tech/badge/env2dict)](https://pepy.tech/project/env2dict)\n[![Downloads](https://pepy.tech/badge/env2dict/month)](https://pepy.tech/project/env2dict)\n[![Downloads](https://pepy.tech/badge/env2dict/week)](https://pepy.tech/project/env2dict)\n\n- [Environment to python dictionary parser util](#environment-to-python-dictionary-parser-util)\n  - [About](#about)\n  - [Syntax](#syntax)\n  - [Examples](#examples)\n  - [How to use](#how-to-use)\n  - [More info](#more-info)\n\n\n# Environment to python dictionary parser util\n\n```sh\npip install env2dict\n```\n\n## About\n\nThis small package provides an ability of easy setting/overriding Python variables from environment. It is expected that u will use it to override your configuration data without changing configuration files itself, what is especially useful for containers-oriented applications.\n\n## Syntax\n\nTo use it, u need to define environment variables matches the pattern: **Prefix***Body***OperationSuffix** where:\n* **Prefix** is any word to determine target variables; for instance, `DD` prefix means to use only variables starts with `DD`; can be empty, what means to select all available variables (not recommended) \n* *Body* is the name of the target configuration parameter\n* **OperationSuffix** is the one of next available suffixes (by default, but u can change your defaults):\n  * `_NUMBER` to convert variable value to integer (environment variables are always strings)\n  * `_FLOAT` to convert variable value to float\n  * `_FLAG` to convert variable value to `optional[boolean]` at that values:\n    *  `1`/`yes`/`Yes`/`True`/`true` equal `true`\n    *  `0`/`no`/`No`/`False`/`false` equal `false`\n    *  `None`/`null`/`NULL` equal `null`\n  * `_LIST` means to parse variable value to string list\n  * `_LIST_APPEND` means to parse variable value to string list and append to existing list instead of override\n  * `_JSON` means to parse variable value as json string\n  * no suffix means that no conversion will be performed, so variable value will stay a string\n\nMoreover, u can put nested dicts values using `__` separator (or other on your choice) in the environment variable name.\n\nNote also that u can combine these suffixes to perform more complicated transformations.\n\n## Examples\n\n* env variable `DD_S_COUNT_NUMBER=10` (with prefix `DD_` conversation) will be converted to `S_COUNT=10` Python object\n* `DD_S_COUNT=10` 🠚 `S_COUNT=\"10\"`\n* `DD_USE_THIS_FLAG=yes` 🠚 `USE_THIS=True`\n* `DD_USE_THIS_FLAG=true` 🠚 `USE_THIS=True`\n* `DD_USE_THIS_FLAG=no` 🠚 `USE_THIS=False`\n* `DD_ALLOWED_HOSTS_LIST_APPEND=127.0.0.1;dev.ocr.com;dev.web.com` will append a list `['127.0.0.1', 'dev.ocr.com', 'dev.web.com']` to `ALLOWED_HOSTS` variable\n* `DD_READ_ME_JSON={\\\"a\\\": 1, \\\"b\\\": [1, 2]}` will be translated to `READ_ME={'a': 1, 'b': [1, 2]}`\n* `DD_SOME_DICT__KEY1__KEY2=postgres` will create a dictionary `SOME_DICT={'KEY1': {'KEY2': 'postgres'}}` if it doesn't exist and will add a field in existing dictionary by aforementioned route\n* `DD_A__B_LIST_APPEND_JSON=[1, 2, 3, [1, 2, \\\"3\\\"]]` will append `[1, 2, 3, [1, 2, \"3\"]]` to the end of value `V` from `A={\"B\": V}`\n\n## How to use\n\n```python\nfrom env2dict import parse_vars\n\nnew_vars = parse_vars(\n    prefix='DD_',\n    initial_vars=None,\n    source=None\n)\n```\n\n## More info\n\nPlease take a look at: \n* `parse_vars` function docstring\n* `tests` directory of this package repo.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpasaopasen%2Fpy-env-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpasaopasen%2Fpy-env-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpasaopasen%2Fpy-env-parser/lists"}