|
From: Waseem D. <wd...@us...> - 2005-06-16 03:45:01
|
Update of /cvsroot/gmailagent/GA-libgmail2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32675 Modified Files: libgmail2.py testlibgmail2.py Log Message: Added basic vCard export (could use a little improvement trying to build FN, and trying to deal with multiline notes?) Index: libgmail2.py =================================================================== RCS file: /cvsroot/gmailagent/GA-libgmail2/libgmail2.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** libgmail2.py 15 Jun 2005 11:14:01 -0000 1.4 --- libgmail2.py 16 Jun 2005 03:44:53 -0000 1.5 *************** *** 8,12 **** # # Contacts support added by wd...@mi... ! # (with massive help from 'gmail.py' and the Johnvey Gmail API) # # License: GPL 2.0 --- 8,14 ---- # # Contacts support added by wd...@mi... ! # (with massive initial help from ! # Adrian Holovaty's 'gmail.py' ! # and the Johnvey Gmail API) # # License: GPL 2.0 *************** *** 896,899 **** --- 898,914 ---- def getNotes(self): return self.notes + def getVCard(self): + """Returns a vCard 3.0 for this + contact, as a string""" + vcard = "BEGIN:VCARD\n" + vcard += "VERSION:3.0\n" + # This might not adhere to the spec + # if the note is multi-line? + vcard += "NOTE:%s\n" % self.getNotes() + # TODO: Take a stab at adding an N field? + vcard += "FN:%s\n" % self.getName() + vcard += "EMAIL;TYPE=INTERNET:%s\n" % self.getEmail() + vcard += "END:VCARD\n" + return vcard class GmailContactList: Index: testlibgmail2.py =================================================================== RCS file: /cvsroot/gmailagent/GA-libgmail2/testlibgmail2.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** testlibgmail2.py 2 Jun 2005 14:12:20 -0000 1.2 --- testlibgmail2.py 16 Jun 2005 03:44:53 -0000 1.3 *************** *** 128,131 **** --- 128,144 ---- self.assertEqual(myContactList.getCount(), 0) + def test9_vCard(self): + """Test vCard export""" + waseem = GmailContact("0", "Waseem Daher", "wd...@mi...", "GmailAgent developer") + vcard = waseem.getVCard() + expectedVCard="""BEGIN:VCARD + VERSION:3.0 + NOTE:GmailAgent developer + FN:Waseem Daher + EMAIL;TYPE=INTERNET:wd...@mi... + END:VCARD + """ + self.assertEqual(vcard, expectedVCard, "getVCard() did not export what we expected") + if __name__ == '__main__': |