{"id":15533444,"url":"https://github.com/datek/datek-app-utils","last_synced_at":"2025-03-05T19:31:16.391Z","repository":{"id":40577473,"uuid":"427926623","full_name":"DAtek/datek-app-utils","owner":"DAtek","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-27T18:58:11.000Z","size":122,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-24T00:05:28.076Z","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/DAtek.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","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":"2021-11-14T12:48:03.000Z","updated_at":"2024-08-27T18:58:15.000Z","dependencies_parsed_at":"2024-08-27T20:54:30.759Z","dependency_job_id":null,"html_url":"https://github.com/DAtek/datek-app-utils","commit_stats":{"total_commits":21,"total_committers":2,"mean_commits":10.5,"dds":0.04761904761904767,"last_synced_commit":"baf69b73761438e264859ef7a3b256a1037d97a7"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAtek%2Fdatek-app-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAtek%2Fdatek-app-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAtek%2Fdatek-app-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAtek%2Fdatek-app-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DAtek","download_url":"https://codeload.github.com/DAtek/datek-app-utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242091357,"owners_count":20070330,"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-10-02T11:37:03.731Z","updated_at":"2025-03-05T19:31:15.926Z","avatar_url":"https://github.com/DAtek.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![codecov](https://codecov.io/gh/DAtek/datek-app-utils/graph/badge.svg?token=UR0G0I41LD)](https://codecov.io/gh/DAtek/datek-app-utils)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n\u003ca href=\"https://github.com/psf/black/blob/main/LICENSE\"\u003e\u003cimg alt=\"License: MIT\" src=\"https://black.readthedocs.io/en/stable/_static/license.svg\"\u003e\u003c/a\u003e\n\n# Utilities for building applications.\n\n## Contains:\n- Config loading from environment\n- Bootstrap for logging\n- Async timeout decorator, which is very useful for writing async tests\n\n## Examples:\n\n### Env config\n\n```python\nimport os\n\nfrom datek_app_utils.env_config.base import BaseConfig\n\n# Just for demonstration, of course env vars shouldn't be set in python\nos.environ[\"COLOR\"] = \"RED\"\nos.environ[\"TEMPERATURE\"] = \"50\"\nos.environ[\"DISABLE_AUTOTUNE\"] = \"y\"\n\n\nclass Config(BaseConfig):\n    COLOR: str\n    TEMPERATURE: int\n    DISABLE_AUTOTUNE: bool\n\n\nassert Config.COLOR == \"RED\"\nassert Config.TEMPERATURE == 50\nassert Config.DISABLE_AUTOTUNE is True\n```\n\nThe `Config` class casts the values automatically.\nMoreover, you can test whether all the mandatory variables have been set or not.\n\n```python\nimport os\n\nfrom datek_app_utils.env_config.base import BaseConfig\nfrom datek_app_utils.env_config.utils import validate_config\nfrom datek_app_utils.env_config.errors import ValidationError\n\nos.environ[\"COLOR\"] = \"RED\"\nos.environ[\"DISABLE_AUTOTUNE\"] = \"I can't sing but I pretend to be a singer\"\n\n\nclass Config(BaseConfig):\n    COLOR: str\n    TEMPERATURE: int\n    AMOUNT: int = None\n    DISABLE_AUTOTUNE: bool = None\n\n\ntry:\n    validate_config(Config)\nexcept ValidationError as error:\n    for attribute_error in error.errors:\n        print(attribute_error)\n\n```\nOutput:\n```\nDISABLE_AUTOTUNE: Invalid value. Required type: \u003cclass 'bool'\u003e\nTEMPERATURE: Not set. Required type: \u003cclass 'int'\u003e\n```\n\n### Async timeout decorator\n\n```python\nfrom asyncio import sleep, run\nfrom datek_app_utils.async_utils import async_timeout\n\n\n@async_timeout(0.1)\nasync def sleep_one_sec():\n    await sleep(1)\n\n    \nrun(sleep_one_sec())\n\n```\nOutput:\n```\nTimeoutError\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatek%2Fdatek-app-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatek%2Fdatek-app-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatek%2Fdatek-app-utils/lists"}