doc
This commit is contained in:
commit
8e86e6a440
1115 changed files with 428332 additions and 0 deletions
40
tests/pythonapi/simple.py
Normal file
40
tests/pythonapi/simple.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
import sys
|
||||
from recoll import recoll
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
ISP3 = True
|
||||
else:
|
||||
ISP3 = False
|
||||
|
||||
def utf8string(s):
|
||||
if s is None:
|
||||
return "None"
|
||||
if ISP3:
|
||||
return s
|
||||
else:
|
||||
return s.encode('utf8')
|
||||
|
||||
db = recoll.connect()
|
||||
query = db.query()
|
||||
|
||||
nres = query.execute("huniique", stemlang="english")
|
||||
qs = "Xapian query: [%s]" % query.getxquery()
|
||||
print(utf8string(qs))
|
||||
|
||||
print("Result count: %d %d" % (nres, query.rowcount))
|
||||
|
||||
print("for i in range(nres):")
|
||||
for i in range(nres):
|
||||
doc = query.fetchone()
|
||||
print(utf8string(doc.filename))
|
||||
|
||||
query.scroll(0, 'absolute')
|
||||
print("\nfor doc in query:")
|
||||
for doc in query:
|
||||
print(utf8string(doc.filename))
|
||||
|
||||
try:
|
||||
query.scroll(0, 'badmode')
|
||||
except:
|
||||
print("\nCatched bad mode. (ok)")
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue