From 773ea2e33b88c904594a556052c96d44bc989405 Mon Sep 17 00:00:00 2001 From: neingeist Date: Mon, 31 Oct 2005 06:20:49 +0000 Subject: [PATCH] Move EvolutionCells out to evolutioncells.py --- evolutioncells.py | 29 +++++++++++++++++++++++++++++ listnumbers.py | 33 ++------------------------------- smstool.py | 35 +++++------------------------------ 3 files changed, 36 insertions(+), 61 deletions(-) create mode 100644 evolutioncells.py diff --git a/evolutioncells.py b/evolutioncells.py new file mode 100644 index 0000000..b4ce682 --- /dev/null +++ b/evolutioncells.py @@ -0,0 +1,29 @@ +import bsddb, os, re + +# Constants + +DB_PATH = "~/.evolution/addressbook/local/system/addressbook.db" + +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 diff --git a/listnumbers.py b/listnumbers.py index b190cbb..fc5ec03 100755 --- a/listnumbers.py +++ b/listnumbers.py @@ -1,42 +1,13 @@ #!/usr/bin/python -import bsddb -import os -import re +from evolutioncells import * # 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() diff --git a/smstool.py b/smstool.py index 974bf7b..f82658b 100644 --- a/smstool.py +++ b/smstool.py @@ -3,40 +3,15 @@ import wxversion #wxversion.select("2.5") from wxPython.wx import * -import bsddb -import os -import re +#import bsddb +#import os +#import re + +from evolutioncells import * # 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 # SimserFrame is the application