Changeset 4908 for lang/python
- Timestamp:
- 01/19/08 01:28:48 (5 years ago)
- Location:
- lang/python/pytc/tags/RELEASE-0.3
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/python/pytc/tags/RELEASE-0.3/ChangeLog
r3823 r4908 1 2007-12-30 Tasuku SUENAGA <gunyarakun@sourceforge.net>2 3 * version 0.34 * modified setup.py for darwin5 * added TCBDB.range and TCBDB.rangefwm6 7 1 2007-12-15 Tasuku SUENAGA <gunyarakun@sourceforge.net> 8 2 -
lang/python/pytc/tags/RELEASE-0.3/pytc.c
r3823 r4908 1 1 /* Copyright(C) 2007- Tasuku SUENAGA 2 2 3 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 4 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 5 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 6 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 7 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 8 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 9 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 10 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 11 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 12 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 13 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3 This library is free software; you can redistribute it and/or 4 modify it under the terms of the GNU Lesser General Public 5 License as published by the Free Software Foundation; either 6 version 2.1 of the License, or (at your option) any later version. 7 8 This library is distributed in the hope that it will be useful, 9 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 Lesser General Public License for more details. 12 13 You should have received a copy of the GNU Lesser General Public 14 License along with this library; if not, write to the Free Software 15 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 14 16 */ 15 17 #include <Python.h> … … 236 238 \ 237 239 if (!PyArg_ParseTupleAndKeywords(args, keywds, "s#s#:" #method, kwlist, \ 238 &key, &key_len, \ 239 &value, &value_len)) { \ 240 &key, &key_len, &value, &value_len)) { \ 240 241 return NULL; \ 241 242 } \ … … 324 325 return NULL; \ 325 326 } \ 326 key = PyString_A sString(_key); \327 key = PyString_AS_STRING(_key); \ 327 328 key_len = PyString_GET_SIZE(_key); \ 328 329 if (!key || !key_len) { \ … … 346 347 func(type *self, PyObject *_key) { \ 347 348 bool result; \ 348 char *key = PyString_A sString(_key); \349 char *key = PyString_AS_STRING(_key); \ 349 350 int key_len = PyString_GET_SIZE(_key); \ 350 351 \ … … 367 368 func(type *self, PyObject *_key, PyObject *_value) { \ 368 369 bool result; \ 369 char *key = PyString_A sString(_key), *value = PyString_AsString(_value); \370 char *key = PyString_AS_STRING(_key), *value = PyString_AS_STRING(_value); \ 370 371 int key_len = PyString_GET_SIZE(_key), value_len = PyString_GET_SIZE(_value); \ 371 372 \ … … 398 399 static int \ 399 400 func(type *self, PyObject *_key) { \ 400 char *key = PyString_A sString(_key); \401 char *key = PyString_AS_STRING(_key); \ 401 402 int key_len = PyString_GET_SIZE(_key), value_len; \ 402 403 \ … … 421 422 func(type *self, PyObject *_key) { \ 422 423 PyObject *ret; \ 423 char *key = PyString_A sString(_key), *value; \424 char *key = PyString_AS_STRING(_key), *value; \ 424 425 int key_len = PyString_GET_SIZE(_key), value_len; \ 425 426 \ … … 475 476 if (value) { tcxstrdel(value); } \ 476 477 return ret; 477 478 #define TCLIST2PyList() \479 if (!list) { \480 raise_tcbdb_error(self->bdb); \481 return NULL; \482 } else { \483 PyObject *ret; \484 int i, n = tclistnum(list); \485 if ((ret = PyList_New(n))) { \486 for (i = 0; i < n; i++) { \487 int value_len; \488 PyObject *_value; \489 const char *value; \490 value = tclistval(list, i, &value_len); \491 _value = PyString_FromStringAndSize(value, value_len); \492 PyList_SET_ITEM(ret, i, _value); \493 } \494 } \495 tclistdel(list); \496 return ret; \497 }498 478 499 479 /*** TCHDB ***/ … … 1420 1400 Py_END_ALLOW_THREADS 1421 1401 1422 TCLIST2PyList() 1402 if (!list) { 1403 raise_tcbdb_error(self->bdb); 1404 return NULL; 1405 } else { 1406 PyObject *ret; 1407 int i, n = tclistnum(list); 1408 if ((ret = PyList_New(n))) { 1409 for (i = 0; i < n; i++) { 1410 int value_len; 1411 PyObject *_value; 1412 const char *value; 1413 value = tclistval(list, i, &value_len); 1414 _value = PyString_FromStringAndSize(value, value_len); 1415 PyList_SET_ITEM(ret, i, _value); 1416 } 1417 } 1418 tclistdel(list); 1419 return ret; 1420 } 1423 1421 } 1424 1422 … … 1435 1433 PY_U_LONG_LONG_NOARGS(PyTCBDB_rnum, PyTCBDB, tcbdbrnum, bdb, tcbdbecode, raise_tcbdb_error) 1436 1434 PY_U_LONG_LONG_NOARGS(PyTCBDB_fsiz, PyTCBDB, tcbdbrnum, bdb, tcbdbecode, raise_tcbdb_error) 1437 1438 static PyObject *1439 PyTCBDB_range(PyTCBDB *self, PyObject *args, PyObject *keywds) {1440 TCLIST *list;1441 char *bkey, *ekey;1442 int bkey_len, binc, ekey_len, einc, max;1443 static char *kwlist[] = {"bkey", "binc", "ekey", "einc", "max", NULL};1444 1445 if (!PyArg_ParseTupleAndKeywords(args, keywds, "z#iz#ii:range", kwlist,1446 &bkey, &bkey_len, &binc,1447 &ekey, &ekey_len, &einc, &max)) {1448 return NULL;1449 }1450 Py_BEGIN_ALLOW_THREADS1451 list = tcbdbrange(self->bdb, bkey, bkey_len, binc,1452 ekey, ekey_len, einc, max);1453 Py_END_ALLOW_THREADS1454 1455 TCLIST2PyList()1456 }1457 1458 static PyObject *1459 PyTCBDB_rangefwm(PyTCBDB *self, PyObject *args, PyObject *keywds) {1460 int max;1461 TCLIST *list;1462 char *prefix;1463 static char *kwlist[] = {"prefix", "max", NULL};1464 1465 if (!PyArg_ParseTupleAndKeywords(args, keywds, "si:rangefwm", kwlist,1466 &prefix, &max)) {1467 return NULL;1468 }1469 Py_BEGIN_ALLOW_THREADS1470 list = tcbdbrange3(self->bdb, prefix, max);1471 Py_END_ALLOW_THREADS1472 1473 TCLIST2PyList()1474 }1475 1435 1476 1436 /* TODO: features for experts */ … … 1766 1726 METH_NOARGS, 1767 1727 "Create a cursor object."}, 1768 {"range", (PyCFunction)PyTCBDB_range,1769 METH_VARARGS | METH_KEYWORDS,1770 ""},1771 {"rangefwm", (PyCFunction)PyTCBDB_rangefwm,1772 METH_VARARGS | METH_KEYWORDS,1773 ""},1774 1728 {"__contains__", (PyCFunction)PyTCBDB___contains__, 1775 1729 METH_O | METH_COEXIST, -
lang/python/pytc/tags/RELEASE-0.3/setup.py
r3823 r4908 25 25 26 26 setup(name = 'pytc', 27 version = '0. 3',27 version = '0.2', 28 28 description = 'Tokyo Cabinet Python bindings', 29 29 long_description = ''' -
lang/python/pytc/tags/RELEASE-0.3/tests/testBDB.py
r3822 r4908 174 174 self.assertEqual(db.get('moru'), 'pupupu') 175 175 176 db['nagasaki'] = 'ichiban'177 db['nagasaki-higashi'] = 'toh'178 db['nagasaki-nishi'] = 'zai'179 db['nagasaki-minami'] = 'nan'180 db['nagasaki-kita'] = 'boku'181 db['nagasaki-hokuyodai'] = 'hokuyodai'182 # range183 self.assertEqual(db.range('nagasaki', False, 'nagasaki-kita', True, 3),184 ['nagasaki-higashi',185 'nagasaki-hokuyodai',186 'nagasaki-kita'])187 # rangefwm188 self.assertEqual(db.rangefwm('nagasaki', 5),189 ['nagasaki', 'nagasaki-higashi',190 'nagasaki-hokuyodai', 'nagasaki-kita',191 'nagasaki-minami'])192 193 176 # vanish 194 177 db.vanish()
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)