Skip to main content

Lightweight helpers for working with filesystem paths.

Project description

PathHelper

PathHelper is a lightweight library for working with file and directory paths in Python. It provides simple interfaces and clear syntax for checking, creating, and removing paths — with helpful utilities for working in temporary directories.


✨ Features

  • FileHelper: check, create, and remove files
  • DirHelper: check, create, and remove directories
  • RunInDir: context manager to temporarily change working directory
  • Simplifies common scripting operations
  • Minimal dependencies and clean API

📦 Installation

pip install pathhelper

🚀 Quick Example

from pathhelper import DirHelper, FileHelper, RunInDir
import os

# Create a directory if it doesn't exist
dir_helper = DirHelper("temp_folder")
dir_helper.create_if_missing()

# Switch to that directory temporarily
with RunInDir("temp_folder"):
    print("Now inside:", os.getcwd())

# Clean up afterward
dir_helper.remove_if_present()

🔍 API Overview

Class Method / Constructor Description
FileHelper __init__(path) Initializes a file path helper with the given file path
check_exists() Returns True if the file exists
create() Creates the file and any necessary parent directories
remove() Removes the file
create_if_missing() Creates the file only if it doesn’t exist
remove_if_present() Removes the file only if it exists
DirHelper __init__(path) Initializes a directory path helper with the given directory path
check_exists() Returns True if the directory exists
create() Creates the directory (and parents)
remove() Recursively removes the directory and contents
create_if_missing() Creates the directory only if it doesn’t exist
remove_if_present() Removes the directory only if it exists
RunInDir __init__(path) Initializes the context manager with a target path
__enter__() / __exit__() Temporarily changes working directory within a with block

🛠 Development Status

| Alpha — usable and tested, but subject to change

📄 License

MIT License

🔗 Links

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

pathhelper-0.1.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

pathhelper-0.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file pathhelper-0.1.0.tar.gz.

File metadata

  • Download URL: pathhelper-0.1.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for pathhelper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dc93a217622f4941a1f6dedfc2452c91dfd2b4f65164c66216322bc9a64140cf
MD5 5be84b676a7d67f03d16cbda9c5fc73d
BLAKE2b-256 753244252cf5476f46fbcb55549bc01967b01f0a3bfed56af6ede1dc45bb89fd

See more details on using hashes here.

File details

Details for the file pathhelper-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pathhelper-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for pathhelper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dcfdeca5aebc6865104f90f6f651d84f8c6f069a26fb0b6c2de9910b3f3f62e6
MD5 656dccaf85dc2e6cfba52db1bdcc80d0
BLAKE2b-256 cd36798ba88c9ebc07bdd88ce3fcd866912333842357ecacbafbc0109e7c6f53

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