Skip to main content

Safe os.remove alternative with soft delete to .trash/ folder

Project description

py-trashguard

A safe, user-friendly alternative to os.remove() that moves files to a .trash/ folder instead of deleting them permanently. Use it as a Python API or a CLI tool to protect your files from accidental deletion.

Features

  • Soft-delete files: Move files to a .trash/ directory instead of permanent removal
  • Restore files: Bring back files from the trash easily
  • List trashed files: See what’s in your trash
  • No dependencies: 100% Python standard library

Installation

Install from PyPI (after publishing):

pip install py-trashguard

Or install from source:

pip install .

Usage

Python API Example

from pytrashguard import trash, restore, list_trash

# Move a file to trash
t = trash("myfile.txt")
print(f"Trashed: {t}")

# List trashed files
print("In trash:", list_trash())

# Restore a file from trash
r = restore("myfile.txt")
print(f"Restored: {r}")

Command Line Interface Example

Move a file to trash:

py-trashguard --trash myfile.txt

List trashed files:

py-trashguard --list

Restore a file from trash:

py-trashguard --restore myfile.txt

Project Structure

  • pytrashguard/core.py: Core logic
  • pytrashguard/cli.py: CLI entry point
  • pytrashguard/__init__.py: API exposure
  • pyproject.toml: Packaging
  • README.md: Documentation

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

py_trashguard-0.1.2.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

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

py_trashguard-0.1.2-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file py_trashguard-0.1.2.tar.gz.

File metadata

  • Download URL: py_trashguard-0.1.2.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for py_trashguard-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5450b4ff325356c2c31223f77d2afeb3997b137131fe1ddea0be6dba4d926e70
MD5 436f9c0aead3dd3244fad93ac1413350
BLAKE2b-256 104bb6ecb006075e4159ef0858046b07a245642ad645986f0dddd425d6b5c70e

See more details on using hashes here.

File details

Details for the file py_trashguard-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: py_trashguard-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for py_trashguard-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cefd92d94401002bd8a5bc24ef57a6af35257de043c173703f230f55fdca8713
MD5 eae86acad83e2644af87b6de77bfb409
BLAKE2b-256 acd56b99102accb56337cef2bfe6f18d6e1afdfdfdd28a055f8cdd6b56332d3b

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