eric6/ThirdParty/Send2Trash/send2trash/plat_gio.py

changeset 6942
2602857055c5
parent 6228
9c3fbf39ec9b
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # Copyright 2017 Virgil Dupras
2
3 # This software is licensed under the "BSD" License as described in the "LICENSE" file,
4 # which should be included with this package. The terms are also available at
5 # http://www.hardcoded.net/licenses/bsd_license
6
7 from __future__ import unicode_literals
8
9 from gi.repository import GObject, Gio
10 from .exceptions import TrashPermissionError
11
12 def send2trash(path):
13 try:
14 f = Gio.File.new_for_path(path)
15 f.trash(cancellable=None)
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('')
21 raise OSError(e.message)

eric ide

mercurial