Search attributes easily within structures of type dictionary, list and embedded substructures with simple format "dict.users.0.name".
Project description
Deep finder
Search attributes easily within structures of type dictionary, list and embedded substructures with simple format 'dict.users.0.name'.
Getting Started
Installation
pip install deepfinder
Usage
Basic sample
from deepfinder import deep_find
user: dict = {
'name': 'ash',
'links': {
'pokehub': '@ash',
},
}
print(deep_find(user, 'links.pokehub'))
# output: '@ash'
List sample
from deepfinder import deep_find
user: dict = {
'name': 'ash',
'pokemons': [{
'name': 'pikachu',
}, {
'name': 'charmander',
}]
}
print(deep_find(user, 'pokemons.0.name'))
# output: 'pikachu'
List all result sample
from deepfinder import deep_find
user: dict = {
'name': 'ash',
'pokemons': [{
'name': 'pikachu',
}, {
'name': 'charmander',
}]
}
print(deep_find(user, 'pokemons.*.name'))
# output: ['pikachu', 'charmander']
List and not null result sample
from deepfinder import deep_find
user: dict = {
'name': 'ash',
'pokemons': [{
'name': 'pikachu',
}, {
'name': 'charmander',
'ball': 'superball',
}]
}
print(deep_find(user, 'pokemons.?.ball'))
# output: 'superball'
Use custom dict and list
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'
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'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
deepfinder-0.1.3.tar.gz
(3.2 kB
view hashes)
Built Distribution
Close
Hashes for deepfinder-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33cbe26f1e56d391a6f6bcac124b82b8a33d3c90140b89d1b14fcd21acfa40c0 |
|
MD5 | 33981ebd7cd0ae4d473d6e8f6a4ea900 |
|
BLAKE2b-256 | 5effa773729dd138409f72e28f167c287824c5f570e8c9b2b72a506b948a4e48 |