mirror of
https://github.com/arsenetar/send2trash.git
synced 2026-01-25 16:11:39 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd9183afe9 | ||
|
|
f6f63b1796 | ||
|
|
0974912e78 | ||
|
|
6c01453fd3 | ||
|
|
7cbefa4317 | ||
|
|
72bc94b48d | ||
|
|
35ad95bcd5 |
10
CHANGES.rst
10
CHANGES.rst
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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)
|
|
||||||
|
|
||||||
|
|||||||
11
setup.py
11
setup.py
@@ -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,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user