Skip to main content

🔍 Deepfinder

GitHub Pypi Downloads GA

What is Deepfinder?

Deepfinder is a Python library that makes it easy to access nested data in dictionaries, lists, and objects using simple dot notation. Instead of writing complex nested access code, you can use intuitive paths like 'users.0.name' to get the data you need.

Key Features

  • Simple Dot Notation: Access nested data using paths like 'user.profile.name'
  • List Support: Access list items using indices like 'users.0.name'
  • Object Support: Access class attributes and properties using dot notation
  • Wildcard Search: Use * to get all items in a list
  • Smart Null Handling: Use ? to find first non-null value or *? for all non-null values
  • Custom Classes: Built-in support for dictionary, list, and object deep finding capabilities

Path Syntax

Deepfinder uses a simple but powerful path syntax to navigate through your data:

  • . - Access dictionary keys, object attributes, or properties (e.g., 'user.name', 'person.address.city')
  • 0, 1, etc. - Access list items by index (e.g., 'users.0.name')
  • * - Get all items in a list (e.g., 'users.*.name' returns all names)
  • ? - Get first non-null value (e.g., 'users.?.email' returns first non-null email)
  • *? - Get all non-null values (e.g., 'users.*?.email' returns all non-null emails)

When to Use Deepfinder?

Deepfinder is particularly useful when:

  • Working with complex nested JSON data
  • Accessing deeply nested configuration files
  • Processing API responses with multiple levels of nesting
  • Working with data structures that mix dictionaries and lists
  • Accessing nested object attributes and properties
  • Working with complex class hierarchies
  • You need to find specific values in complex data structures or objects

Installation

pip install deepfinder

Quick Start

Basic Dictionary Access

from deepfinder import deep_find

# Example data
user = {
    'name': 'ash',
    'links': {
        'pokehub': '@ash'
    }
}

# Get the pokehub link
result = deep_find(user, 'links.pokehub')
print(result)  # Output: '@ash'

Working with Lists

from deepfinder import deep_find

# Example data with a list of pokemon
user = {
    'name': 'ash',
    'pokemons': [
        {
            'name': 'pikachu',
            'type': 'electric'
        },
        {
            'name': 'charmander',
            'type': 'fire'
        }
    ]
}

# Get pikachu's name (first pokemon)
result = deep_find(user, 'pokemons.0.name')
print(result)  # Output: 'pikachu'

# Get all pokemon names
result = deep_find(user, 'pokemons.*.name')
print(result)  # Output: ['pikachu', 'charmander']

Working with Objects

from deepfinder import deep_find

class Address:
    def __init__(self, city, country):
        self.city = city
        self.country = country

class User:
    def __init__(self, name, address):
        self.name = name
        self.address = address

# Create nested objects
address = Address('Pallet Town', 'Kanto')
user = User('Ash', address)

# Access nested object attributes
result = deep_find(user, 'address.city')
print(result)  # Output: 'Pallet Town'

Finding First Non-Null Value

Use ? to get the first non-null value in a list:

user = {
    'pokemons': [
        {'name': 'pikachu'},  # no ball
        {'name': 'charmander', 'ball': 'superball'},  # has ball
        {'name': 'lucario', 'ball': 'ultraball'}  # has ball
    ]
}

# Get the first pokemon that has a ball
result = deep_find(user, 'pokemons.?.ball')
print(result)  # Output: 'superball'

Finding All Non-Null Values

Use *? to get all non-null values in a list:

user = {
    'pokemons': [
        {'name': 'pikachu'},  # no ball
        {'name': 'charmander', 'ball': 'superball'},  # has ball
        {'name': 'lucario', 'ball': 'ultraball'}  # has ball
    ]
}

# Get all pokemon balls
result = deep_find(user, 'pokemons.*?.ball')
print(result)  # Output: ['superball', 'ultraball']

Using Custom Classes

Deepfinder provides custom classes that make it even easier to work with nested data:

DeepFinderDict

from deepfinder.entity import DeepFinderDict

# Create a dictionary with built-in deep finding
user = DeepFinderDict({
    'name': 'ash',
    'pokemons': [
        {'name': 'pikachu'},
        {'name': 'charmander', 'ball': 'superball'}
    ]
})

# Use the deep_find method directly on the dictionary
result = user.deep_find('pokemons.?.ball')
print(result)  # Output: 'superball'

DeepFinderList

from deepfinder.entity import DeepFinderList

# Create a list with built-in deep finding
users = DeepFinderList([{
    'name': 'ash',
    'pokemons': [
        {'name': 'pikachu'},
        {'name': 'charmander', 'ball': 'superball'}
    ]
}])

# Use the deep_find method directly on the list
result = users.deep_find('0.pokemons.?.ball')
print(result)  # Output: 'superball'

Contributing

Contributions are welcome! Feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deepfinder-1.5.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deepfinder-1.5.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file deepfinder-1.5.1.tar.gz.

File metadata

  • Download URL: deepfinder-1.5.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for deepfinder-1.5.1.tar.gz
Algorithm Hash digest
SHA256 c87add90ebb47d5c03b900c28445abe65ef1249fe9aed11a10aeda910e08c68e
MD5 43c76dc2eb14196bd91be75b9869eb4f
BLAKE2b-256 1fd01e819fd1bde3fea10097fa5084ccef76f267c60b732f1481b44244235ad3

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepfinder-1.5.1.tar.gz:

Publisher: publish.yml on otsobide/deepfinder.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deepfinder-1.5.1-py3-none-any.whl.

File metadata

  • Download URL: deepfinder-1.5.1-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for deepfinder-1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b38b05e5e69e10658b478fa365534ccf1a957eb5c6b7546851d93ce6fc16606c
MD5 5a95a0d60fb62e63b54399b0214ad510
BLAKE2b-256 686aadeebfb8be9ba8df646d7cb5e13da2808acdf97542eeebea3da4ca808661

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepfinder-1.5.1-py3-none-any.whl:

Publisher: publish.yml on otsobide/deepfinder.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.6.0

2 files

This release

1.5.1 This release

2 files

1.5.0

2 files

1.4.10

2 files

1.4.2

2 files

1.4.1

2 files

1.4.0

2 files

1.3.1

2 files

1.3.0

2 files

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.1

2 files

0.1.0

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page