You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
984 B
Python
49 lines
984 B
Python
#!/usr/bin/python
|
|
|
|
import bsddb
|
|
import os
|
|
import re
|
|
|
|
# Constants
|
|
|
|
SMSLEN = 160
|
|
DB_PATH = "~/.evolution/addressbook/local/system/addressbook.db"
|
|
|
|
# EvolutionsCells gets cell phone numbers out of the Evolution database
|
|
|
|
class EvolutionCells:
|
|
def __init__(self):
|
|
contacts = {}
|
|
self.contacts = contacts
|
|
|
|
db = bsddb.hashopen(os.path.expanduser(DB_PATH),"r")
|
|
self.db = db
|
|
|
|
for k in db.keys():
|
|
name = ""
|
|
cell = ""
|
|
for e in db[k].split('\r\n'):
|
|
if re.search("^FN:", e):
|
|
name = re.sub("^FN:", "", e)
|
|
if re.search("^\.?TEL;TYPE=CELL.*?:", e):
|
|
cell = re.sub("^\.?TEL;TYPE=CELL.*?:", "", e)
|
|
if cell != "":
|
|
contacts[name] = cell
|
|
|
|
db.close
|
|
|
|
def getContacts(self):
|
|
return self.contacts
|
|
|
|
|
|
# Get contacts
|
|
cells = EvolutionCells()
|
|
contacts = cells.getContacts()
|
|
|
|
# Fill contact list and the combobox
|
|
|
|
contactlist = contacts.keys()
|
|
contactlist.sort()
|
|
for k in contactlist:
|
|
print k + " " + contacts[k]
|