Re: [Deskbar] Man I'm gonna regret this :)

For future Reference i attach to this mail the example,
showcasing the libbeagle power.

I committed to CVS the new beagle-live handler, fine tuning and comments
are welcome.

import beagle
import gobject
import sys

total_hits = 0

def hits_added_cb (query, response):
	global total_hits
	hits = response.get_hits()
	total_hits = total_hits + len(hits)
	print "Found hits (%d):" % len(hits)
	print "-------------------------------------------"
	for hit in hits:
		if hit.get_type() == "FeedItem":
			text = hit.get_property("dc:title")
			print "Blog: %s" % text
		elif hit.get_type() == "File":
			print "File: %s" % hit.get_uri()
			print "%s (%s)" % (hit.get_uri(), hit.get_source_object_name())

	print "-------------------------------------------"

def finished_cb (query, response, loop):

client = beagle.Client()
main_loop = gobject.MainLoop()
query = beagle.Query()

for i in sys.argv[1:]:

query.connect("hits-added", hits_added_cb)
query.connect("finished", finished_cb, main_loop)

print "Found a total of %d hits" % total_hits

Attachment: signature.asc
Description: This is a digitally signed message part

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]