{"id":34020858,"url":"https://github.com/gtors/diggity","last_synced_at":"2026-05-28T01:01:48.998Z","repository":{"id":281549220,"uuid":"858075798","full_name":"gtors/diggity","owner":"gtors","description":"Diggity is a Python library that provides functionality similar to Ruby's dig method.","archived":false,"fork":false,"pushed_at":"2025-05-22T03:28:06.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-15T04:31:51.328Z","etag":null,"topics":["dig","nested-structures","utilities"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/gtors.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-09-16T09:07:00.000Z","updated_at":"2025-05-21T16:55:00.000Z","dependencies_parsed_at":"2025-05-21T17:42:18.416Z","dependency_job_id":null,"html_url":"https://github.com/gtors/diggity","commit_stats":null,"previous_names":["gtors/diggity"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/gtors/diggity","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gtors%2Fdiggity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gtors%2Fdiggity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gtors%2Fdiggity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gtors%2Fdiggity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gtors","download_url":"https://codeload.github.com/gtors/diggity/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gtors%2Fdiggity/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33589684,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["dig","nested-structures","utilities"],"created_at":"2025-12-13T15:28:44.261Z","updated_at":"2026-05-28T01:01:48.967Z","avatar_url":"https://github.com/gtors.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Diggity\n\n**Diggity** is a Python library that provides functionality similar to Ruby's `dig` method.\nIt allows you to traverse nested data structures to extract values using a specified path or return a default value when the traversal is unsuccessful.\n\nAdditionally, it includes `coalesce` and `coalesce_logical` functions for handling optional values and finding the first non-`None` or truthy value in a sequence.\n\n## Features\n- **`dig_path`**: Extract value from nested data structures using dot-separated path.\n- **`dig`**: Extract value from nested data structures using a sequence of keys, indices or attributes provided via `*args`.\n- **`coalesce`**: Returns the first non-`None` value from a sequence of arguments.\n- **`coalesce_logical`**: Returns the first truthy value from a sequence of arguments.\n\n## Installation\n\nTo install **Diggity**, simply run the following command:\n\n```bash\npip install diggity\n```\n\n## Usage\n\n### Extracting Nested Values\n\nYou can extract values from nested data structures in various ways. Below are some examples.\n\n```python\nimport diggity\n\ndata = {\n    \"users\": [\n        {\n            \"name\": \"Alice\",\n            \"age\": 30,\n            \"preferences\": {\n                \"languages\": [\"Python\", \"Rust\", \"Go\"]\n            }\n        },\n    ]\n}\n\n# Extracting a value using a dotted path\nname = diggity.dig_path(data, \"users.0.name\")  # Returns: \"Alice\"\n# Or\nname = diggity.dig(data, \"users\", 0, \"name\")  # Also returns: \"Alice\"\n\n# Extracting a non-existing value, returning None\nhobby = diggity.dig_path(data, \"users.0.hobby\")  # Returns: None\n# Or\nhobby = diggity.dig(data, \"users\", 0, \"hobby\")  # Also returns: None\n\n# Providing a default value for a non-existing path\nhobby_with_default = diggity.dig(data, \"users\", 0, \"hobby\", default=\"No hobby specified\")  # Returns: \"No hobby specified\"\n\n# Using a custom separator\nfavorite_language = diggity.dig_path(data, \"users:0:preferences:languages:0\", sep=\":\")  # Returns: \"Python\"\n```\n\n### Handling Optional Values with `coalesce`\n\nThe `coalesce` function returns the first non-`None` value from a sequence of arguments.\n\n```python\nimport diggity\n\n# Returns the first non-None value\nresult = diggity.coalesce(None, None, 42, None)  # Returns: 42\n\n# Returns None if all values are None\nresult = diggity.coalesce(None, None, None)  # Returns: None\n\n# Works with mixed types\nresult = diggity.coalesce(None, False, 0, \"hello\")  # Returns: False\n```\n\n### Finding the First Truthy Value with `coalesce_logical`\n\nThe `coalesce_logical` function returns the first truthy value from a sequence of arguments.\n\n```python\nimport diggity\n\n# Returns the first truthy value\nresult = diggity.coalesce_logical(None, False, 42, 0)  # Returns: 42\n\n# Returns None if all values are falsy\nresult = diggity.coalesce_logical(None, False, 0, \"\")  # Returns: None\n\n# Works with mixed types\nresult = diggity.coalesce_logical(None, False, \"hello\", 0)  # Returns: \"hello\"\n```\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a pull request or open an issue.\n\n## Acknowledgments\n\nThis project uses [PyO3](https://pyo3.rs/) to bridge Rust and Python. Special thanks to the contributors of the PyO3 library.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgtors%2Fdiggity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgtors%2Fdiggity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgtors%2Fdiggity/lists"}