Skip to main content

FindPath is a Python utility class designed to dynamically search for a specific file within a given directory structure.

Project description

FindPath

FindPath provides a structured and safe way to search for files in Python projects without hardcoding absolute paths. This class-based tool starts from the current working directory and moves upward in the directory tree to locate a user-defined root directory. Once the root is found, it scans all files in the directory tree rooted at that location to find the file you're looking for.

Key Features:

  • Automatically navigates to the user-defined root directory.
  • Recursively scans all subdirectories and files from the root.
  • Raises informative exceptions when the root or desired file is not found.
  • Prevents ambiguity by detecting multiple matches of the desired file.
  • Clean, object-oriented design with property validation.

Use Cases:

  • Ideal for structured projects where a specific file (like config, license, or metadata) must be dynamically located.
  • Helpful in deployment scripts, testing frameworks, or automated workflows where relative locations might shift.
from findpath import FindPath

finder = FindPath()
finder.root = "my_project"
file_path = finder.find("test.png")
print(f"File found at: {file_path}")

Exceptions

  • FileNotFoundError: Raised if the root directory or the desired file is not found.
  • ValueError: Raised if multiple files with the same name are found.
  • AttributeError: Raised if required attributes are accessed before being set.

Ideal Use Case

FindPath is ideal for projects that need to dynamically locate configuration files, logs, or other resources in deeply nested directory structures. It is especially useful when the relative or absolute path to a file is unknown, but the file name is known.

Project details


Download files

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

Source Distribution

findpath-1.0.2.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

findpath-1.0.2-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file findpath-1.0.2.tar.gz.

File metadata

  • Download URL: findpath-1.0.2.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for findpath-1.0.2.tar.gz
Algorithm Hash digest
SHA256 548f3f1965601a223f7e28166354cafc91f5206c7217b95e96dc9d0b8ae76761
MD5 58e9fdb3b4dc7684f987e19eb0bd90e8
BLAKE2b-256 609a334200cc71a7948ea6b8ea65a4b35638830bca35b4de748a2300cbf361c7

See more details on using hashes here.

File details

Details for the file findpath-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: findpath-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for findpath-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ff770896fca642b4022847e69b87dd6d5f380c2cf1f14d720dbe747dbb7263a2
MD5 d3573fdf6d6b87e36d78203b8e521bda
BLAKE2b-256 3e0501beea576fc557147e6047fdcf5ee597e4d4802afd23577c81d943d6ed9d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page