4. Backends

Author:Chris Warrick <chris@chriswarrick.com>
Copyright:© 2011-2018, Chris Warrick.
License:BSD (see /LICENSE or Appendix B.)

Trashman uses backends for managing files. All the backends define the same functions and inherit from the Trash class.

Backend requirements:
  • name ending in Trash (eg. XDGTrash, DummyTrash)
  • PEP 8, docstrings
  • inherit from Trash
  • throw exceptions and log activity
  • implement the functions listed below (do not re-implement log unless needed)
  • do actual work (save for the dummy backend)
  • have a self.trashdir variable with the trash location (None if impossible)
  • have a self.logger instance (import logging, logging.getLogger('NAME')

In order to choose a backend, use trashman.backends.select(backend). If backend is auto, a choice will be made basing on the config, and if it also says auto, on the OS used. If it is list, a human-readable list of backends will be printed.

4.1. Functions

(this automatically-generated of the Trash class.)

class trashman.backends.trash.Trash[source]

Base Trash class.


Empty the trash.


List the trash contents.

log(msg, lvl='debug')[source]

Log a message.


Regenerate the trash and recreate metadata.

restore(filename, verbose)[source]

Restore a file from trash.

trash(filepath, verbose)[source]

Move specified file to trash.