<h1 align="center">🔍 Deepfinder </h1>
<div align="center">
![](https://img.shields.io/badge/PRs-welcome-green.svg)
[![GitHub](https://img.shields.io/github/license/jparadadev/deepfinder.py)](https://github.com/jparadadev/deepfinder.py/blob/main/LICENSE)
[![Pypi](https://img.shields.io/pypi/v/deepfinder)](https://pypi.org/project/deepfinder/)
[![Downloads](https://pepy.tech/badge/deepfinder)](https://pepy.tech/project/deepfinder)
[![GA](https://github.com/jparadadev/deepfinder.py/workflows/Tests/badge.svg)](https://github.com/jparadadev/deepfinder.py/actions/workflows/test.yml)
</div>
![](https://raw.githubusercontent.com/jparadadev/deepfinder.py/assets/assets/logo.png)
Search attributes easily using dot paths. Within structures of type dictionary, list and embedded substructures with simple format 'dict.users.0.name'.
## Getting Started
### Installation
```Shell
pip install deepfinder
```
### Usage
#### Basic sample
```python
from deepfinder import deep_find
user: dict = {
'name': 'ash',
'links': {
'pokehub': '@ash'
},
}
print(deep_find(user, 'links.pokehub'))
# output: '@ash'
```
#### List sample
```python
from deepfinder import deep_find
user: dict = {
'name': 'ash',
'pokemons': [
{
'name': 'pikachu',
'type': 'electric'
},
{
'name': 'charmander',
'type': 'fire'
}
]
}
print(deep_find(user, 'pokemons.0.name'))
# output: 'pikachu'
```
#### List all result sample
```python
from deepfinder import deep_find
user: dict = {
'name': 'ash',
'pokemons': [
{
'name': 'pikachu',
'type': 'electric'
},
{
'name': 'charmander',
'type': 'fire'
}
]
}
print(deep_find(user, 'pokemons.*.name'))
# output: ['pikachu', 'charmander']
```
#### Find the first non-null result
```python
from deepfinder import deep_find
user: dict = {
'name': 'ash',
'pokemons': [
{
'name': 'pikachu',
},
{
'name': 'charmander',
'ball': 'superball'
}
]
}
print(deep_find(user, 'pokemons.?.ball'))
# output: 'superball'
```
#### Find all non-null results
```python
from deepfinder import deep_find
user: dict = {
'name': 'ash',
'pokemons': [
{
'name': 'pikachu',
},
{
'name': 'charmander',
'ball': 'superball'
},
{
'name': 'lucario',
'ball': 'ultraball'
}
]
}
print(deep_find(user, 'pokemons.*?.ball'))
# output: ['superball', 'ultraball']
```
### Use custom dict and list
```python
from deepfinder.entity import DeepFinderDict
user: dict = DeepFinderDict({
'name': 'ash',
'pokemons': [
{
'name': 'pikachu'
},
{
'name': 'charmander',
'ball': 'superball'
}
]
})
print(user.deep_find('pokemons.?.ball'))
# output: 'superball'
```
```python
from deepfinder.entity import DeepFinderList
users: list = DeepFinderList([{
'name': 'ash',
'pokemons': [
{
'name': 'pikachu'
},
{
'name': 'charmander',
'ball': 'superball'
}
]
}])
print(users.deep_find('0.pokemons.?.ball'))
# output: 'superball'
```
Raw data
{
"_id": null,
"home_page": "https://github.com/jparadadev/deepfinder.py",
"name": "deepfinder",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "find,get,dictionary,list,array,deep,find,structure,nested,nested,data",
"author": "Javier Parada",
"author_email": "javierparadadev@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/aa/f4/60f8f5f59f87d18abcc23252b3d0c012191235931ef29f55ea2ba1888b22/deepfinder-1.4.2.tar.gz",
"platform": "any",
"description": "<h1 align=\"center\">\ud83d\udd0d Deepfinder </h1>\n\n<div align=\"center\">\n\n![](https://img.shields.io/badge/PRs-welcome-green.svg)\n[![GitHub](https://img.shields.io/github/license/jparadadev/deepfinder.py)](https://github.com/jparadadev/deepfinder.py/blob/main/LICENSE)\n[![Pypi](https://img.shields.io/pypi/v/deepfinder)](https://pypi.org/project/deepfinder/)\n[![Downloads](https://pepy.tech/badge/deepfinder)](https://pepy.tech/project/deepfinder)\n[![GA](https://github.com/jparadadev/deepfinder.py/workflows/Tests/badge.svg)](https://github.com/jparadadev/deepfinder.py/actions/workflows/test.yml)\n \n</div>\n\n![](https://raw.githubusercontent.com/jparadadev/deepfinder.py/assets/assets/logo.png)\n\nSearch attributes easily using dot paths. Within structures of type dictionary, list and embedded substructures with simple format 'dict.users.0.name'.\n\n## Getting Started\n\n### Installation\n\n```Shell\n pip install deepfinder\n```\n\n### Usage\n\n#### Basic sample\n\n```python\nfrom deepfinder import deep_find\nuser: dict = {\n 'name': 'ash',\n 'links': {\n 'pokehub': '@ash'\n },\n}\nprint(deep_find(user, 'links.pokehub'))\n# output: '@ash'\n```\n\n#### List sample\n\n```python\nfrom deepfinder import deep_find\nuser: dict = {\n 'name': 'ash',\n 'pokemons': [\n {\n 'name': 'pikachu',\n 'type': 'electric'\n },\n {\n 'name': 'charmander',\n 'type': 'fire'\n }\n ]\n}\nprint(deep_find(user, 'pokemons.0.name'))\n# output: 'pikachu'\n```\n\n#### List all result sample\n\n```python\nfrom deepfinder import deep_find\nuser: dict = {\n 'name': 'ash',\n 'pokemons': [\n {\n 'name': 'pikachu',\n 'type': 'electric'\n }, \n {\n 'name': 'charmander',\n 'type': 'fire'\n }\n ]\n}\nprint(deep_find(user, 'pokemons.*.name'))\n# output: ['pikachu', 'charmander']\n```\n\n#### Find the first non-null result\n\n```python\nfrom deepfinder import deep_find\nuser: dict = {\n 'name': 'ash',\n 'pokemons': [\n {\n 'name': 'pikachu',\n },\n {\n 'name': 'charmander',\n 'ball': 'superball'\n }\n ]\n}\nprint(deep_find(user, 'pokemons.?.ball'))\n# output: 'superball'\n```\n\n#### Find all non-null results\n\n```python\nfrom deepfinder import deep_find\nuser: dict = {\n 'name': 'ash',\n 'pokemons': [\n {\n 'name': 'pikachu',\n },\n {\n 'name': 'charmander',\n 'ball': 'superball'\n },\n {\n 'name': 'lucario',\n 'ball': 'ultraball'\n }\n ]\n}\nprint(deep_find(user, 'pokemons.*?.ball'))\n# output: ['superball', 'ultraball']\n```\n\n\n\n### Use custom dict and list\n\n```python\nfrom deepfinder.entity import DeepFinderDict\nuser: dict = DeepFinderDict({\n 'name': 'ash',\n 'pokemons': [\n {\n 'name': 'pikachu'\n },\n {\n 'name': 'charmander',\n 'ball': 'superball'\n }\n ]\n})\nprint(user.deep_find('pokemons.?.ball'))\n# output: 'superball'\n```\n\n```python\nfrom deepfinder.entity import DeepFinderList\nusers: list = DeepFinderList([{\n 'name': 'ash',\n 'pokemons': [\n {\n 'name': 'pikachu'\n }, \n {\n 'name': 'charmander',\n 'ball': 'superball'\n }\n ]\n}])\nprint(users.deep_find('0.pokemons.?.ball'))\n# output: 'superball'\n```\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Search attributes easily using dot paths. Within structures of type dictionary, list and embedded substructures with simple format 'dict.users.0.name'.",
"version": "1.4.2",
"project_urls": {
"Bug Tracker": "https://github.com/jparadadev/deepfinder.py/issues",
"Homepage": "https://github.com/jparadadev/deepfinder.py"
},
"split_keywords": [
"find",
"get",
"dictionary",
"list",
"array",
"deep",
"find",
"structure",
"nested",
"nested",
"data"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "719da401858767e2a82d1f8a3243e3a4c75bc9402eb4530b5523d6a5e2339602",
"md5": "d43500e919f96633ab3733673325b290",
"sha256": "75d0a6ee602de34fb05945012b4ada515330fa7ee46b39c7a45b2163e96f774d"
},
"downloads": -1,
"filename": "deepfinder-1.4.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d43500e919f96633ab3733673325b290",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 4234,
"upload_time": "2023-05-31T08:03:14",
"upload_time_iso_8601": "2023-05-31T08:03:14.356716Z",
"url": "https://files.pythonhosted.org/packages/71/9d/a401858767e2a82d1f8a3243e3a4c75bc9402eb4530b5523d6a5e2339602/deepfinder-1.4.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "aaf460f8f5f59f87d18abcc23252b3d0c012191235931ef29f55ea2ba1888b22",
"md5": "4bad37e881013ce3acbef4785680a3ee",
"sha256": "67582207b32cefc22ada02e4003daccc0f10cbfdfac2c3aad30f170e15106e91"
},
"downloads": -1,
"filename": "deepfinder-1.4.2.tar.gz",
"has_sig": false,
"md5_digest": "4bad37e881013ce3acbef4785680a3ee",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 3742,
"upload_time": "2023-05-31T08:03:15",
"upload_time_iso_8601": "2023-05-31T08:03:15.659505Z",
"url": "https://files.pythonhosted.org/packages/aa/f4/60f8f5f59f87d18abcc23252b3d0c012191235931ef29f55ea2ba1888b22/deepfinder-1.4.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-31 08:03:15",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jparadadev",
"github_project": "deepfinder.py",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "deepfinder"
}