1
0
mirror of https://github.com/arsenetar/send2trash.git synced 2026-02-10 23:01:38 +00:00

Converted to py3k (haven't tried it on Windows yet, but it should compile and work...)

--HG--
branch : py3k
This commit is contained in:
Virgil Dupras
2010-07-07 16:12:13 +02:00
parent 88b90d859c
commit 2858b5b153
7 changed files with 52 additions and 26 deletions

View File

@@ -7,8 +7,8 @@
import sys
if sys.platform == 'darwin':
from plat_osx import send2trash
from .plat_osx import send2trash
elif sys.platform == 'win32':
from plat_win import send2trash
from .plat_win import send2trash
else:
from plat_other import send2trash
from .plat_other import send2trash

View File

@@ -4,9 +4,9 @@
# which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license
import _send2trash_osx
import send2trash_osx
def send2trash(path):
if not isinstance(path, unicode):
path = unicode(path, 'utf-8')
_send2trash_osx.send(path)
if not isinstance(path, str):
path = str(path, 'utf-8')
send2trash_osx.send(path)

View File

@@ -4,7 +4,7 @@
# which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license
from __future__ import unicode_literals
import sys
import os
import os.path as op
@@ -60,8 +60,8 @@ def move_without_conflict(src, dst):
os.rename(src, destpath)
def send2trash(path):
if not isinstance(path, unicode):
path = unicode(path, sys.getfilesystemencoding())
if not isinstance(path, str):
path = str(path, sys.getfilesystemencoding())
try:
move_without_conflict(path, TRASH_PATH)
except OSError:

View File

@@ -5,11 +5,11 @@
# http://www.hardcoded.net/licenses/bsd_license
import os.path as op
import _send2trash_win
import send2trash_win
def send2trash(path):
if not isinstance(path, unicode):
path = unicode(path, 'mbcs')
if not isinstance(path, str):
path = str(path, 'mbcs')
if not op.isabs(path):
path = op.abspath(path)
_send2trash_win.send(path)
send2trash_win.send(path)