{"id":24016452,"url":"https://github.com/zechcodes/nubby","last_synced_at":"2026-01-21T09:02:07.172Z","repository":{"id":262627533,"uuid":"864664924","full_name":"ZechCodes/Nubby","owner":"ZechCodes","description":"Config loader that injects configs using Bevy.","archived":false,"fork":false,"pushed_at":"2025-04-02T01:43:36.000Z","size":689,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T14:14:14.986Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","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/ZechCodes.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":"2024-09-28T20:32:26.000Z","updated_at":"2025-04-02T01:42:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"8393e814-70db-452a-8ae0-21008c8d2451","html_url":"https://github.com/ZechCodes/Nubby","commit_stats":null,"previous_names":["zechcodes/nubby"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ZechCodes/Nubby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZechCodes%2FNubby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZechCodes%2FNubby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZechCodes%2FNubby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZechCodes%2FNubby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZechCodes","download_url":"https://codeload.github.com/ZechCodes/Nubby/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZechCodes%2FNubby/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28630938,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"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":[],"created_at":"2025-01-08T08:51:27.165Z","updated_at":"2026-01-21T09:02:02.159Z","avatar_url":"https://github.com/ZechCodes.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nubby\n\nA simple config loader for Python using Bevy for dependency injection. You just need to create a model, declare what\nfile name it should look for, and mark that model as a dependency wherever you need to have it made available.\n\n## Installation\n\n```bash\npip install nubby\n```\n\nYou can optionally install the `toml` or `yaml` extras to support those file formats.\n\n```bash\npip install nubby[toml]\npip install nubby[yaml]\n```\n\nOut of the box Nubby will use `tomllib` to read TOML files but the `toml` extra installs the `tomlkit` package which\nallows writing to TOML files.\n\n## Usage\n\nNubby is designed to have the smallest possible API surface area. You just need to create a model type that implements\nthe `SectionModel` interface and declare the file name it should look for. Then you can inject that model wherever you\nneed it using Bevy.\n\nThe file name shouldn't include the file extension. Nubby's file handlers look for supported file extensions in the\nsearch paths. By default, the current working directory is the only search path. You can add more paths using the\n`nubby.get_active_controller().add_path` method. It is also possible to add more file handlers using the\n`nubby.get_active_controller().add_handler` method.\n\nHere's a basic example of loading a model from a file:\n\n```python\nfrom dataclasses import dataclass\nfrom bevy import inject, dependency\nfrom nubby.models import new_file_model\n\n\nfile_definition = new_file_model(\"person_info\")\n\n@file_definition.section(\"person\")\n@dataclass\nclass Person:\n    name: str\n    age: int\n\n\n@inject\ndef print_person_details(person: Person = dependency()):\n    print(f\"{person.name} is {person.age} years old\")\n```\n\nRunning `print_person_details()` prints the name and age of the person loaded from the `person` section of the `person_info` file.\nDepending on the available file handlers it could be a json, toml, or yaml file.\n\nNote that it is not necessary to pass anything to the `print_person_details` function. Nubby uses Bevy to automatically inject the\n`Person` model and loads the appropriate config file.\n\nTo save any modifications to a model just call the active controller's `save` method, passing it the updated model:\n\n```python\nfrom nubby import get_active_controller\n\n# After modifying the person model\nperson.age = 32\nget_active_controller().save(person)\n```\n\nThe `save` method will update the in-memory cache as well as the file on disk. It will not update any models that have\nalready been created.\n\n### Name Normalization\n\nBy default, section names in config files match the class name. You can customize this behavior:\n\n```python\n# Use snake_case for section names\nfile_definition = new_file_model(\"config\", generate_normalized_names=True)\n\n@file_definition.section()  # Will use \"user_profile\" as the section name key in the config file\n@dataclass\nclass UserProfile:\n    username: str\n    email: str\n```\n\n## Supported File Formats\n\nNubby supports the following file formats out of the box:\n\n- JSON (`.json`)\n- TOML (`.toml`) - requires `tomlkit` for writing\n- YAML (`.yaml`, `.yml`) - requires `pyyaml`\n\n## License\n\nNubby is made available under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzechcodes%2Fnubby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzechcodes%2Fnubby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzechcodes%2Fnubby/lists"}