mirror of
https://github.com/arsenetar/send2trash.git
synced 2025-05-08 09:49:52 +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:
parent
88b90d859c
commit
2858b5b153
@ -34,12 +34,25 @@ static PyMethodDef TrashMethods[] = {
|
|||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
static struct PyModuleDef TrashDef = {
|
||||||
init_send2trash_osx(void)
|
PyModuleDef_HEAD_INIT,
|
||||||
|
"send2trash_osx",
|
||||||
|
NULL,
|
||||||
|
-1,
|
||||||
|
TrashMethods,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
PyObject *
|
||||||
|
PyInit_send2trash_osx(void)
|
||||||
{
|
{
|
||||||
PyObject *m = Py_InitModule("_send2trash_osx", TrashMethods);
|
PyObject *m = PyModule_Create(&TrashDef);
|
||||||
if (m == NULL) {
|
if (m == NULL) {
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,11 +58,24 @@ static PyMethodDef TrashMethods[] = {
|
|||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
static struct PyModuleDef TrashDef = {
|
||||||
init_send2trash_win(void)
|
PyModuleDef_HEAD_INIT,
|
||||||
|
"send2trash_win",
|
||||||
|
NULL,
|
||||||
|
-1,
|
||||||
|
TrashMethods,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
PyObject *
|
||||||
|
PyInit_send2trash_win(void)
|
||||||
{
|
{
|
||||||
PyObject *m = Py_InitModule("_send2trash_win", TrashMethods);
|
PyObject *m = PyModule_Create(&TrashDef);
|
||||||
if (m == NULL) {
|
if (m == NULL) {
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
return m;
|
||||||
}
|
}
|
@ -7,8 +7,8 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
from plat_osx import send2trash
|
from .plat_osx import send2trash
|
||||||
elif sys.platform == 'win32':
|
elif sys.platform == 'win32':
|
||||||
from plat_win import send2trash
|
from .plat_win import send2trash
|
||||||
else:
|
else:
|
||||||
from plat_other import send2trash
|
from .plat_other import send2trash
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
# which should be included with this package. The terms are also available at
|
# which should be included with this package. The terms are also available at
|
||||||
# http://www.hardcoded.net/licenses/bsd_license
|
# http://www.hardcoded.net/licenses/bsd_license
|
||||||
|
|
||||||
import _send2trash_osx
|
import send2trash_osx
|
||||||
|
|
||||||
def send2trash(path):
|
def send2trash(path):
|
||||||
if not isinstance(path, unicode):
|
if not isinstance(path, str):
|
||||||
path = unicode(path, 'utf-8')
|
path = str(path, 'utf-8')
|
||||||
_send2trash_osx.send(path)
|
send2trash_osx.send(path)
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# which should be included with this package. The terms are also available at
|
# which should be included with this package. The terms are also available at
|
||||||
# http://www.hardcoded.net/licenses/bsd_license
|
# http://www.hardcoded.net/licenses/bsd_license
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import os.path as op
|
import os.path as op
|
||||||
@ -60,8 +60,8 @@ def move_without_conflict(src, dst):
|
|||||||
os.rename(src, destpath)
|
os.rename(src, destpath)
|
||||||
|
|
||||||
def send2trash(path):
|
def send2trash(path):
|
||||||
if not isinstance(path, unicode):
|
if not isinstance(path, str):
|
||||||
path = unicode(path, sys.getfilesystemencoding())
|
path = str(path, sys.getfilesystemencoding())
|
||||||
try:
|
try:
|
||||||
move_without_conflict(path, TRASH_PATH)
|
move_without_conflict(path, TRASH_PATH)
|
||||||
except OSError:
|
except OSError:
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
# http://www.hardcoded.net/licenses/bsd_license
|
# http://www.hardcoded.net/licenses/bsd_license
|
||||||
|
|
||||||
import os.path as op
|
import os.path as op
|
||||||
import _send2trash_win
|
import send2trash_win
|
||||||
|
|
||||||
def send2trash(path):
|
def send2trash(path):
|
||||||
if not isinstance(path, unicode):
|
if not isinstance(path, str):
|
||||||
path = unicode(path, 'mbcs')
|
path = str(path, 'mbcs')
|
||||||
if not op.isabs(path):
|
if not op.isabs(path):
|
||||||
path = op.abspath(path)
|
path = op.abspath(path)
|
||||||
_send2trash_win.send(path)
|
send2trash_win.send(path)
|
||||||
|
8
setup.py
8
setup.py
@ -8,13 +8,13 @@ exts = []
|
|||||||
|
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
exts.append(Extension(
|
exts.append(Extension(
|
||||||
'_send2trash_osx',
|
'send2trash_osx',
|
||||||
[op.join('modules', 'send2trash_osx.c')],
|
[op.join('modules', 'send2trash_osx.c')],
|
||||||
extra_link_args=['-framework', 'CoreServices'],
|
extra_link_args=['-framework', 'CoreServices'],
|
||||||
))
|
))
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
exts.append(Extension(
|
exts.append(Extension(
|
||||||
'_send2trash_win',
|
'send2trash_win',
|
||||||
[op.join('modules', 'send2trash_win.c')],
|
[op.join('modules', 'send2trash_win.c')],
|
||||||
extra_link_args = ['shell32.lib'],
|
extra_link_args = ['shell32.lib'],
|
||||||
))
|
))
|
||||||
@ -26,14 +26,14 @@ CLASSIFIERS = [
|
|||||||
'Operating System :: MacOS :: MacOS X',
|
'Operating System :: MacOS :: MacOS X',
|
||||||
'Operating System :: Microsoft :: Windows',
|
'Operating System :: Microsoft :: Windows',
|
||||||
'Operating System :: POSIX',
|
'Operating System :: POSIX',
|
||||||
'Programming Language :: Python :: 2',
|
'Programming Language :: Python :: 3',
|
||||||
'Programming Language :: Objective C',
|
'Programming Language :: Objective C',
|
||||||
'Programming Language :: C',
|
'Programming Language :: C',
|
||||||
'Topic :: Desktop Environment :: File Managers',
|
'Topic :: Desktop Environment :: File Managers',
|
||||||
]
|
]
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='Send2Trash',
|
name='Send2Trash3k',
|
||||||
version='1.0.1',
|
version='1.0.1',
|
||||||
author='Hardcoded Software',
|
author='Hardcoded Software',
|
||||||
author_email='hsoft@hardcoded.net',
|
author_email='hsoft@hardcoded.net',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user