9 def hits_added_cb (query
, response
):
11 hits
= response
.get_hits()
12 num_matches
= response
.get_num_matches()
14 total_hits
= total_hits
+ len(hits
)
15 print "Returned hits (%d) out of total %d matches:" % (len(hits
), num_matches
)
16 print "-------------------------------------------"
19 if hit
.get_type() == "FeedItem":
20 text
= hit
['dc:title']
21 print "Blog: %s" % text
22 elif hit
.get_type() == "File":
23 print "File: %s" % hit
.get_uri()
24 elif hit
.get_type() == "MailMessage":
25 print "Email: %s" % hit
['dc:title']
26 for sender
in hit
.get_properties ('fixme:from'):
27 print "\tSent by: %s" % sender
29 print "%s (%s)" % (hit
.get_uri(), hit
.get_source())
31 print "-------------------------------------------"
33 def finished_cb (query
, response
, loop
):
36 client
= beagle
.Client()
37 main_loop
= gobject
.MainLoop()
38 query
= beagle
.Query()
40 for i
in sys
.argv
[1:]:
43 query
.connect("hits-added", hits_added_cb
)
44 query
.connect("finished", finished_cb
, main_loop
)
45 client
.send_request_async(query
)
49 print "Found a total of %d hits" % total_hits