From cf1f6122a220940e53a093ce1ba9ded6b1d679b9 Mon Sep 17 00:00:00 2001 From: neingeist Date: Fri, 21 Oct 2005 08:39:57 +0000 Subject: [PATCH] list numbers --- listnumbers.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ smstool.py | 2 ++ 2 files changed, 50 insertions(+) create mode 100755 listnumbers.py diff --git a/listnumbers.py b/listnumbers.py new file mode 100755 index 0000000..b190cbb --- /dev/null +++ b/listnumbers.py @@ -0,0 +1,48 @@ +#!/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] diff --git a/smstool.py b/smstool.py index c992239..974bf7b 100644 --- a/smstool.py +++ b/smstool.py @@ -1,5 +1,7 @@ #!/usr/bin/python +import wxversion +#wxversion.select("2.5") from wxPython.wx import * import bsddb import os