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 logicpytrashguard/cli.py: CLI entry pointpytrashguard/__init__.py: API exposurepyproject.toml: PackagingREADME.md: Documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5450b4ff325356c2c31223f77d2afeb3997b137131fe1ddea0be6dba4d926e70
|
|
| MD5 |
436f9c0aead3dd3244fad93ac1413350
|
|
| BLAKE2b-256 |
104bb6ecb006075e4159ef0858046b07a245642ad645986f0dddd425d6b5c70e
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cefd92d94401002bd8a5bc24ef57a6af35257de043c173703f230f55fdca8713
|
|
| MD5 |
eae86acad83e2644af87b6de77bfb409
|
|
| BLAKE2b-256 |
acd56b99102accb56337cef2bfe6f18d6e1afdfdfdd28a055f8cdd6b56332d3b
|