ThirdParty/Send2Trash/send2trash/plat_gio.py

changeset 6228
9c3fbf39ec9b
parent 5994
cf0b37d2a28d
equal deleted inserted replaced
6227:fc0869cd16dc 6228:9c3fbf39ec9b
5 # http://www.hardcoded.net/licenses/bsd_license 5 # http://www.hardcoded.net/licenses/bsd_license
6 6
7 from __future__ import unicode_literals 7 from __future__ import unicode_literals
8 8
9 from gi.repository import GObject, Gio 9 from gi.repository import GObject, Gio
10 from .exceptions import TrashPermissionError
10 11
11 def send2trash(path): 12 def send2trash(path):
12 try: 13 try:
13 f = Gio.File.new_for_path(path) 14 f = Gio.File.new_for_path(path)
14 f.trash(cancellable=None) 15 f.trash(cancellable=None)
15 except GObject.GError as e: 16 except GObject.GError as e:
17 if e.code == Gio.IOErrorEnum.NOT_SUPPORTED:
18 # We get here if we can't create a trash directory on the same
19 # device. I don't know if other errors can result in NOT_SUPPORTED.
20 raise TrashPermissionError('')
16 raise OSError(e.message) 21 raise OSError(e.message)

eric ide

mercurial