30 lines
		
	
	
	
		
			654 B
		
	
	
	
		
			Python
		
	
	
	
	
	
		
		
			
		
	
	
			30 lines
		
	
	
	
		
			654 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| 
								 | 
							
								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
							 |