9 def hits_added_cb (query
, response
):
11 hits
= response
.get_hits()
13 total_hits
= total_hits
+ len(hits
)
14 print "Found hits (%d):" % len(hits
)
15 print "-------------------------------------------"
18 if hit
.get_type() == "FeedItem":
19 text
= hit
['dc:title']
20 print "Blog: %s" % text
21 elif hit
.get_type() == "File":
22 print "File: %s" % hit
.get_uri()
23 elif hit
.get_type() == "MailMessage":
24 print "Email: %s" % hit
['dc:title']
25 for sender
in hit
.get_properties ('fixme:from'):
26 print "\tSent by: %s" % sender
28 print "%s (%s)" % (hit
.get_uri(), hit
.get_source())
30 print "-------------------------------------------"
32 def finished_cb (query
, response
, loop
):
35 client
= beagle
.Client()
36 main_loop
= gobject
.MainLoop()
37 query
= beagle
.Query()
39 for i
in sys
.argv
[1:]:
42 query
.connect("hits-added", hits_added_cb
)
43 query
.connect("finished", finished_cb
, main_loop
)
44 client
.send_request_async(query
)
48 print "Found a total of %d hits" % total_hits