|
From: Waseem D. <wd...@us...> - 2005-06-16 05:09:16
|
Update of /cvsroot/gmailagent/GA-libgmail2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7485 Modified Files: libgmail2.py testlibgmail2.py Log Message: Added support for multiline notes in vCard export (not convinced that we'll ever get these from Gmail, or that we can even add contacts with multiline notes successfully, but it's still worth dealing with this case in the vCard export) Index: libgmail2.py =================================================================== RCS file: /cvsroot/gmailagent/GA-libgmail2/libgmail2.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** libgmail2.py 16 Jun 2005 05:01:20 -0000 1.6 --- libgmail2.py 16 Jun 2005 05:09:05 -0000 1.7 *************** *** 903,909 **** 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() # Fake-out N by splitting up whatever we get out of getName # This might not always do 'the right thing' --- 903,908 ---- vcard = "BEGIN:VCARD\n" vcard += "VERSION:3.0\n" ! # Deal with multiline notes ! vcard += "NOTE:%s\n" % self.getNotes().replace("\n","\\n") # Fake-out N by splitting up whatever we get out of getName # This might not always do 'the right thing' Index: testlibgmail2.py =================================================================== RCS file: /cvsroot/gmailagent/GA-libgmail2/testlibgmail2.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** testlibgmail2.py 16 Jun 2005 05:01:20 -0000 1.4 --- testlibgmail2.py 16 Jun 2005 05:09:05 -0000 1.5 *************** *** 140,145 **** END:VCARD """ ! self.assertEqual(vcard, expectedVCard, "getVCard() did not export what we expected") if __name__ == '__main__': --- 140,157 ---- END:VCARD """ ! self.assertEqual(vcard, expectedVCard, "getVCard() did not export what we expected for Waseem") + # Test multi-line NOTEs + bob = GmailContact("0", "BillyJo", "bi...@jo...", "I like multilines\nwoo") + bobvcard=bob.getVCard() + bobexpectedVCard="""BEGIN:VCARD + VERSION:3.0 + NOTE:I like multilines\\nwoo + N:BillyJo + FN:BillyJo + EMAIL;TYPE=INTERNET:bi...@jo... + END:VCARD + """ + self.assertEqual(vcard, expectedVCard, "getVCard() didn't export what we expected for BillyJo") if __name__ == '__main__': |