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.0.tar.gz (4.5 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.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: findpath-1.0.0.tar.gz
  • Upload date:
  • Size: 4.5 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.0.tar.gz
Algorithm Hash digest
SHA256 cbe4e15f806aff3c99122faff29c0be4fde631e5b12e7ea9a143c8f1bce22787
MD5 3d1e10b508bf21bcc5f6f1dc6b82b844
BLAKE2b-256 f46ba30c7dc95644381edafb81847d4bf076ece809bd905cc3e50e30cca1a061

See more details on using hashes here.

File details

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

File metadata

  • Download URL: findpath-1.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3e4ee89cf35b8d9b0bb02f6050df4e45340a1885882b0d6cf197f868dce0e99a
MD5 149057b554b2feb9e0e1c5e3b2cdd046
BLAKE2b-256 93cb02f15f687995cd70a5c16e01365bb15a271cd0f85d665396b7b755888ed0

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