jetraw.trash module

Trash management for Jetraw.

This module provides functionality to manage deleted files in the Jetraw trash. Files are deleted using JetrawPath.unlink() and can be restored or permanently deleted from the trash using these functions.

jetraw.trash.delete_from_trash(paths, *, client=None)

Permanently delete specific files from the trash.

This operation cannot be undone. The specified files will be permanently deleted.

Parameters:
  • paths (list[Path] | list[str] | Path | str) – File(s) to permanently delete (JetrawPath, string, or list of either)

  • client – Jetraw client instance (uses default if None)

Raises:

RuntimeError – If deletion fails

Example

>>> # Permanently delete a single file
>>> delete_from_trash("old-file.tiff")
>>>
>>> # Permanently delete multiple files
>>> delete_from_trash(["file1.tiff", "file2.tiff"])
>>>
>>> # Permanently delete using JetrawPath objects
>>> trashed_files = list_trash()
>>> delete_from_trash(trashed_files[:5])  # Delete first 5 files
jetraw.trash.empty_trash(*, client=None)

Permanently delete all files in the trash.

This operation cannot be undone. All files in the trash will be permanently deleted.

Parameters:

client – Jetraw client instance (uses default if None)

Raises:

RuntimeError – If emptying trash fails

Example

>>> # Empty the entire trash
>>> empty_trash()
>>> print("All trashed files have been permanently deleted")
jetraw.trash.list_trash(*, client=None, return_paths=True)

List all files in the trash.

Parameters:
  • client – Jetraw client instance (uses default if None)

  • return_paths – If True, return JetrawPath objects; if False, return names

Returns:

List of trashed files as paths or names

Return type:

list[JetrawPath] or list[str]

Raises:

RuntimeError – If listing trash fails

Example

>>> # List trashed files as paths
>>> trashed_files = list_trash()
>>> for path in trashed_files:
...     print(f"Trashed: {path.name}")
>>>
>>> # List trashed files as names only
>>> trashed_names = list_trash(return_paths=False)
>>> print(f"Found {len(trashed_names)} trashed files")
jetraw.trash.restore_from_trash(paths, destination=None, *, client=None)

Restore files from the trash.

Parameters:
  • paths (list[Path] | list[str] | Path | str) – File(s) to restore (JetrawPath, string, or list of either)

  • destination (Optional[str]) – Optional destination path for restored files

  • client – Jetraw client instance (uses default if None)

Raises:

RuntimeError – If restoration fails

Return type:

None

Example

>>> # Restore a single file
>>> restore_from_trash(JetrawPath("deleted-file.tiff"))
>>>
>>> # Restore multiple files to a specific location
>>> restore_from_trash(
...     ["file1.tiff", "file2.tiff"],
...     destination="/restored/"
... )
>>>
>>> # Restore using JetrawPath objects
>>> trashed_files = list_trash()
>>> restore_from_trash(trashed_files)