fix executesd

This commit is contained in:
dockes 2008-10-10 08:18:27 +00:00
parent 667daba8fa
commit d282f8a838
3 changed files with 14 additions and 10 deletions

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: pyrecoll.cpp,v 1.19 2008-10-10 08:05:11 dockes Exp $ (C) 2007 J.F.Dockes";
static char rcsid[] = "@(#$Id: pyrecoll.cpp,v 1.20 2008-10-10 08:18:27 dockes Exp $ (C) 2007 J.F.Dockes";
#endif
@ -173,7 +173,7 @@ SearchData_addclause(recoll_SearchDataObject* self, PyObject *args,
char *fld = 0; // needs freeing
int dostem = 1; // needs freeing
recoll_SearchDataObject *sub = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ses|iesO!", kwlist,
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ses|iesiO!", kwlist,
&tp, "utf-8", &qs, &slack,
"utf-8", &fld, &dostem,
&recoll_SearchDataType, &sub))
@ -665,7 +665,7 @@ Query_execute(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
}
PyDoc_STRVAR(doc_Query_executesd,
"execute(SearchData)\n"
"executesd(SearchData)\n"
"\n"
"Starts a search for the query defined by the SearchData object.\n"
);
@ -676,17 +676,19 @@ Query_executesd(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
static char *kwlist[] = {"searchdata", NULL};
recoll_SearchDataObject *pysd = 0;
LOGDEB(("Query_executeSD\n"));
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!|i:Query_execute", kwlist,
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:Query_execute",
kwlist,
&recoll_SearchDataType, &pysd)) {
return 0;
}
if (self->query == 0 ||
if (pysd == 0 || self->query == 0 ||
the_queries.find(self->query) == the_queries.end()) {
PyErr_SetString(PyExc_AttributeError, "query");
return 0;
}
string sf = self->sortfield ? string(self->sortfield) : string("");
self->query->setSortBy(sf, self->ascending);
self->query->setQuery(pysd->sd);
int cnt = self->query->getResCnt();
self->next = 0;
return Py_BuildValue("i", cnt);

View File

@ -94,6 +94,8 @@ class mbox_indexer:
#print "Simple: " + ct
if ct.lower() == "text/plain":
charset = part.get_content_charset("iso-8859-1")
print "charset: ", charset
print "text: ", part.get_payload(None, True)
text += unicode(part.get_payload(None, True), charset)
doc.text = text
# dbytes

View File

@ -7,7 +7,7 @@ def dotest(db, q):
query = db.query()
query.sortby("title", 1)
nres = query.executesd(q, stemming = 1)
nres = query.executesd(q)
print "Result count: ", nres
if nres > 10:
nres = 10
@ -22,10 +22,10 @@ def dotest(db, q):
# End dotest
sd = recoll.SearchData()
sd.addClause("and", "essaouira maroc")
#sd.addClause("and", "dockes", field="author")
#sd.addClause("phrase", "jean francois", 1)
#sd.addClause("excl", "plage")
sd.addclause("and", "essaouira maroc")
#sd.addclause("and", "dockes", field="author")
#sd.addclause("phrase", "jean francois", 1)
#sd.addclause("excl", "plage")
db = recoll.connect()
dotest(db, sd)