/usr/local/Hypy

view examples/search.py @ 2:3b0b571962aa

initial drop
author Cory Dodt <corymercurial@spam.goonmill.org>
date Sat Dec 13 11:30:29 2008 -0800 (2008-12-13)
parents
children 3085a106a56e
line source
1 # hypy version of the estraiernative gather example
3 from hypy import HDatabase, HCondition
5 # open the database, read-only
6 db = HDatabase()
7 db.open('casket', 'r')
9 # create a search condition object
10 cond = HCondition(u'lull*')
12 # get the result of search
13 result = db.search(cond)
15 # iterate the result
16 for doc in result:
17 # display attributes
18 print 'URI: %s' % (doc[u'@uri'].encode('utf-8'),)
19 print "Title: %s" % (doc[u'@title'].encode('utf-8'),)
21 # display the body text
22 for t in doc.getTexts():
23 print t.encode('utf-8')
25 # close the database
26 db.close()