1
0
mirror of https://github.com/arsenetar/send2trash.git synced 2026-01-25 16:11:39 +00:00

7 Commits
1.3.0 ... 1.3.1

Author SHA1 Message Date
Virgil Dupras
bd9183afe9 v1.3.1 2017-07-31 14:21:18 -04:00
Kfir Hadas
f6f63b1796 Use text_type (unicode for PY2, str for PY3) (#12) 2017-07-07 16:09:16 -04:00
Virgil Dupras
0974912e78 Merge pull request #7 from julian-r/master
throwing a WindowsError with the code
2016-06-04 19:22:46 -04:00
Julian David Rath
6c01453fd3 throwing a WindowsError with the code 2016-04-12 08:53:04 +02:00
Virgil Dupras
7cbefa4317 Merge pull request #6 from glensc/patch-1
Update plat_other.py
2016-04-10 19:04:38 -04:00
Elan Ruusamäe
72bc94b48d Update plat_other.py
minor typo fix
2016-04-10 11:09:46 +03:00
Virgil Dupras
35ad95bcd5 Fixed typo in changelog 2013-07-19 19:33:09 -04:00
4 changed files with 21 additions and 17 deletions

View File

@@ -1,11 +1,17 @@
Changes Changes
======= =======
Version 1.3.1 -- 2017/07/31
---------------------------
* Throw ``WindowsError`` instead of ``OSError`` in ``plat_win``. (#7)
* Fix ``TypeError`` on python 2 in ``plat_other``. (#12)
Version 1.3.0 -- 2013/07/19 Version 1.3.0 -- 2013/07/19
--------------------------- ---------------------------
* Added support for Gnome's GIO. * Added support for Gnome's GIO.
* Merged Python 3 and Python 2 vesion in a single codebase. * Merged Python 3 and Python 2 versions in a single codebase.
Version 1.2.0 -- 2011/03/16 Version 1.2.0 -- 2011/03/16
--------------------------- ---------------------------
@@ -30,4 +36,4 @@ Version 1.0.1 -- 2010/04/19
Version 1.0.0 -- 2010/04/07 Version 1.0.0 -- 2010/04/07
--------------------------- ---------------------------
* Initial Release * Initial Release

View File

@@ -27,6 +27,9 @@ except ImportError:
# Python 2 # Python 2
from urllib import quote from urllib import quote
# PY2-PY3 compatibilty
text_type = str if sys.version_info[0] == 3 else unicode
FILES_DIR = 'files' FILES_DIR = 'files'
INFO_DIR = 'info' INFO_DIR = 'info'
INFO_SUFFIX = '.trashinfo' INFO_SUFFIX = '.trashinfo'
@@ -37,7 +40,7 @@ HOMETRASH = op.join(XDG_DATA_HOME, 'Trash')
uid = os.getuid() uid = os.getuid()
TOPDIR_TRASH = '.Trash' TOPDIR_TRASH = '.Trash'
TOPDIR_FALLBACK = '.Trash-' + str(uid) TOPDIR_FALLBACK = '.Trash-' + text_type(uid)
def is_parent(parent, path): def is_parent(parent, path):
path = op.realpath(path) # In case it's a symlink path = op.realpath(path) # In case it's a symlink
@@ -48,7 +51,7 @@ def format_date(date):
return date.strftime("%Y-%m-%dT%H:%M:%S") return date.strftime("%Y-%m-%dT%H:%M:%S")
def info_for(src, topdir): def info_for(src, topdir):
# ...it MUST not include a ".."" directory, and for files not "under" that # ...it MUST not include a ".." directory, and for files not "under" that
# directory, absolute pathnames must be used. [2] # directory, absolute pathnames must be used. [2]
if topdir is None or not is_parent(topdir, src): if topdir is None or not is_parent(topdir, src):
src = op.abspath(src) src = op.abspath(src)
@@ -106,7 +109,7 @@ def find_ext_volume_global_trash(volume_root):
if not op.isdir(trash_dir) or op.islink(trash_dir) or not (mode & stat.S_ISVTX): if not op.isdir(trash_dir) or op.islink(trash_dir) or not (mode & stat.S_ISVTX):
return None return None
trash_dir = op.join(trash_dir, str(uid)) trash_dir = op.join(trash_dir, text_type(uid))
try: try:
check_create(trash_dir) check_create(trash_dir)
except OSError: except OSError:
@@ -132,8 +135,8 @@ def get_dev(path):
return os.lstat(path).st_dev return os.lstat(path).st_dev
def send2trash(path): def send2trash(path):
if not isinstance(path, str): if not isinstance(path, text_type):
path = str(path, sys.getfilesystemencoding()) path = text_type(path, sys.getfilesystemencoding())
if not op.exists(path): if not op.exists(path):
raise OSError("File not found: %s" % path) raise OSError("File not found: %s" % path)
# ...should check whether the user has the necessary permissions to delete # ...should check whether the user has the necessary permissions to delete

View File

@@ -54,6 +54,4 @@ def send2trash(path):
fileop.lpszProgressTitle = None fileop.lpszProgressTitle = None
result = SHFileOperationW(byref(fileop)) result = SHFileOperationW(byref(fileop))
if result: if result:
msg = "Couldn't perform operation. Error code: %d" % result raise WindowsError(None, None, path, result)
raise OSError(msg)

View File

@@ -1,6 +1,3 @@
import sys
import os.path as op
from setuptools import setup from setuptools import setup
CLASSIFIERS = [ CLASSIFIERS = [
@@ -19,14 +16,14 @@ LONG_DESCRIPTION = open('README.rst', 'rt').read() + '\n\n' + open('CHANGES.rst'
setup( setup(
name='Send2Trash', name='Send2Trash',
version='1.3.0', version='1.3.1',
author='Hardcoded Software', author='Virgil Dupras',
author_email='hsoft@hardcoded.net', author_email='hsoft@hardcoded.net',
packages=['send2trash'], packages=['send2trash'],
scripts=[], scripts=[],
url='http://github.com/hsoft/send2trash', url='https://github.com/hsoft/send2trash',
license='BSD License', license='BSD License',
description='Send file to trash natively under Mac OS X, Windows and Linux.', description='Send file to trash natively under Mac OS X, Windows and Linux.',
long_description=LONG_DESCRIPTION, long_description=LONG_DESCRIPTION,
classifiers=CLASSIFIERS, classifiers=CLASSIFIERS,
) )