Pys60 contacts related code
Code
Contacts
Backup
# coding=utf-8 import time import contacts contacts_db = contacts.open() #default db of the phone. # contacts_db behaves like a list of objects somehow # and with .keys() one can retrieve all the ids. # like contacts_db.keys() returns [1,2,3,...,20] # Moreover is a list of list so the contact actually # are accessed by contacts_db[id][fieldid] but this is a minor # problem because with len(contacts_db[id]) one can now how many # fields one can query or with contacts_db[id].keys(). Now i'm not 100% familiar with the db # but it seems that contacts with lenght 80 cannot be queried and # are not real entries or something like that. # Better to act safe until more experience is gathered. file = open("e:\\contacts_" + time.strftime("%Y-%m-%d-%H-%M", time.localtime()) + ".txt","w") for contact_id in contacts_db.keys() : if len(contacts_db[contact_id]) < 80: print str(contact_id) file.write( "---- contact" + str(contact_id) + " ----" + "\n") for field_key in contacts_db[contact_id].keys() : if field_key < 1000 : # else some strange field key is listed. file.write( str(contacts_db[contact_id][field_key]) ) file.write( "\n") file.write( "\n") file.write( "\n") file.close() print "Done" #know problems, sometimes warnings are thrown.
page revision: 0, last edited: 09 Aug 2015 19:28