|
a/src/python/recoll/pyrecoll.cpp |
|
b/src/python/recoll/pyrecoll.cpp |
|
... |
|
... |
60 |
} recoll_SearchDataObject;
|
60 |
} recoll_SearchDataObject;
|
61 |
|
61 |
|
62 |
static void
|
62 |
static void
|
63 |
SearchData_dealloc(recoll_SearchDataObject *self)
|
63 |
SearchData_dealloc(recoll_SearchDataObject *self)
|
64 |
{
|
64 |
{
|
65 |
LOGDEB(("SearchData_dealloc\n"));
|
65 |
LOGDEB(("SearchData_dealloc. Releasing. Count before: %d\n",
|
|
|
66 |
self->sd.getcnt()));
|
|
|
67 |
self->sd.release();
|
66 |
Py_TYPE(self)->tp_free((PyObject*)self);
|
68 |
Py_TYPE(self)->tp_free((PyObject*)self);
|
67 |
}
|
69 |
}
|
68 |
|
70 |
|
69 |
static PyObject *
|
71 |
static PyObject *
|
70 |
SearchData_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
72 |
SearchData_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|
... |
|
... |
176 |
|
178 |
|
177 |
static PyObject *
|
179 |
static PyObject *
|
178 |
SearchData_addclause(recoll_SearchDataObject* self, PyObject *args,
|
180 |
SearchData_addclause(recoll_SearchDataObject* self, PyObject *args,
|
179 |
PyObject *kwargs)
|
181 |
PyObject *kwargs)
|
180 |
{
|
182 |
{
|
181 |
LOGDEB(("SearchData_addclause\n"));
|
183 |
LOGDEB0(("SearchData_addclause\n"));
|
182 |
if (self->sd.isNull()) {
|
184 |
if (self->sd.isNull()) {
|
183 |
LOGERR(("SearchData_addclause: not init??\n"));
|
185 |
LOGERR(("SearchData_addclause: not init??\n"));
|
184 |
PyErr_SetString(PyExc_AttributeError, "sd");
|
186 |
PyErr_SetString(PyExc_AttributeError, "sd");
|
185 |
return 0;
|
187 |
return 0;
|
186 |
}
|
188 |
}
|
|
... |
|
... |
300 |
}
|
302 |
}
|
301 |
|
303 |
|
302 |
static PyObject *
|
304 |
static PyObject *
|
303 |
Doc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
305 |
Doc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
304 |
{
|
306 |
{
|
|
|
307 |
LOGDEB(("Doc_new\n"));
|
305 |
recoll_DocObject *self;
|
308 |
recoll_DocObject *self;
|
306 |
LOGDEB(("Doc_new\n"));
|
|
|
307 |
|
309 |
|
308 |
self = (recoll_DocObject *)type->tp_alloc(type, 0);
|
310 |
self = (recoll_DocObject *)type->tp_alloc(type, 0);
|
309 |
if (self == 0)
|
311 |
if (self == 0)
|
310 |
return 0;
|
312 |
return 0;
|
311 |
self->doc = 0;
|
313 |
self->doc = 0;
|
|
... |
|
... |
336 |
);
|
338 |
);
|
337 |
|
339 |
|
338 |
static PyObject *
|
340 |
static PyObject *
|
339 |
Doc_getbinurl(recoll_DocObject *self)
|
341 |
Doc_getbinurl(recoll_DocObject *self)
|
340 |
{
|
342 |
{
|
341 |
LOGDEB(("Doc_getbinurl\n"));
|
343 |
LOGDEB0(("Doc_getbinurl\n"));
|
342 |
if (self->doc == 0 ||
|
344 |
if (self->doc == 0 ||
|
343 |
the_docs.find(self->doc) == the_docs.end()) {
|
345 |
the_docs.find(self->doc) == the_docs.end()) {
|
344 |
PyErr_SetString(PyExc_AttributeError, "doc");
|
346 |
PyErr_SetString(PyExc_AttributeError, "doc");
|
345 |
return 0;
|
347 |
return 0;
|
346 |
}
|
348 |
}
|
|
... |
|
... |
355 |
);
|
357 |
);
|
356 |
|
358 |
|
357 |
static PyObject *
|
359 |
static PyObject *
|
358 |
Doc_setbinurl(recoll_DocObject *self, PyObject *value)
|
360 |
Doc_setbinurl(recoll_DocObject *self, PyObject *value)
|
359 |
{
|
361 |
{
|
|
|
362 |
LOGDEB0(("Doc_setbinurl\n"));
|
360 |
if (self->doc == 0 ||
|
363 |
if (self->doc == 0 ||
|
361 |
the_docs.find(self->doc) == the_docs.end()) {
|
364 |
the_docs.find(self->doc) == the_docs.end()) {
|
362 |
PyErr_SetString(PyExc_AttributeError, "doc??");
|
365 |
PyErr_SetString(PyExc_AttributeError, "doc??");
|
363 |
return 0;
|
366 |
return 0;
|
364 |
}
|
367 |
}
|
|
... |
|
... |
376 |
"keys() -> list of doc object keys (attribute names)\n"
|
379 |
"keys() -> list of doc object keys (attribute names)\n"
|
377 |
);
|
380 |
);
|
378 |
static PyObject *
|
381 |
static PyObject *
|
379 |
Doc_keys(recoll_DocObject *self)
|
382 |
Doc_keys(recoll_DocObject *self)
|
380 |
{
|
383 |
{
|
381 |
LOGDEB(("Doc_keys\n"));
|
384 |
LOGDEB0(("Doc_keys\n"));
|
382 |
if (self->doc == 0 ||
|
385 |
if (self->doc == 0 ||
|
383 |
the_docs.find(self->doc) == the_docs.end()) {
|
386 |
the_docs.find(self->doc) == the_docs.end()) {
|
384 |
PyErr_SetString(PyExc_AttributeError, "doc");
|
387 |
PyErr_SetString(PyExc_AttributeError, "doc");
|
385 |
return 0;
|
388 |
return 0;
|
386 |
}
|
389 |
}
|
|
... |
|
... |
401 |
"items() -> dictionary of doc object keys/values\n"
|
404 |
"items() -> dictionary of doc object keys/values\n"
|
402 |
);
|
405 |
);
|
403 |
static PyObject *
|
406 |
static PyObject *
|
404 |
Doc_items(recoll_DocObject *self)
|
407 |
Doc_items(recoll_DocObject *self)
|
405 |
{
|
408 |
{
|
406 |
LOGDEB(("Doc_items\n"));
|
409 |
LOGDEB0(("Doc_items\n"));
|
407 |
if (self->doc == 0 ||
|
410 |
if (self->doc == 0 ||
|
408 |
the_docs.find(self->doc) == the_docs.end()) {
|
411 |
the_docs.find(self->doc) == the_docs.end()) {
|
409 |
PyErr_SetString(PyExc_AttributeError, "doc");
|
412 |
PyErr_SetString(PyExc_AttributeError, "doc");
|
410 |
return 0;
|
413 |
return 0;
|
411 |
}
|
414 |
}
|
|
... |
|
... |
431 |
"Retrieve the named doc attribute\n"
|
434 |
"Retrieve the named doc attribute\n"
|
432 |
);
|
435 |
);
|
433 |
static PyObject *
|
436 |
static PyObject *
|
434 |
Doc_get(recoll_DocObject *self, PyObject *args)
|
437 |
Doc_get(recoll_DocObject *self, PyObject *args)
|
435 |
{
|
438 |
{
|
436 |
LOGDEB(("Doc_get\n"));
|
439 |
LOGDEB0(("Doc_get\n"));
|
437 |
char *sutf8 = 0; // needs freeing
|
440 |
char *sutf8 = 0; // needs freeing
|
438 |
if (!PyArg_ParseTuple(args, "es:Doc_get",
|
441 |
if (!PyArg_ParseTuple(args, "es:Doc_get",
|
439 |
"utf-8", &sutf8)) {
|
442 |
"utf-8", &sutf8)) {
|
440 |
return 0;
|
443 |
return 0;
|
441 |
}
|
444 |
}
|
|
... |
|
... |
485 |
// an exception as would be standard. We don't change it to keep existing code
|
488 |
// an exception as would be standard. We don't change it to keep existing code
|
486 |
// working.
|
489 |
// working.
|
487 |
static PyObject *
|
490 |
static PyObject *
|
488 |
Doc_getattro(recoll_DocObject *self, PyObject *nameobj)
|
491 |
Doc_getattro(recoll_DocObject *self, PyObject *nameobj)
|
489 |
{
|
492 |
{
|
|
|
493 |
LOGDEB0(("Doc_getattro\n"));
|
490 |
if (self->doc == 0 || the_docs.find(self->doc) == the_docs.end()) {
|
494 |
if (self->doc == 0 || the_docs.find(self->doc) == the_docs.end()) {
|
491 |
PyErr_SetString(PyExc_AttributeError, "doc");
|
495 |
PyErr_SetString(PyExc_AttributeError, "doc");
|
492 |
return 0;
|
496 |
return 0;
|
493 |
}
|
497 |
}
|
494 |
|
498 |
|
|
... |
|
... |
512 |
} else {
|
516 |
} else {
|
513 |
PyErr_SetString(PyExc_AttributeError, "name not unicode nor string??");
|
517 |
PyErr_SetString(PyExc_AttributeError, "name not unicode nor string??");
|
514 |
Py_RETURN_NONE;
|
518 |
Py_RETURN_NONE;
|
515 |
}
|
519 |
}
|
516 |
|
520 |
|
517 |
key = rclconfig->fieldCanon(string(name));
|
521 |
key = rclconfig->fieldQCanon(string(name));
|
518 |
|
522 |
|
519 |
switch (key.at(0)) {
|
523 |
switch (key.at(0)) {
|
520 |
case 'u':
|
524 |
case 'u':
|
521 |
if (!key.compare(Rcl::Doc::keyurl)) {
|
525 |
if (!key.compare(Rcl::Doc::keyurl)) {
|
522 |
value = self->doc->url; found = true;
|
526 |
value = self->doc->url; found = true;
|
|
... |
|
... |
603 |
}
|
607 |
}
|
604 |
|
608 |
|
605 |
static int
|
609 |
static int
|
606 |
Doc_setattr(recoll_DocObject *self, char *name, PyObject *value)
|
610 |
Doc_setattr(recoll_DocObject *self, char *name, PyObject *value)
|
607 |
{
|
611 |
{
|
|
|
612 |
LOGDEB0(("Doc_setattr: doc %p\n", self->doc));
|
608 |
if (self->doc == 0 || the_docs.find(self->doc) == the_docs.end()) {
|
613 |
if (self->doc == 0 || the_docs.find(self->doc) == the_docs.end()) {
|
609 |
PyErr_SetString(PyExc_AttributeError, "doc??");
|
614 |
PyErr_SetString(PyExc_AttributeError, "doc??");
|
610 |
return -1;
|
615 |
return -1;
|
611 |
}
|
616 |
}
|
612 |
LOGDEB1(("Doc_setmeta: doc %p\n", self->doc));
|
|
|
613 |
|
617 |
|
614 |
#if PY_MAJOR_VERSION < 3
|
618 |
#if PY_MAJOR_VERSION < 3
|
615 |
if (PyString_Check(value)) {
|
619 |
if (PyString_Check(value)) {
|
616 |
value = PyUnicode_FromObject(value);
|
620 |
value = PyUnicode_FromObject(value);
|
617 |
if (value == 0)
|
621 |
if (value == 0)
|
|
... |
|
... |
634 |
PyErr_SetString(PyExc_AttributeError, "value??");
|
638 |
PyErr_SetString(PyExc_AttributeError, "value??");
|
635 |
return -1;
|
639 |
return -1;
|
636 |
}
|
640 |
}
|
637 |
char* uvalue = PyBytes_AsString(putf8);
|
641 |
char* uvalue = PyBytes_AsString(putf8);
|
638 |
Py_DECREF(putf8);
|
642 |
Py_DECREF(putf8);
|
639 |
string key = rclconfig->fieldCanon(string(name));
|
643 |
string key = rclconfig->fieldQCanon(string(name));
|
640 |
|
644 |
|
641 |
LOGDEB0(("Doc_setattr: [%s] (%s) -> [%s]\n", key.c_str(), name, uvalue));
|
645 |
LOGDEB0(("Doc_setattr: [%s] (%s) -> [%s]\n", key.c_str(), name, uvalue));
|
642 |
// We set the value in the meta array in all cases. Good idea ? or do it
|
646 |
// We set the value in the meta array in all cases. Good idea ? or do it
|
643 |
// only for fields without a dedicated Doc:: entry?
|
647 |
// only for fields without a dedicated Doc:: entry?
|
644 |
self->doc->meta[key] = uvalue;
|
648 |
self->doc->meta[key] = uvalue;
|
|
... |
|
... |
791 |
} recoll_QueryObject;
|
795 |
} recoll_QueryObject;
|
792 |
|
796 |
|
793 |
PyDoc_STRVAR(doc_Query_close,
|
797 |
PyDoc_STRVAR(doc_Query_close,
|
794 |
"close(). Deallocate query. Object is unusable after the call."
|
798 |
"close(). Deallocate query. Object is unusable after the call."
|
795 |
);
|
799 |
);
|
796 |
static void
|
800 |
static PyObject *
|
797 |
Query_close(recoll_QueryObject *self)
|
801 |
Query_close(recoll_QueryObject *self)
|
798 |
{
|
802 |
{
|
799 |
LOGDEB(("Query_close\n"));
|
803 |
LOGDEB(("Query_close\n"));
|
800 |
if (self->query)
|
804 |
if (self->query) {
|
801 |
the_queries.erase(self->query);
|
805 |
the_queries.erase(self->query);
|
802 |
deleteZ(self->query);
|
806 |
deleteZ(self->query);
|
|
|
807 |
}
|
803 |
deleteZ(self->sortfield);
|
808 |
deleteZ(self->sortfield);
|
804 |
if (self->connection)
|
809 |
if (self->connection) {
|
805 |
Py_DECREF(self->connection);
|
810 |
Py_DECREF(self->connection);
|
|
|
811 |
self->connection = 0;
|
|
|
812 |
}
|
|
|
813 |
Py_RETURN_NONE;
|
806 |
}
|
814 |
}
|
807 |
|
815 |
|
808 |
static void
|
816 |
static void
|
809 |
Query_dealloc(recoll_QueryObject *self)
|
817 |
Query_dealloc(recoll_QueryObject *self)
|
810 |
{
|
818 |
{
|
811 |
LOGDEB(("Query_dealloc\n"));
|
819 |
LOGDEB(("Query_dealloc\n"));
|
812 |
Query_close(self);
|
820 |
PyObject *ret = Query_close(self);
|
|
|
821 |
Py_DECREF(ret);
|
813 |
Py_TYPE(self)->tp_free((PyObject*)self);
|
822 |
Py_TYPE(self)->tp_free((PyObject*)self);
|
814 |
}
|
823 |
}
|
815 |
|
824 |
|
816 |
static PyObject *
|
825 |
static PyObject *
|
817 |
Query_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
826 |
Query_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
818 |
{
|
827 |
{
|
|
|
828 |
LOGDEB(("Query_new\n"));
|
819 |
recoll_QueryObject *self;
|
829 |
recoll_QueryObject *self;
|
820 |
LOGDEB(("Query_new\n"));
|
|
|
821 |
|
830 |
|
822 |
self = (recoll_QueryObject *)type->tp_alloc(type, 0);
|
831 |
self = (recoll_QueryObject *)type->tp_alloc(type, 0);
|
823 |
if (self == 0)
|
832 |
if (self == 0)
|
824 |
return 0;
|
833 |
return 0;
|
825 |
self->query = 0;
|
834 |
self->query = 0;
|
|
... |
|
... |
850 |
}
|
859 |
}
|
851 |
|
860 |
|
852 |
static PyObject *
|
861 |
static PyObject *
|
853 |
Query_iter(PyObject *self)
|
862 |
Query_iter(PyObject *self)
|
854 |
{
|
863 |
{
|
|
|
864 |
Py_INCREF(self);
|
855 |
return self;
|
865 |
return self;
|
856 |
}
|
866 |
}
|
857 |
|
867 |
|
858 |
PyDoc_STRVAR(doc_Query_sortby,
|
868 |
PyDoc_STRVAR(doc_Query_sortby,
|
859 |
"sortby(field=fieldname, ascending=True)\n"
|
869 |
"sortby(field=fieldname, ascending=True)\n"
|
|
... |
|
... |
863 |
);
|
873 |
);
|
864 |
|
874 |
|
865 |
static PyObject *
|
875 |
static PyObject *
|
866 |
Query_sortby(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
|
876 |
Query_sortby(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
|
867 |
{
|
877 |
{
|
868 |
LOGDEB(("Query_sortby\n"));
|
878 |
LOGDEB0(("Query_sortby\n"));
|
869 |
static const char *kwlist[] = {"field", "ascending", NULL};
|
879 |
static const char *kwlist[] = {"field", "ascending", NULL};
|
870 |
char *sfield = 0;
|
880 |
char *sfield = 0;
|
871 |
PyObject *ascobj = 0;
|
881 |
PyObject *ascobj = 0;
|
872 |
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|O", (char**)kwlist,
|
882 |
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|O", (char**)kwlist,
|
873 |
&sfield,
|
883 |
&sfield,
|
|
... |
|
... |
897 |
);
|
907 |
);
|
898 |
|
908 |
|
899 |
static PyObject *
|
909 |
static PyObject *
|
900 |
Query_execute(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
|
910 |
Query_execute(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
|
901 |
{
|
911 |
{
|
902 |
LOGDEB1(("Query_execute\n"));
|
912 |
LOGDEB0(("Query_execute\n"));
|
903 |
static const char *kwlist[] = {"query_string", "stemming", "stemlang", NULL};
|
913 |
static const char *kwlist[] = {"query_string", "stemming", "stemlang", NULL};
|
904 |
char *sutf8 = 0; // needs freeing
|
914 |
char *sutf8 = 0; // needs freeing
|
905 |
char *sstemlang = 0;
|
915 |
char *sstemlang = 0;
|
906 |
int dostem = 1;
|
916 |
int dostem = 1;
|
907 |
PyObject *dostemobj = 0;
|
917 |
PyObject *dostemobj = 0;
|
|
... |
|
... |
920 |
if (sstemlang) {
|
930 |
if (sstemlang) {
|
921 |
stemlang.assign(sstemlang);
|
931 |
stemlang.assign(sstemlang);
|
922 |
PyMem_Free(sstemlang);
|
932 |
PyMem_Free(sstemlang);
|
923 |
}
|
933 |
}
|
924 |
|
934 |
|
925 |
LOGDEB(("Query_execute: [%s] dostem %d stemlang [%s]\n", utf8.c_str(),
|
935 |
LOGDEB0(("Query_execute: [%s] dostem %d stemlang [%s]\n", utf8.c_str(),
|
926 |
dostem, stemlang.c_str()));
|
936 |
dostem, stemlang.c_str()));
|
927 |
|
937 |
|
928 |
if (self->query == 0 ||
|
938 |
if (self->query == 0 ||
|
929 |
the_queries.find(self->query) == the_queries.end()) {
|
939 |
the_queries.find(self->query) == the_queries.end()) {
|
930 |
PyErr_SetString(PyExc_AttributeError, "query");
|
940 |
PyErr_SetString(PyExc_AttributeError, "query");
|
|
... |
|
... |
958 |
);
|
968 |
);
|
959 |
|
969 |
|
960 |
static PyObject *
|
970 |
static PyObject *
|
961 |
Query_executesd(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
|
971 |
Query_executesd(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
|
962 |
{
|
972 |
{
|
|
|
973 |
LOGDEB0(("Query_executeSD\n"));
|
963 |
static const char *kwlist[] = {"searchdata", NULL};
|
974 |
static const char *kwlist[] = {"searchdata", NULL};
|
964 |
recoll_SearchDataObject *pysd = 0;
|
975 |
recoll_SearchDataObject *pysd = 0;
|
965 |
LOGDEB(("Query_executeSD\n"));
|
|
|
966 |
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:Query_execute",
|
976 |
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:Query_execute",
|
967 |
(char **)kwlist,
|
977 |
(char **)kwlist,
|
968 |
&recoll_SearchDataType, &pysd)) {
|
978 |
&recoll_SearchDataType, &pysd)) {
|
969 |
return 0;
|
979 |
return 0;
|
970 |
}
|
980 |
}
|
|
... |
|
... |
1000 |
"Fetches the next Doc object in the current search results.\n"
|
1010 |
"Fetches the next Doc object in the current search results.\n"
|
1001 |
);
|
1011 |
);
|
1002 |
static PyObject *
|
1012 |
static PyObject *
|
1003 |
Query_fetchone(PyObject *_self)
|
1013 |
Query_fetchone(PyObject *_self)
|
1004 |
{
|
1014 |
{
|
|
|
1015 |
LOGDEB0(("Query_fetchone/next\n"));
|
1005 |
recoll_QueryObject* self = (recoll_QueryObject*)_self;
|
1016 |
recoll_QueryObject* self = (recoll_QueryObject*)_self;
|
1006 |
LOGDEB(("Query_fetchone/next\n"));
|
|
|
1007 |
|
1017 |
|
1008 |
if (self->query == 0 ||
|
1018 |
if (self->query == 0 ||
|
1009 |
the_queries.find(self->query) == the_queries.end()) {
|
1019 |
the_queries.find(self->query) == the_queries.end()) {
|
1010 |
PyErr_SetString(PyExc_AttributeError, "query");
|
1020 |
PyErr_SetString(PyExc_AttributeError, "query");
|
1011 |
return 0;
|
1021 |
return 0;
|
|
... |
|
... |
1042 |
"Fetches the next Doc objects in the current search results.\n"
|
1052 |
"Fetches the next Doc objects in the current search results.\n"
|
1043 |
);
|
1053 |
);
|
1044 |
static PyObject *
|
1054 |
static PyObject *
|
1045 |
Query_fetchmany(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
|
1055 |
Query_fetchmany(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
|
1046 |
{
|
1056 |
{
|
1047 |
LOGDEB(("Query_fetchmany\n"));
|
1057 |
LOGDEB0(("Query_fetchmany\n"));
|
1048 |
static const char *kwlist[] = {"size", NULL};
|
1058 |
static const char *kwlist[] = {"size", NULL};
|
1049 |
int size = 0;
|
1059 |
int size = 0;
|
1050 |
|
1060 |
|
1051 |
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i", (char**)kwlist,
|
1061 |
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i", (char**)kwlist,
|
1052 |
&size))
|
1062 |
&size))
|
|
... |
|
... |
1094 |
"Adjusts the position in the current result set.\n"
|
1104 |
"Adjusts the position in the current result set.\n"
|
1095 |
);
|
1105 |
);
|
1096 |
static PyObject *
|
1106 |
static PyObject *
|
1097 |
Query_scroll(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
|
1107 |
Query_scroll(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
|
1098 |
{
|
1108 |
{
|
1099 |
LOGDEB(("Query_scroll\n"));
|
1109 |
LOGDEB0(("Query_scroll\n"));
|
1100 |
static const char *kwlist[] = {"position", "mode", NULL};
|
1110 |
static const char *kwlist[] = {"position", "mode", NULL};
|
1101 |
int pos = 0;
|
1111 |
int pos = 0;
|
1102 |
char *smode = 0;
|
1112 |
char *smode = 0;
|
1103 |
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|s", (char**)kwlist,
|
1113 |
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|s", (char**)kwlist,
|
1104 |
&pos, &smode))
|
1114 |
&pos, &smode))
|
|
... |
|
... |
1181 |
};
|
1191 |
};
|
1182 |
|
1192 |
|
1183 |
static PyObject *
|
1193 |
static PyObject *
|
1184 |
Query_highlight(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
|
1194 |
Query_highlight(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
|
1185 |
{
|
1195 |
{
|
1186 |
LOGDEB1(("Query_highlight\n"));
|
1196 |
LOGDEB0(("Query_highlight\n"));
|
1187 |
static const char *kwlist[] = {"text", "ishtml", "eolbr", "methods", NULL};
|
1197 |
static const char *kwlist[] = {"text", "ishtml", "eolbr", "methods", NULL};
|
1188 |
char *sutf8 = 0; // needs freeing
|
1198 |
char *sutf8 = 0; // needs freeing
|
1189 |
int ishtml = 0;
|
1199 |
int ishtml = 0;
|
1190 |
PyObject *ishtmlobj = 0;
|
1200 |
PyObject *ishtmlobj = 0;
|
1191 |
int eolbr = 1;
|
1201 |
int eolbr = 1;
|
|
... |
|
... |
1203 |
PyMem_Free(sutf8);
|
1213 |
PyMem_Free(sutf8);
|
1204 |
if (ishtmlobj && PyObject_IsTrue(ishtmlobj))
|
1214 |
if (ishtmlobj && PyObject_IsTrue(ishtmlobj))
|
1205 |
ishtml = 1;
|
1215 |
ishtml = 1;
|
1206 |
if (eolbrobj && !PyObject_IsTrue(eolbrobj))
|
1216 |
if (eolbrobj && !PyObject_IsTrue(eolbrobj))
|
1207 |
eolbr = 0;
|
1217 |
eolbr = 0;
|
1208 |
LOGDEB(("Query_highlight: ishtml %d\n", ishtml));
|
1218 |
LOGDEB0(("Query_highlight: ishtml %d\n", ishtml));
|
1209 |
|
1219 |
|
1210 |
if (self->query == 0 ||
|
1220 |
if (self->query == 0 ||
|
1211 |
the_queries.find(self->query) == the_queries.end()) {
|
1221 |
the_queries.find(self->query) == the_queries.end()) {
|
1212 |
PyErr_SetString(PyExc_AttributeError, "query");
|
1222 |
PyErr_SetString(PyExc_AttributeError, "query");
|
1213 |
return 0;
|
1223 |
return 0;
|
|
... |
|
... |
1241 |
"If methods is set, will also perform highlighting. See the highlight method\n"
|
1251 |
"If methods is set, will also perform highlighting. See the highlight method\n"
|
1242 |
);
|
1252 |
);
|
1243 |
static PyObject *
|
1253 |
static PyObject *
|
1244 |
Query_makedocabstract(recoll_QueryObject* self, PyObject *args,PyObject *kwargs)
|
1254 |
Query_makedocabstract(recoll_QueryObject* self, PyObject *args,PyObject *kwargs)
|
1245 |
{
|
1255 |
{
|
1246 |
LOGDEB(("Query_makeDocAbstract\n"));
|
1256 |
LOGDEB0(("Query_makeDocAbstract\n"));
|
1247 |
static const char *kwlist[] = {"doc", "methods", NULL};
|
1257 |
static const char *kwlist[] = {"doc", "methods", NULL};
|
1248 |
recoll_DocObject *pydoc = 0;
|
1258 |
recoll_DocObject *pydoc = 0;
|
1249 |
PyObject *hlmethods = 0;
|
1259 |
PyObject *hlmethods = 0;
|
1250 |
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!|O:Query_makeDocAbstract",
|
1260 |
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!|O:Query_makeDocAbstract",
|
1251 |
(char **)kwlist,
|
1261 |
(char **)kwlist,
|
|
... |
|
... |
1311 |
"Meaningful only after executexx\n"
|
1321 |
"Meaningful only after executexx\n"
|
1312 |
);
|
1322 |
);
|
1313 |
static PyObject *
|
1323 |
static PyObject *
|
1314 |
Query_getxquery(recoll_QueryObject* self, PyObject *, PyObject *)
|
1324 |
Query_getxquery(recoll_QueryObject* self, PyObject *, PyObject *)
|
1315 |
{
|
1325 |
{
|
1316 |
LOGDEB(("Query_getxquery self->query %p\n"));
|
1326 |
LOGDEB0(("Query_getxquery self->query %p\n", self->query));
|
1317 |
|
1327 |
|
1318 |
if (self->query == 0 ||
|
1328 |
if (self->query == 0 ||
|
1319 |
the_queries.find(self->query) == the_queries.end()) {
|
1329 |
the_queries.find(self->query) == the_queries.end()) {
|
1320 |
PyErr_SetString(PyExc_AttributeError, "query");
|
1330 |
PyErr_SetString(PyExc_AttributeError, "query");
|
1321 |
return 0;
|
1331 |
return 0;
|
|
... |
|
... |
1339 |
"clauses\n"
|
1349 |
"clauses\n"
|
1340 |
);
|
1350 |
);
|
1341 |
static PyObject *
|
1351 |
static PyObject *
|
1342 |
Query_getgroups(recoll_QueryObject* self, PyObject *, PyObject *)
|
1352 |
Query_getgroups(recoll_QueryObject* self, PyObject *, PyObject *)
|
1343 |
{
|
1353 |
{
|
1344 |
LOGDEB(("Query_getxquery\n"));
|
1354 |
LOGDEB0(("Query_getgroups\n"));
|
1345 |
|
1355 |
|
1346 |
if (self->query == 0 ||
|
1356 |
if (self->query == 0 ||
|
1347 |
the_queries.find(self->query) == the_queries.end()) {
|
1357 |
the_queries.find(self->query) == the_queries.end()) {
|
1348 |
PyErr_SetString(PyExc_AttributeError, "query");
|
1358 |
PyErr_SetString(PyExc_AttributeError, "query");
|
1349 |
return 0;
|
1359 |
return 0;
|
|
... |
|
... |
1481 |
PyObject_HEAD
|
1491 |
PyObject_HEAD
|
1482 |
/* Type-specific fields go here. */
|
1492 |
/* Type-specific fields go here. */
|
1483 |
Rcl::Db *db;
|
1493 |
Rcl::Db *db;
|
1484 |
} recoll_DbObject;
|
1494 |
} recoll_DbObject;
|
1485 |
|
1495 |
|
1486 |
static void
|
1496 |
static PyObject *
|
1487 |
Db_close(recoll_DbObject *self)
|
1497 |
Db_close(recoll_DbObject *self)
|
1488 |
{
|
1498 |
{
|
1489 |
LOGDEB(("Db_close\n"));
|
1499 |
LOGDEB(("Db_close. self %p\n", self));
|
1490 |
if (self->db)
|
1500 |
if (self->db) {
|
1491 |
the_dbs.erase(self->db);
|
1501 |
the_dbs.erase(self->db);
|
1492 |
delete self->db;
|
1502 |
delete self->db;
|
1493 |
self->db = 0;
|
1503 |
self->db = 0;
|
|
|
1504 |
}
|
|
|
1505 |
Py_RETURN_NONE;
|
1494 |
}
|
1506 |
}
|
1495 |
|
1507 |
|
1496 |
static void
|
1508 |
static void
|
1497 |
Db_dealloc(recoll_DbObject *self)
|
1509 |
Db_dealloc(recoll_DbObject *self)
|
1498 |
{
|
1510 |
{
|
1499 |
LOGDEB(("Db_dealloc\n"));
|
1511 |
LOGDEB(("Db_dealloc\n"));
|
1500 |
Db_close(self);
|
1512 |
PyObject *ret = Db_close(self);
|
|
|
1513 |
Py_DECREF(ret);
|
1501 |
Py_TYPE(self)->tp_free((PyObject*)self);
|
1514 |
Py_TYPE(self)->tp_free((PyObject*)self);
|
1502 |
}
|
1515 |
}
|
1503 |
|
1516 |
|
1504 |
static PyObject *
|
1517 |
static PyObject *
|
1505 |
Db_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
1518 |
Db_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
1506 |
{
|
1519 |
{
|
|
|
1520 |
LOGDEB2(("Db_new\n"));
|
1507 |
recoll_DbObject *self;
|
1521 |
recoll_DbObject *self;
|
1508 |
|
1522 |
|
1509 |
self = (recoll_DbObject *)type->tp_alloc(type, 0);
|
1523 |
self = (recoll_DbObject *)type->tp_alloc(type, 0);
|
1510 |
if (self == 0)
|
1524 |
if (self == 0)
|
1511 |
return 0;
|
1525 |
return 0;
|
|
... |
|
... |
1607 |
result->query = new Rcl::Query(self->db);
|
1621 |
result->query = new Rcl::Query(self->db);
|
1608 |
result->connection = self;
|
1622 |
result->connection = self;
|
1609 |
Py_INCREF(self);
|
1623 |
Py_INCREF(self);
|
1610 |
|
1624 |
|
1611 |
the_queries.insert(result->query);
|
1625 |
the_queries.insert(result->query);
|
1612 |
Py_INCREF(result);
|
|
|
1613 |
return (PyObject *)result;
|
1626 |
return (PyObject *)result;
|
1614 |
}
|
1627 |
}
|
1615 |
|
1628 |
|
1616 |
static PyObject *
|
1629 |
static PyObject *
|
1617 |
Db_setAbstractParams(recoll_DbObject *self, PyObject *args, PyObject *kwargs)
|
1630 |
Db_setAbstractParams(recoll_DbObject *self, PyObject *args, PyObject *kwargs)
|
1618 |
{
|
1631 |
{
|
1619 |
LOGDEB(("Db_setAbstractParams\n"));
|
1632 |
LOGDEB0(("Db_setAbstractParams\n"));
|
1620 |
static const char *kwlist[] = {"maxchars", "contextwords", NULL};
|
1633 |
static const char *kwlist[] = {"maxchars", "contextwords", NULL};
|
1621 |
int ctxwords = -1, maxchars = -1;
|
1634 |
int ctxwords = -1, maxchars = -1;
|
1622 |
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii", (char**)kwlist,
|
1635 |
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii", (char**)kwlist,
|
1623 |
&maxchars, &ctxwords))
|
1636 |
&maxchars, &ctxwords))
|
1624 |
return 0;
|
1637 |
return 0;
|
1625 |
if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) {
|
1638 |
if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) {
|
1626 |
LOGERR(("Db_query: db not found %p\n", self->db));
|
1639 |
LOGERR(("Db_query: db not found %p\n", self->db));
|
1627 |
PyErr_SetString(PyExc_AttributeError, "db id not found");
|
1640 |
PyErr_SetString(PyExc_AttributeError, "db id not found");
|
1628 |
return 0;
|
1641 |
return 0;
|
1629 |
}
|
1642 |
}
|
1630 |
LOGDEB(("Db_setAbstractParams: mxchrs %d, ctxwrds %d\n", maxchars, ctxwords));
|
1643 |
LOGDEB0(("Db_setAbstractParams: mxchrs %d, ctxwrds %d\n", maxchars, ctxwords));
|
1631 |
self->db->setAbstractParams(-1, maxchars, ctxwords);
|
1644 |
self->db->setAbstractParams(-1, maxchars, ctxwords);
|
1632 |
Py_RETURN_NONE;
|
1645 |
Py_RETURN_NONE;
|
1633 |
}
|
1646 |
}
|
1634 |
|
1647 |
|
1635 |
static PyObject *
|
1648 |
static PyObject *
|
1636 |
Db_makeDocAbstract(recoll_DbObject* self, PyObject *args)
|
1649 |
Db_makeDocAbstract(recoll_DbObject* self, PyObject *args)
|
1637 |
{
|
1650 |
{
|
1638 |
LOGDEB(("Db_makeDocAbstract\n"));
|
1651 |
LOGDEB0(("Db_makeDocAbstract\n"));
|
1639 |
recoll_DocObject *pydoc = 0;
|
1652 |
recoll_DocObject *pydoc = 0;
|
1640 |
recoll_QueryObject *pyquery = 0;
|
1653 |
recoll_QueryObject *pyquery = 0;
|
1641 |
if (!PyArg_ParseTuple(args, "O!O!:Db_makeDocAbstract",
|
1654 |
if (!PyArg_ParseTuple(args, "O!O!:Db_makeDocAbstract",
|
1642 |
&recoll_DocType, &pydoc,
|
1655 |
&recoll_DocType, &pydoc,
|
1643 |
&recoll_QueryType, &pyquery)) {
|
1656 |
&recoll_QueryType, &pyquery)) {
|
|
... |
|
... |
1678 |
"returns the expanded term list.\n"
|
1691 |
"returns the expanded term list.\n"
|
1679 |
);
|
1692 |
);
|
1680 |
static PyObject *
|
1693 |
static PyObject *
|
1681 |
Db_termMatch(recoll_DbObject* self, PyObject *args, PyObject *kwargs)
|
1694 |
Db_termMatch(recoll_DbObject* self, PyObject *args, PyObject *kwargs)
|
1682 |
{
|
1695 |
{
|
1683 |
LOGDEB(("Db_termMatch\n"));
|
1696 |
LOGDEB0(("Db_termMatch\n"));
|
1684 |
static const char *kwlist[] = {"type", "expr", "field", "maxlen",
|
1697 |
static const char *kwlist[] = {"type", "expr", "field", "maxlen",
|
1685 |
"casesens", "diacsens", "lang", NULL};
|
1698 |
"casesens", "diacsens", "lang", NULL};
|
1686 |
char *tp = 0;
|
1699 |
char *tp = 0;
|
1687 |
char *expr = 0; // needs freeing
|
1700 |
char *expr = 0; // needs freeing
|
1688 |
char *field = 0; // needs freeing
|
1701 |
char *field = 0; // needs freeing
|
|
... |
|
... |
1747 |
}
|
1760 |
}
|
1748 |
|
1761 |
|
1749 |
static PyObject *
|
1762 |
static PyObject *
|
1750 |
Db_needUpdate(recoll_DbObject* self, PyObject *args, PyObject *kwds)
|
1763 |
Db_needUpdate(recoll_DbObject* self, PyObject *args, PyObject *kwds)
|
1751 |
{
|
1764 |
{
|
|
|
1765 |
LOGDEB0(("Db_needUpdate\n"));
|
1752 |
char *udi = 0; // needs freeing
|
1766 |
char *udi = 0; // needs freeing
|
1753 |
char *sig = 0; // needs freeing
|
1767 |
char *sig = 0; // needs freeing
|
1754 |
LOGDEB(("Db_needUpdate\n"));
|
|
|
1755 |
if (!PyArg_ParseTuple(args, "eses:Db_needUpdate",
|
1768 |
if (!PyArg_ParseTuple(args, "eses:Db_needUpdate",
|
1756 |
"utf-8", &udi, "utf-8", &sig)) {
|
1769 |
"utf-8", &udi, "utf-8", &sig)) {
|
1757 |
return 0;
|
1770 |
return 0;
|
1758 |
}
|
1771 |
}
|
1759 |
if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) {
|
1772 |
if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) {
|
|
... |
|
... |
1770 |
}
|
1783 |
}
|
1771 |
|
1784 |
|
1772 |
static PyObject *
|
1785 |
static PyObject *
|
1773 |
Db_delete(recoll_DbObject* self, PyObject *args, PyObject *kwds)
|
1786 |
Db_delete(recoll_DbObject* self, PyObject *args, PyObject *kwds)
|
1774 |
{
|
1787 |
{
|
|
|
1788 |
LOGDEB0(("Db_delete\n"));
|
1775 |
char *udi = 0; // needs freeing
|
1789 |
char *udi = 0; // needs freeing
|
1776 |
LOGDEB(("Db_delete\n"));
|
|
|
1777 |
if (!PyArg_ParseTuple(args, "es:Db_delete", "utf-8", &udi)) {
|
1790 |
if (!PyArg_ParseTuple(args, "es:Db_delete", "utf-8", &udi)) {
|
1778 |
return 0;
|
1791 |
return 0;
|
1779 |
}
|
1792 |
}
|
1780 |
if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) {
|
1793 |
if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) {
|
1781 |
LOGERR(("Db_delete: db not found %p\n", self->db));
|
1794 |
LOGERR(("Db_delete: db not found %p\n", self->db));
|
|
... |
|
... |
1789 |
}
|
1802 |
}
|
1790 |
|
1803 |
|
1791 |
static PyObject *
|
1804 |
static PyObject *
|
1792 |
Db_purge(recoll_DbObject* self)
|
1805 |
Db_purge(recoll_DbObject* self)
|
1793 |
{
|
1806 |
{
|
|
|
1807 |
LOGDEB0(("Db_purge\n"));
|
1794 |
if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) {
|
1808 |
if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) {
|
1795 |
LOGERR(("Db_purge: db not found %p\n", self->db));
|
1809 |
LOGERR(("Db_purge: db not found %p\n", self->db));
|
1796 |
PyErr_SetString(PyExc_AttributeError, "db");
|
1810 |
PyErr_SetString(PyExc_AttributeError, "db");
|
1797 |
return 0;
|
1811 |
return 0;
|
1798 |
}
|
1812 |
}
|
|
... |
|
... |
1801 |
}
|
1815 |
}
|
1802 |
|
1816 |
|
1803 |
static PyObject *
|
1817 |
static PyObject *
|
1804 |
Db_addOrUpdate(recoll_DbObject* self, PyObject *args, PyObject *)
|
1818 |
Db_addOrUpdate(recoll_DbObject* self, PyObject *args, PyObject *)
|
1805 |
{
|
1819 |
{
|
1806 |
LOGDEB(("Db_addOrUpdate\n"));
|
1820 |
LOGDEB0(("Db_addOrUpdate\n"));
|
1807 |
char *sudi = 0; // needs freeing
|
1821 |
char *sudi = 0; // needs freeing
|
1808 |
char *sparent_udi = 0; // needs freeing
|
1822 |
char *sparent_udi = 0; // needs freeing
|
1809 |
recoll_DocObject *pydoc;
|
1823 |
recoll_DocObject *pydoc;
|
1810 |
|
1824 |
|
1811 |
if (!PyArg_ParseTuple(args, "esO!|es:Db_addOrUpdate",
|
1825 |
if (!PyArg_ParseTuple(args, "esO!|es:Db_addOrUpdate",
|
|
... |
|
... |
1942 |
//////////////////////////////////////////////////////////////////////////
|
1956 |
//////////////////////////////////////////////////////////////////////////
|
1943 |
// Module methods
|
1957 |
// Module methods
|
1944 |
static PyObject *
|
1958 |
static PyObject *
|
1945 |
recoll_connect(PyObject *self, PyObject *args, PyObject *kwargs)
|
1959 |
recoll_connect(PyObject *self, PyObject *args, PyObject *kwargs)
|
1946 |
{
|
1960 |
{
|
|
|
1961 |
LOGDEB2(("recoll_connect\n"));
|
1947 |
recoll_DbObject *db = (recoll_DbObject *)
|
1962 |
recoll_DbObject *db = (recoll_DbObject *)
|
1948 |
PyObject_Call((PyObject *)&recoll_DbType, args, kwargs);
|
1963 |
PyObject_Call((PyObject *)&recoll_DbType, args, kwargs);
|
1949 |
return (PyObject *)db;
|
1964 |
return (PyObject *)db;
|
1950 |
}
|
1965 |
}
|
1951 |
|
1966 |
|