Helper Functions
Step 6: Implement Helper Methods
def clear_bin(self):
recycle_bin = winshell.recycle_bin()
items = len(list(recycle_bin))
if items != 0:
recycle_bin.empty(confirm=True, show_progress=True, sound=True)
return "Recycle bin has been cleared."
else:
return "The recycle bin is already empty."def recycle_file(self, file_path: str):
try:
winshell.undelete(file_path)
return f"The file {file_path} has been restored from the recycle bin."
except Exception as e:
return f"Error restoring file: {str(e)}"Last updated