|
a/src/python/recoll/pyrecoll.cpp |
|
b/src/python/recoll/pyrecoll.cpp |
|
... |
|
... |
53 |
//////////////////////////////////////////////////////////////////////
|
53 |
//////////////////////////////////////////////////////////////////////
|
54 |
/// SEARCHDATA SearchData code
|
54 |
/// SEARCHDATA SearchData code
|
55 |
typedef struct {
|
55 |
typedef struct {
|
56 |
PyObject_HEAD
|
56 |
PyObject_HEAD
|
57 |
/* Type-specific fields go here. */
|
57 |
/* Type-specific fields go here. */
|
58 |
RefCntr<Rcl::SearchData> sd;
|
58 |
STD_SHARED_PTR<Rcl::SearchData> sd;
|
59 |
} recoll_SearchDataObject;
|
59 |
} recoll_SearchDataObject;
|
60 |
|
60 |
|
61 |
static void
|
61 |
static void
|
62 |
SearchData_dealloc(recoll_SearchDataObject *self)
|
62 |
SearchData_dealloc(recoll_SearchDataObject *self)
|
63 |
{
|
63 |
{
|
64 |
LOGDEB(("SearchData_dealloc. Releasing. Count before: %d\n",
|
64 |
LOGDEB(("SearchData_dealloc. Releasing. Count before: %d\n",
|
65 |
self->sd.getcnt()));
|
65 |
self->sd.use_count()));
|
66 |
self->sd.release();
|
66 |
self->sd.reset();
|
67 |
Py_TYPE(self)->tp_free((PyObject*)self);
|
67 |
Py_TYPE(self)->tp_free((PyObject*)self);
|
68 |
}
|
68 |
}
|
69 |
|
69 |
|
70 |
static PyObject *
|
70 |
static PyObject *
|
71 |
SearchData_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
71 |
SearchData_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|
... |
|
... |
106 |
if (steml) {
|
106 |
if (steml) {
|
107 |
stemlang = steml;
|
107 |
stemlang = steml;
|
108 |
} else {
|
108 |
} else {
|
109 |
stemlang = "english";
|
109 |
stemlang = "english";
|
110 |
}
|
110 |
}
|
111 |
self->sd = RefCntr<Rcl::SearchData>(new Rcl::SearchData(tp, stemlang));
|
111 |
self->sd = STD_SHARED_PTR<Rcl::SearchData>(new Rcl::SearchData(tp, stemlang));
|
112 |
return 0;
|
112 |
return 0;
|
113 |
}
|
113 |
}
|
114 |
|
114 |
|
115 |
/* Note: addclause necessite And/Or vient du fait que le string peut avoir
|
115 |
/* Note: addclause necessite And/Or vient du fait que le string peut avoir
|
116 |
plusieurs mots. A transferer dans l'i/f Python ou pas ? */
|
116 |
plusieurs mots. A transferer dans l'i/f Python ou pas ? */
|
|
... |
|
... |
178 |
static PyObject *
|
178 |
static PyObject *
|
179 |
SearchData_addclause(recoll_SearchDataObject* self, PyObject *args,
|
179 |
SearchData_addclause(recoll_SearchDataObject* self, PyObject *args,
|
180 |
PyObject *kwargs)
|
180 |
PyObject *kwargs)
|
181 |
{
|
181 |
{
|
182 |
LOGDEB0(("SearchData_addclause\n"));
|
182 |
LOGDEB0(("SearchData_addclause\n"));
|
183 |
if (self->sd.isNull()) {
|
183 |
if (!self->sd) {
|
184 |
LOGERR(("SearchData_addclause: not init??\n"));
|
184 |
LOGERR(("SearchData_addclause: not init??\n"));
|
185 |
PyErr_SetString(PyExc_AttributeError, "sd");
|
185 |
PyErr_SetString(PyExc_AttributeError, "sd");
|
186 |
return 0;
|
186 |
return 0;
|
187 |
}
|
187 |
}
|
188 |
static const char *kwlist[] = {"type", "qstring", "slack", "field",
|
188 |
static const char *kwlist[] = {"type", "qstring", "slack", "field",
|
|
... |
|
... |
949 |
if (!sd) {
|
949 |
if (!sd) {
|
950 |
PyErr_SetString(PyExc_ValueError, reason.c_str());
|
950 |
PyErr_SetString(PyExc_ValueError, reason.c_str());
|
951 |
return 0;
|
951 |
return 0;
|
952 |
}
|
952 |
}
|
953 |
|
953 |
|
954 |
RefCntr<Rcl::SearchData> rq(sd);
|
954 |
STD_SHARED_PTR<Rcl::SearchData> rq(sd);
|
955 |
self->query->setSortBy(*self->sortfield, self->ascending);
|
955 |
self->query->setSortBy(*self->sortfield, self->ascending);
|
956 |
self->query->setQuery(rq);
|
956 |
self->query->setQuery(rq);
|
957 |
int cnt = self->query->getResCnt();
|
957 |
int cnt = self->query->getResCnt();
|
958 |
self->next = 0;
|
958 |
self->next = 0;
|
959 |
self->rowcount = cnt;
|
959 |
self->rowcount = cnt;
|
|
... |
|
... |
1220 |
the_queries.find(self->query) == the_queries.end()) {
|
1220 |
the_queries.find(self->query) == the_queries.end()) {
|
1221 |
PyErr_SetString(PyExc_AttributeError, "query");
|
1221 |
PyErr_SetString(PyExc_AttributeError, "query");
|
1222 |
return 0;
|
1222 |
return 0;
|
1223 |
}
|
1223 |
}
|
1224 |
|
1224 |
|
1225 |
RefCntr<Rcl::SearchData> sd = self->query->getSD();
|
1225 |
STD_SHARED_PTR<Rcl::SearchData> sd = self->query->getSD();
|
1226 |
if (sd.isNull()) {
|
1226 |
if (!sd) {
|
1227 |
PyErr_SetString(PyExc_ValueError, "Query not initialized");
|
1227 |
PyErr_SetString(PyExc_ValueError, "Query not initialized");
|
1228 |
return 0;
|
1228 |
return 0;
|
1229 |
}
|
1229 |
}
|
1230 |
HighlightData hldata;
|
1230 |
HighlightData hldata;
|
1231 |
sd->getTerms(hldata);
|
1231 |
sd->getTerms(hldata);
|
|
... |
|
... |
1271 |
if (the_queries.find(self->query) == the_queries.end()) {
|
1271 |
if (the_queries.find(self->query) == the_queries.end()) {
|
1272 |
LOGERR(("Query_makeDocAbstract: query not found %p\n", self->query));
|
1272 |
LOGERR(("Query_makeDocAbstract: query not found %p\n", self->query));
|
1273 |
PyErr_SetString(PyExc_AttributeError, "query");
|
1273 |
PyErr_SetString(PyExc_AttributeError, "query");
|
1274 |
return 0;
|
1274 |
return 0;
|
1275 |
}
|
1275 |
}
|
1276 |
RefCntr<Rcl::SearchData> sd = self->query->getSD();
|
1276 |
STD_SHARED_PTR<Rcl::SearchData> sd = self->query->getSD();
|
1277 |
if (sd.isNull()) {
|
1277 |
if (!sd) {
|
1278 |
PyErr_SetString(PyExc_ValueError, "Query not initialized");
|
1278 |
PyErr_SetString(PyExc_ValueError, "Query not initialized");
|
1279 |
return 0;
|
1279 |
return 0;
|
1280 |
}
|
1280 |
}
|
1281 |
string abstract;
|
1281 |
string abstract;
|
1282 |
if (hlmethods == 0) {
|
1282 |
if (hlmethods == 0) {
|
|
... |
|
... |
1327 |
if (self->query == 0 ||
|
1327 |
if (self->query == 0 ||
|
1328 |
the_queries.find(self->query) == the_queries.end()) {
|
1328 |
the_queries.find(self->query) == the_queries.end()) {
|
1329 |
PyErr_SetString(PyExc_AttributeError, "query");
|
1329 |
PyErr_SetString(PyExc_AttributeError, "query");
|
1330 |
return 0;
|
1330 |
return 0;
|
1331 |
}
|
1331 |
}
|
1332 |
RefCntr<Rcl::SearchData> sd = self->query->getSD();
|
1332 |
STD_SHARED_PTR<Rcl::SearchData> sd = self->query->getSD();
|
1333 |
if (sd.isNull()) {
|
1333 |
if (!sd) {
|
1334 |
PyErr_SetString(PyExc_ValueError, "Query not initialized");
|
1334 |
PyErr_SetString(PyExc_ValueError, "Query not initialized");
|
1335 |
return 0;
|
1335 |
return 0;
|
1336 |
}
|
1336 |
}
|
1337 |
string desc = sd->getDescription();
|
1337 |
string desc = sd->getDescription();
|
1338 |
return PyUnicode_Decode(desc.c_str(), desc.size(), "UTF-8", "replace");
|
1338 |
return PyUnicode_Decode(desc.c_str(), desc.size(), "UTF-8", "replace");
|
|
... |
|
... |
1355 |
if (self->query == 0 ||
|
1355 |
if (self->query == 0 ||
|
1356 |
the_queries.find(self->query) == the_queries.end()) {
|
1356 |
the_queries.find(self->query) == the_queries.end()) {
|
1357 |
PyErr_SetString(PyExc_AttributeError, "query");
|
1357 |
PyErr_SetString(PyExc_AttributeError, "query");
|
1358 |
return 0;
|
1358 |
return 0;
|
1359 |
}
|
1359 |
}
|
1360 |
RefCntr<Rcl::SearchData> sd = self->query->getSD();
|
1360 |
STD_SHARED_PTR<Rcl::SearchData> sd = self->query->getSD();
|
1361 |
if (sd.isNull()) {
|
1361 |
if (!sd) {
|
1362 |
PyErr_SetString(PyExc_ValueError, "Query not initialized");
|
1362 |
PyErr_SetString(PyExc_ValueError, "Query not initialized");
|
1363 |
return 0;
|
1363 |
return 0;
|
1364 |
}
|
1364 |
}
|
1365 |
HighlightData hld;
|
1365 |
HighlightData hld;
|
1366 |
sd->getTerms(hld);
|
1366 |
sd->getTerms(hld);
|