4. Backends

Author:Chris Warrick <chris@chriswarrick.com>
Copyright:© 2011–2015, Chris Warrick.
License:BSD (see /LICENSE or Appendix B.)
Date:2015-02-28
Version:1.5.0

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(verbose)[source]

Empty the trash.

list(human=True)[source]

List the trash contents.

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

Log a message.

regenerate()[source]

Regenerate the trash and recreate metadata.

restore(filename, verbose)[source]

Restore a file from trash.

trash(filepath, verbose)[source]

Move specified file to trash.