Showing posts with label ebook. Show all posts
Showing posts with label ebook. Show all posts

Wednesday, August 22, 2007

Minimalistic Evolution phonebook extractor

If you're using Evolution as your E-Mail client and contact management application, and you like Python, here is a small snippet that allows you to dump out all phone numbers of your contacts to the console. Of course, with this code as a guide, you can produce even more useful applications ;)

What you need: Evolution, pygobject, evolution-python, Python (2.4 or higher) and some contacts in your contact list
#!/usr/bin/python

import evolution
import gobject

book = evolution.open_addressbook('default')

props = gobject.list_properties( evolution.EContact)
pp = [ p.name for p in props if 'phone' in p.name ]

for contact in book.get_all_contacts():
gp = contact.get_property
name = gp('file-as')
numbers = ', '.join( [ gp(p) for p in pp if gp(p) ])
if numbers:
print ': '.join( [ name, numbers ])