Skip to main content

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

Project description

py-trashguard

PyPI - Python Version License: MIT

Author: avishek devnath (avishekdevnath@gmail.com)
License: MIT License


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:

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
  • LICENSE: MIT License

License

This project is licensed under the MIT License. See the LICENSE file for details.

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.3.tar.gz (4.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.3-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_trashguard-0.1.3.tar.gz
  • Upload date:
  • Size: 4.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.3.tar.gz
Algorithm Hash digest
SHA256 8e670b96b7a72f47a8bf9505dc27f196a4c9a6ef1cec950f7c15a593154c9b7f
MD5 04237f46c6f04935be120556ebbb3aa0
BLAKE2b-256 0c02df3fb20eaae360821584e5a301834076c94529e95db6a6b8eb1c487e568c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_trashguard-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c98998874ddf659ebd0bbcff174b437776d0aae0a35b6fff6e518c295b77d565
MD5 b27cd1140f77ee4175ed63a8708a9c85
BLAKE2b-256 ffe6761da3bdb675a8287d8dc467698ec86a38c35a64cd35cd4d5387a934e5b9

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