Jppy: Example for moving your Birthdays over to ContactsDB
Nicholas Piper
nick at nickpiper.co.uk
Thu Sep 14 21:15:30 BST 2006
Hi,
I just saw that HappyDays has a beta out, which supports the Birthday
field in Contacts: http://jmjeong.com/index.php?display=HappyDays
So I wanted to move all my birthday details over. Only those which are
simple Birthdays, and only those with years in. Here's what I did in a
Python script:
import jppy
import mx.DateTime
ab = jppy.addressBook()
for r in ab.records():
if r['custom1']:
s = r['custom1']
parts = s.split('/')
if len(parts) == 3 and len(parts[-1]) == 2:
s = "/".join((parts[0],
parts[1],
"19%s" % parts[2]))
try:
date = mx.DateTime.strptime(s,"%d/%m/%Y")
except Exception, e:
print r, r['custom1'], e
continue
r['birthday'] = date
r['custom1'] = ""
print r, r['custom1'], r['birthday']
ab.save(r)
Just sharing in case it's handy.
Nick
--
Nick Piper, Developer, LogicaCMG http://www.nickpiper.co.uk/
GPG Encrypted mail welcome! 1024D/3ED8B27F
Choose life. Be Vegan :-) Please reduce needless cruelty + suffering !
More information about the Jppy
mailing list