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
logunless needed) - do actual work (save for the
dummybackend) - have a
self.trashdirvariable with the trash location (Noneif impossible) - have a
self.loggerinstance (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.