py-trashguard
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 logicpytrashguard/cli.py: CLI entry pointpytrashguard/__init__.py: API exposurepyproject.toml: PackagingREADME.md: DocumentationLICENSE: MIT License
License
This project is licensed under the MIT License. See the LICENSE file for details.
Metadata
Release files for py-trashguard 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| py_trashguard-0.1.3.tar.gz | 4.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_trashguard-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.1 kB
Release files / py_trashguard-0.1.3.tar.gz
| Download URL | py_trashguard-0.1.3.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e670b96b7a72f47a8bf9505dc27f196a4c9a6ef1cec950f7c15a593154c9b7f
|
|
BLAKE2b-256 checksum How to use checksums |
0c02df3fb20eaae360821584e5a301834076c94529e95db6a6b8eb1c487e568c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.0
|
Release files / py_trashguard-0.1.3-py3-none-any.whl
| Download URL | py_trashguard-0.1.3-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c98998874ddf659ebd0bbcff174b437776d0aae0a35b6fff6e518c295b77d565
|
|
BLAKE2b-256 checksum How to use checksums |
ffe6761da3bdb675a8287d8dc467698ec86a38c35a64cd35cd4d5387a934e5b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.0
|