|
a/src/python/recoll/pyrecoll.cpp |
|
b/src/python/recoll/pyrecoll.cpp |
|
... |
|
... |
401 |
"items() -> dictionary of doc object keys/values\n"
|
401 |
"items() -> dictionary of doc object keys/values\n"
|
402 |
);
|
402 |
);
|
403 |
static PyObject *
|
403 |
static PyObject *
|
404 |
Doc_items(recoll_DocObject *self)
|
404 |
Doc_items(recoll_DocObject *self)
|
405 |
{
|
405 |
{
|
406 |
LOGDEB(("Doc_getbinurl\n"));
|
406 |
LOGDEB(("Doc_items\n"));
|
407 |
if (self->doc == 0 ||
|
407 |
if (self->doc == 0 ||
|
408 |
the_docs.find(self->doc) == the_docs.end()) {
|
408 |
the_docs.find(self->doc) == the_docs.end()) {
|
409 |
PyErr_SetString(PyExc_AttributeError, "doc");
|
409 |
PyErr_SetString(PyExc_AttributeError, "doc");
|
410 |
return 0;
|
410 |
return 0;
|
411 |
}
|
411 |
}
|
|
... |
|
... |
446 |
the_docs.find(self->doc) == the_docs.end()) {
|
446 |
the_docs.find(self->doc) == the_docs.end()) {
|
447 |
PyErr_SetString(PyExc_AttributeError, "doc??");
|
447 |
PyErr_SetString(PyExc_AttributeError, "doc??");
|
448 |
return 0;
|
448 |
return 0;
|
449 |
}
|
449 |
}
|
450 |
string value;
|
450 |
string value;
|
|
|
451 |
bool found = false;
|
|
|
452 |
|
|
|
453 |
//
|
|
|
454 |
if (!key.compare("xdocid")) {
|
|
|
455 |
char cid[30];
|
|
|
456 |
sprintf(cid, "%lu", (unsigned long)self->doc->xdocid);
|
|
|
457 |
value = cid;
|
|
|
458 |
found = true;
|
|
|
459 |
} else {
|
451 |
if (self->doc->getmeta(key, 0)) {
|
460 |
if (self->doc->getmeta(key, 0)) {
|
452 |
value = self->doc->meta[key];
|
461 |
value = self->doc->meta[key];
|
|
|
462 |
found = true;
|
|
|
463 |
}
|
|
|
464 |
}
|
|
|
465 |
|
|
|
466 |
if (found) {
|
453 |
return PyUnicode_Decode(value.c_str(),
|
467 |
return PyUnicode_Decode(value.c_str(),
|
454 |
value.size(),
|
468 |
value.size(),
|
455 |
"UTF-8", "replace");
|
469 |
"UTF-8", "replace");
|
456 |
}
|
470 |
}
|
|
|
471 |
|
457 |
Py_RETURN_NONE;
|
472 |
Py_RETURN_NONE;
|
458 |
}
|
473 |
}
|
459 |
|
474 |
|
460 |
static PyMethodDef Doc_methods[] = {
|
475 |
static PyMethodDef Doc_methods[] = {
|
461 |
{"getbinurl", (PyCFunction)Doc_getbinurl, METH_NOARGS, doc_Doc_getbinurl},
|
476 |
{"getbinurl", (PyCFunction)Doc_getbinurl, METH_NOARGS, doc_Doc_getbinurl},
|
|
... |
|
... |
550 |
case 't':
|
565 |
case 't':
|
551 |
if (!key.compare("text")) {
|
566 |
if (!key.compare("text")) {
|
552 |
value = self->doc->text; found = true;
|
567 |
value = self->doc->text; found = true;
|
553 |
}
|
568 |
}
|
554 |
break;
|
569 |
break;
|
|
|
570 |
case 'x':
|
|
|
571 |
if (!key.compare("xdocid")) {
|
|
|
572 |
char cid[30];
|
|
|
573 |
sprintf(cid, "%lu", (unsigned long)self->doc->xdocid);
|
|
|
574 |
value = cid;
|
|
|
575 |
found = true;
|
|
|
576 |
}
|
|
|
577 |
break;
|
555 |
}
|
578 |
}
|
556 |
|
579 |
|
557 |
if (!found) {
|
580 |
if (!found) {
|
558 |
// This will look up a method name (we have no other standard
|
581 |
// This will look up a method name (we have no other standard
|
559 |
// attributes)
|
582 |
// attributes)
|