ThirdParty/Send2Trash/send2trash/plat_gio.py

Fri, 20 Jun 2014 16:05:45 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 20 Jun 2014 16:05:45 +0200
changeset 3644
a2c88b9b1d16
child 4555
861e1741985c
permissions
-rw-r--r--

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.

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
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
7 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
8
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 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
10 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
11 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
12 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
13 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
14 raise OSError(e.message)

eric ide

mercurial