mirror of
https://github.com/arsenetar/send2trash.git
synced 2025-05-08 17:59:50 +00:00
Renamed _trash_* modules to _send2trash_* and added python wrapper around them.
--HG-- rename : modules/trash_osx.c => modules/send2trash_osx.c rename : modules/trash_win.c => modules/send2trash_win.c
This commit is contained in:
parent
be87b55146
commit
8a1dff2947
@ -1,4 +1,5 @@
|
|||||||
syntax: glob
|
syntax: glob
|
||||||
|
|
||||||
|
*.pyc
|
||||||
build
|
build
|
||||||
.DS_Store
|
.DS_Store
|
@ -2,7 +2,7 @@
|
|||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include <CoreServices/CoreServices.h>
|
#include <CoreServices/CoreServices.h>
|
||||||
|
|
||||||
static PyObject* trash_osx_send(PyObject *self, PyObject *args)
|
static PyObject* send2trash_osx_send(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
UInt8 *utf8_chars;
|
UInt8 *utf8_chars;
|
||||||
FSRef fp;
|
FSRef fp;
|
||||||
@ -22,13 +22,13 @@ static PyObject* trash_osx_send(PyObject *self, PyObject *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static PyMethodDef TrashMethods[] = {
|
static PyMethodDef TrashMethods[] = {
|
||||||
{"send", trash_osx_send, METH_VARARGS, ""},
|
{"send", send2trash_osx_send, METH_VARARGS, ""},
|
||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
PyMODINIT_FUNC
|
||||||
init_trash_osx(void)
|
init_send2trash_osx(void)
|
||||||
{
|
{
|
||||||
PyObject *m = Py_InitModule("_trash_osx", TrashMethods);
|
PyObject *m = Py_InitModule("_send2trash_osx", TrashMethods);
|
||||||
if (m == NULL) {
|
if (m == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
@ -9,7 +9,7 @@
|
|||||||
rather than sending it to trash.
|
rather than sending it to trash.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static PyObject* trash_win_send(PyObject *self, PyObject *args)
|
static PyObject* send2trash_win_send(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
SHFILEOPSTRUCTW op;
|
SHFILEOPSTRUCTW op;
|
||||||
PyObject *filepath;
|
PyObject *filepath;
|
||||||
@ -47,14 +47,14 @@ static PyObject* trash_win_send(PyObject *self, PyObject *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static PyMethodDef TrashMethods[] = {
|
static PyMethodDef TrashMethods[] = {
|
||||||
{"send", trash_win_send, METH_VARARGS, ""},
|
{"send", send2trash_win_send, METH_VARARGS, ""},
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
PyMODINIT_FUNC
|
||||||
init_trash_win(void)
|
init_send2trash_win(void)
|
||||||
{
|
{
|
||||||
PyObject *m = Py_InitModule("_trash_win", TrashMethods);
|
PyObject *m = Py_InitModule("_send2trash_win", TrashMethods);
|
||||||
if (m == NULL) {
|
if (m == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
if sys.platform == 'darwin':
|
||||||
|
from plat_osx import send2trash
|
||||||
|
elif sys.platform == 'win32':
|
||||||
|
from plat_win import send2trash
|
||||||
|
else:
|
||||||
|
print "Unsupported platform"
|
6
send2trash/plat_osx.py
Normal file
6
send2trash/plat_osx.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import _send2trash_osx
|
||||||
|
|
||||||
|
def send2trash(path):
|
||||||
|
if not isinstance(path, unicode):
|
||||||
|
path = unicode(path, 'utf-8')
|
||||||
|
_send2trash_osx.send(path)
|
9
send2trash/plat_win.py
Normal file
9
send2trash/plat_win.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import os.path as op
|
||||||
|
import _send2trash_win
|
||||||
|
|
||||||
|
def send2trash(path):
|
||||||
|
if not isinstance(path, unicode):
|
||||||
|
path = unicode(path, 'mbcs')
|
||||||
|
if not op.isabs(path):
|
||||||
|
path = op.abspath(path)
|
||||||
|
_send2trash_win.send(path)
|
10
setup.py
10
setup.py
@ -1,21 +1,21 @@
|
|||||||
import sys
|
import sys
|
||||||
import os.path as op
|
import os.path as op
|
||||||
|
|
||||||
from distutils.core import setup
|
from setuptools import setup
|
||||||
from distutils.extension import Extension
|
from distutils.extension import Extension
|
||||||
|
|
||||||
exts = []
|
exts = []
|
||||||
|
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
exts.append(Extension(
|
exts.append(Extension(
|
||||||
'_trash_osx',
|
'_send2trash_osx',
|
||||||
[op.join('modules', 'trash_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(
|
||||||
'_trash_win',
|
'_send2trash_win',
|
||||||
[op.join('modules', 'trash_win.c')],
|
[op.join('modules', 'send2trash_win.c')],
|
||||||
extra_link_args = ['shell32.lib'],
|
extra_link_args = ['shell32.lib'],
|
||||||
))
|
))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user