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.1.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.1-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: findpath-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 51dbbdec04aaffe1033cb1c94ec2f5f1a7f5d7bb0b6f1d8c794581d30c45b985
MD5 43df2a356dd6694eed79bdd4e01726de
BLAKE2b-256 681a56e9370e31943aa255e49d95c1cc859103eb04c4648eeed6bfecd5f20e8f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: findpath-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0bb6338eb1e2a993be58fdc95e570f19d26a3aa691d68fc3832536f917cd0998
MD5 877edcfacfcda6d84833bf5e329ecfa9
BLAKE2b-256 1f739d1d4ac433a9d2da0d79b4671318c67a99af14e18d3097ba2058004b1a2c

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