make python recoll a package with 2 modules recoll and rclextract

This commit is contained in:
Jean-Francois Dockes
2012-12-20 17:05:34 +01:00
parent aa9518ef25
commit 9cc826168b
7 changed files with 51 additions and 15 deletions
+20 -6
View File
@@ -6,9 +6,15 @@ This could actually be useful for something after some customization
import sys
from getopt import getopt
import recoll
import rclextract
try:
from recoll import recoll
from recoll import rclextract
hasextract = True
except:
import recoll
hasextract = False
allmeta = ("title", "keywords", "abstract", "url", "mimetype", "mtime",
"ipath", "fbytes", "dbytes", "relevancyrating")
@@ -27,9 +33,15 @@ class ptrmeths:
def extract(doc):
extractor = rclextract.Extractor(doc)
newdoc = extractor.extract(doc.ipath)
newdoc = extractor.textextract(doc.ipath)
return newdoc
def extractofile(doc, outfilename=""):
extractor = rclextract.Extractor(doc)
outfilename = extractor.idoctofile(doc.ipath, doc.mimetype, \
ofilename=outfilename)
return outfilename
def doquery(db, q):
# Get query object
query = db.query()
@@ -48,9 +60,11 @@ def doquery(db, q):
while query.next >= 0 and query.next < nres:
doc = query.fetchone()
print query.next, ":",
# for k,v in doc.items().items():
# print "KEY:", k.encode('utf-8'), "VALUE", v.encode('utf-8')
# continue
#for k,v in doc.items().items():
#print "KEY:", k.encode('utf-8'), "VALUE", v.encode('utf-8')
#continue
#outfile = extractofile(doc)
#print "outfile:", outfile, "url", doc.url.encode("utf-8")
for k in ("title", "mtime", "author"):
value = getattr(doc, k)
# value = doc.get(k)