#!/usr/bin/python import bsddb, os, re, sys if len(sys.argv) > 1: # return 0 or 1 if arg is in contacts check = sys.argv[1] else: check = None # just dump a list of contacts home = os.getenv('HOME') dbname = '%s/evolution/local/Contacts/addressbook.db' % home db = bsddb.hashopen(dbname, 'r') regex = re.compile('EMAIL;INTERNET:(?P.*)[\n|$]', re.M) for k in db.keys(): matches = [s.strip() for s in regex.findall(db[k])] for contact in matches: if contact: if check is not None: if check == contact: db.close() sys.exit(1) else: print contact db.close()