/usr/local/Hypy
view examples/search.py @ 139:d0a738aea316
Added tag 0.8.4.1 for changeset bbc3e3a3c4fb
| author | Cory Dodt <corymercurial@spam.goonmill.org> |
|---|---|
| date | Fri Oct 09 10:32:45 2009 -0700 (11 months ago) |
| parents | 3b0b571962aa |
| children |
line source
1 # hypy version of the estraiernative gather/search 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()
