# S60 To-Call List (c) 2010 Silas S. Brown, License: GPL read_from = r"E:\tocall.txt" # save your notes there max_matches = 4 # if more than this number of contacts match a name, don't link it import contacts, re, time, e32 items = open(read_from).read() # will crash if not exist htmlFilename = r"E:\tocall.html" cdb = contacts.open() count = 0 ; htmlFile=open(htmlFilename,"w") htmlFile.write("
") conNotes = {} for item in items.split("\n"): if not item: continue count += 1 ; print "Importing item",count e32.ao_sleep(0.1) # allow display to refresh item = item.replace("&","@&&@").replace("<","@<<@") def myfunc(m): word = item[m.start():m.end()] if not word: return word if not word in conNotes: notes = [] cons = cdb.find(u""+word) if len(cons) <= max_matches: for con in cons: thisCon = [] for val in [field.value for field in con.find()]: if val=="private": continue if re.match("^[0-9+]*$",val): val=""+val+"" else: val=re.sub("(?i)"+word,""+word+"",val,1) thisCon.append(val) notes.append(" ".join(thisCon)) if notes: conNotes[word]=";