ThirdParty/Send2Trash/send2trash/plat_gio.py

Fri, 13 Nov 2015 22:52:26 +0100

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Fri, 13 Nov 2015 22:52:26 +0100
changeset 4555
861e1741985c
parent 3644
a2c88b9b1d16
child 5994
cf0b37d2a28d
permissions
-rw-r--r--

Adjustments to future imports for Python 2 compatibility.

3644
a2c88b9b1d16 Added code to Project to move deleted files/directories to the recycle bin falling back to removing them (os.remove), if send2trash cannot be imported due to missing dependencies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # Copyright 2013 Hardcoded Software (http://www.hardcoded.net)
a2c88b9b1d16 Added code to Project to move deleted files/directories to the recycle bin falling back to removing them (os.remove), if send2trash cannot be imported due to missing dependencies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
a2c88b9b1d16 Added code to Project to move deleted files/directories to the recycle bin falling back to removing them (os.remove), if send2trash cannot be imported due to missing dependencies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # This software is licensed under the "BSD" License as described in the "LICENSE" file,
a2c88b9b1d16 Added code to Project to move deleted files/directories to the recycle bin falling back to removing them (os.remove), if send2trash cannot be imported due to missing dependencies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 # which should be included with this package. The terms are also available at
a2c88b9b1d16 Added code to Project to move deleted files/directories to the recycle bin falling back to removing them (os.remove), if send2trash cannot be imported due to missing dependencies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5 # http://www.hardcoded.net/licenses/bsd_license
a2c88b9b1d16 Added code to Project to move deleted files/directories to the recycle bin falling back to removing them (os.remove), if send2trash cannot be imported due to missing dependencies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6
4555
861e1741985c Adjustments to future imports for Python 2 compatibility.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3644
diff changeset
7 from __future__ import unicode_literals
861e1741985c Adjustments to future imports for Python 2 compatibility.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3644
diff changeset
8
3644
a2c88b9b1d16 Added code to Project to move deleted files/directories to the recycle bin falling back to removing them (os.remove), if send2trash cannot be imported due to missing dependencies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 from gi.repository import GObject, Gio
a2c88b9b1d16 Added code to Project to move deleted files/directories to the recycle bin falling back to removing them (os.remove), if send2trash cannot be imported due to missing dependencies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
a2c88b9b1d16 Added code to Project to move deleted files/directories to the recycle bin falling back to removing them (os.remove), if send2trash cannot be imported due to missing dependencies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 def send2trash(path):
a2c88b9b1d16 Added code to Project to move deleted files/directories to the recycle bin falling back to removing them (os.remove), if send2trash cannot be imported due to missing dependencies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 try:
a2c88b9b1d16 Added code to Project to move deleted files/directories to the recycle bin falling back to removing them (os.remove), if send2trash cannot be imported due to missing dependencies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 f = Gio.File.new_for_path(path)
a2c88b9b1d16 Added code to Project to move deleted files/directories to the recycle bin falling back to removing them (os.remove), if send2trash cannot be imported due to missing dependencies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 f.trash(cancellable=None)
a2c88b9b1d16 Added code to Project to move deleted files/directories to the recycle bin falling back to removing them (os.remove), if send2trash cannot be imported due to missing dependencies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 except GObject.GError as e:
a2c88b9b1d16 Added code to Project to move deleted files/directories to the recycle bin falling back to removing them (os.remove), if send2trash cannot be imported due to missing dependencies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 raise OSError(e.message)

eric ide

mercurial