mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Remove unused code
This commit is contained in:
parent
17b84867dd
commit
846a1a5e9f
@ -14,7 +14,7 @@ Test a binary calibre build to ensure that all needed binary images/libraries ha
|
|||||||
import os, ctypes, sys, unittest, time
|
import os, ctypes, sys, unittest, time
|
||||||
|
|
||||||
from calibre.constants import plugins, iswindows, islinux, isosx, ispy3
|
from calibre.constants import plugins, iswindows, islinux, isosx, ispy3
|
||||||
from polyglot.builtins import iteritems, map, unicode_type
|
from polyglot.builtins import iteritems, map, unicode_type, getenv
|
||||||
|
|
||||||
is_ci = os.environ.get('CI', '').lower() == 'true'
|
is_ci = os.environ.get('CI', '').lower() == 'true'
|
||||||
|
|
||||||
@ -154,23 +154,17 @@ class BuildTest(unittest.TestCase):
|
|||||||
for k, v in iteritems(d):
|
for k, v in iteritems(d):
|
||||||
au(v, k)
|
au(v, k)
|
||||||
for k in os.environ:
|
for k in os.environ:
|
||||||
au(winutil.getenv(unicode_type(k)), 'getenv-' + k)
|
au(getenv(k), 'getenv-' + k)
|
||||||
os.environ['XXXTEST'] = 'YYY'
|
os.environ['XXXTEST'] = 'YYY'
|
||||||
self.assertEqual(winutil.getenv('XXXTEST'), 'YYY')
|
self.assertEqual(getenv('XXXTEST'), 'YYY')
|
||||||
del os.environ['XXXTEST']
|
del os.environ['XXXTEST']
|
||||||
self.assertIsNone(winutil.getenv('XXXTEST'))
|
self.assertIsNone(getenv('XXXTEST'))
|
||||||
t = time.localtime()
|
t = time.localtime()
|
||||||
fmt = '%Y%a%b%e%H%M'
|
fmt = '%Y%a%b%e%H%M'
|
||||||
for fmt in (fmt, fmt.encode('ascii')):
|
for fmt in (fmt, fmt.encode('ascii')):
|
||||||
x = strftime(fmt, t)
|
x = strftime(fmt, t)
|
||||||
au(x, 'strftime')
|
au(x, 'strftime')
|
||||||
self.assertEqual(unicode_type(time.strftime(fmt.replace('%e', '%#d'), t)), x)
|
self.assertEqual(unicode_type(time.strftime(fmt.replace('%e', '%#d'), t)), x)
|
||||||
from polyglot.builtins import getenv
|
|
||||||
q = 'value'
|
|
||||||
os.environ['test_unicode_getenv'] = q
|
|
||||||
val = getenv('test_unicode_getenv')
|
|
||||||
self.assertEqual(val, q)
|
|
||||||
self.assertTrue(isinstance(val, type('')))
|
|
||||||
|
|
||||||
def test_sqlite(self):
|
def test_sqlite(self):
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
@ -230,19 +230,6 @@ winutil_set_max_stdio(PyObject *self, PyObject *args) {
|
|||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
|
||||||
winutil_getenv(PyObject *self, PyObject *args) {
|
|
||||||
const Py_UNICODE *q;
|
|
||||||
if (!PyArg_ParseTuple(args, "u", &q)) return NULL;
|
|
||||||
wchar_t *buf = NULL;
|
|
||||||
size_t sz = 0;
|
|
||||||
PyObject *ans = NULL;
|
|
||||||
if (_wdupenv_s(&buf, &sz, q) != 0 || buf == NULL || sz == 0) { ans = Py_None; Py_INCREF(ans); }
|
|
||||||
else ans = PyUnicode_FromWideChar(buf, sz - 1);
|
|
||||||
if (buf) free(buf);
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
winutil_move_file(PyObject *self, PyObject *args) {
|
winutil_move_file(PyObject *self, PyObject *args) {
|
||||||
Py_UNICODE *a, *b;
|
Py_UNICODE *a, *b;
|
||||||
@ -435,10 +422,6 @@ be a unicode string. Returns unicode strings."
|
|||||||
"setmaxstdio(num)\n\nSet the maximum number of open file handles."
|
"setmaxstdio(num)\n\nSet the maximum number of open file handles."
|
||||||
},
|
},
|
||||||
|
|
||||||
{"getenv", (PyCFunction)winutil_getenv, METH_VARARGS,
|
|
||||||
"getenv(name)\n\nGet the value of the specified env var as a unicode string."
|
|
||||||
},
|
|
||||||
|
|
||||||
{"username", (PyCFunction)winutil_username, METH_NOARGS,
|
{"username", (PyCFunction)winutil_username, METH_NOARGS,
|
||||||
"username()\n\nGet the current username as a unicode string."
|
"username()\n\nGet the current username as a unicode string."
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user