comparison bindings/python/pyadbmodule.c @ 744:124ae047b968

Added python bindings for liszt (LIst SiZes and Timepoints of each database entry)
author mas01mc
date Thu, 11 Nov 2010 05:34:47 +0000
parents 63a75a2b5fa6
children 91719fa0d45b
comparison
equal deleted inserted replaced
743:63a75a2b5fa6 744:124ae047b968
279 ins->times = times; 279 ins->times = times;
280 //printf("features::%s\npower::%s\nkey::%s\ntimes::%s\n", ins->features, ins->power, ins->key, ins->times); 280 //printf("features::%s\npower::%s\nkey::%s\ntimes::%s\n", ins->features, ins->power, ins->key, ins->times);
281 ok = audiodb_insert(current_db, ins); 281 ok = audiodb_insert(current_db, ins);
282 return PyBool_FromLong(ok-1); 282 return PyBool_FromLong(ok-1);
283 283
284 }
285
286 /* liszt - list strings, sizes, and time-points of all database entries
287 *
288 */
289 PyObject* _pyadb_liszt(PyObject *self, PyObject *args)
290 {
291 adb_t *current_db;
292 int ok,i;
293 PyObject * incoming = NULL;
294 PyObject * outgoing = NULL;
295 PyObject * newBits = NULL;
296
297 ok = PyArg_ParseTuple(args, "O", &incoming);
298
299 if (!ok) return 0;
300 current_db = (adb_t *)PyCObject_AsVoidPtr(incoming);
301
302 adb_liszt_results_t *liszt = audiodb_liszt(current_db);
303
304 outgoing = PyList_New((Py_ssize_t)0);
305 for (i=0 ; i<liszt->nresults ; i++){
306 newBits = Py_BuildValue("sI",liszt->entries[i].key,liszt->entries[i].nvectors);
307 if (PyList_Append(outgoing, newBits)){
308 //error msg here
309 Py_XDECREF(newBits);
310 return NULL;
311 }
312 Py_DECREF(newBits);
313 }
314 audiodb_liszt_free_results(current_db, liszt);
315 return outgoing;
284 } 316 }
285 317
286 /* base query. The nomenclature here is about a far away as pythonic as is possible. 318 /* base query. The nomenclature here is about a far away as pythonic as is possible.
287 * This should be taken care of via the higher level python structure 319 * This should be taken care of via the higher level python structure
288 * returns a dict that should be result ordered and key = result key 320 * returns a dict that should be result ordered and key = result key
579 if times is given, must be 1d array of length 2*numVectors like this:\n\ 611 if times is given, must be 1d array of length 2*numVectors like this:\n\
580 int audiodb_insert_datum(adb_t *, const adb_datum_t *);"}, 612 int audiodb_insert_datum(adb_t *, const adb_datum_t *);"},
581 { "_pyadb_insertFromFile", (PyCFunction)_pyadb_insertFromFile, METH_VARARGS | METH_KEYWORDS, 613 { "_pyadb_insertFromFile", (PyCFunction)_pyadb_insertFromFile, METH_VARARGS | METH_KEYWORDS,
582 "_pyadb_insertFromFile(adb_t *, features=featureFile, [power=powerfile | key=keystring | times=timingFile])->\ 614 "_pyadb_insertFromFile(adb_t *, features=featureFile, [power=powerfile | key=keystring | times=timingFile])->\
583 int return code (0 for sucess)"}, 615 int return code (0 for sucess)"},
616 { "_pyadb_liszt", (PyCFunction)_pyadb_liszt, METH_VARARGS,
617 "_pyadb_liszt(adb_t*)->[[key1,numvecs1],[key2,numvecs2]...]"},
584 { "_pyadb_queryFromKey", (PyCFunction)_pyadb_queryFromKey, METH_VARARGS | METH_KEYWORDS, 618 { "_pyadb_queryFromKey", (PyCFunction)_pyadb_queryFromKey, METH_VARARGS | METH_KEYWORDS,
585 "base query. The nomenclature here is about a far away as pythonic as is possible.\n\ 619 "base query. The nomenclature here is about a far away as pythonic as is possible.\n\
586 This should be taken care of via the higher level python structure\n\ 620 This should be taken care of via the higher level python structure\n\
587 returns a dict that should be result ordered and key = result key\n\ 621 returns a dict that should be result ordered and key = result key\n\
588 and value is a list of tuples one per result associated with that key, of the form:\n\ 622 and value is a list of tuples one per result associated with that key, of the form:\n\