|
|
@@ -473,60 +473,6 @@ static inline void *extract_pyobject(FILE *in, layout_type_t type) |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
|
|
|
|
static PyObject *Rocket_extract_list(Rocket *self, PyObject *args) |
|
|
|
{ |
|
|
|
long count; |
|
|
|
if (_extract_handle_params(self, args, &count) < 0) |
|
|
|
return NULL; |
|
|
|
|
|
|
|
/* Make a list to return */ |
|
|
|
PyObject *retlist = PyList_New(0); |
|
|
|
if (!retlist) |
|
|
|
return NULL; |
|
|
|
|
|
|
|
/* Read data into new Python lists */ |
|
|
|
int row; |
|
|
|
for (row = 0; row < count; row++) |
|
|
|
{ |
|
|
|
PyObject *rowlist = PyList_New(self->layout_count + 1); |
|
|
|
if (!rowlist) { |
|
|
|
Py_DECREF(retlist); |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
|
|
|
|
/* Timestamp */ |
|
|
|
PyObject *entry = extract_pyobject(self->file, |
|
|
|
LAYOUT_TYPE_INT64); |
|
|
|
if (!entry || (PyList_SetItem(rowlist, 0, entry) < 0)) { |
|
|
|
Py_DECREF(rowlist); |
|
|
|
Py_DECREF(retlist); |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
|
|
|
|
/* Data */ |
|
|
|
int i; |
|
|
|
for (i = 0; i < self->layout_count; i++) { |
|
|
|
PyObject *ent = extract_pyobject(self->file, |
|
|
|
self->layout_type); |
|
|
|
if (!ent || (PyList_SetItem(rowlist, i+1, ent) < 0)) { |
|
|
|
Py_DECREF(rowlist); |
|
|
|
Py_DECREF(retlist); |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* Add row to return value */ |
|
|
|
if (PyList_Append(retlist, rowlist) < 0) { |
|
|
|
Py_DECREF(rowlist); |
|
|
|
Py_DECREF(retlist); |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
|
|
|
|
Py_DECREF(rowlist); |
|
|
|
} |
|
|
|
return retlist; |
|
|
|
} |
|
|
|
|
|
|
|
/**** |
|
|
|
* Extract to string |
|
|
|
*/ |
|
|
@@ -665,11 +611,6 @@ static PyMethodDef Rocket_methods[] = { |
|
|
|
" data_offset: current offset into the data string\n" |
|
|
|
" last_timestamp: last timestamp we parsed" }, |
|
|
|
|
|
|
|
{ "extract_list", (PyCFunction)Rocket_extract_list, METH_VARARGS, |
|
|
|
"extract_list(self, offset, count)\n\n" |
|
|
|
"Extract count rows of data from the file at offset offset.\n" |
|
|
|
"Return a list of lists [[row],[row],...]" }, |
|
|
|
|
|
|
|
{ "extract_string", (PyCFunction)Rocket_extract_string, METH_VARARGS, |
|
|
|
"extract_string(self, offset, count)\n\n" |
|
|
|
"Extract count rows of data from the file at offset offset.\n" |
|
|
|