conduit r1542 - in trunk: . conduit/modules



Author: johncarr
Date: Tue Jul 15 09:15:47 2008
New Revision: 1542
URL: http://svn.gnome.org/viewvc/conduit?rev=1542&view=rev

Log:
Convert name from osync to vcard

Modified:
   trunk/   (props changed)
   trunk/conduit/modules/SynceModule.py

Modified: trunk/conduit/modules/SynceModule.py
==============================================================================
--- trunk/conduit/modules/SynceModule.py	(original)
+++ trunk/conduit/modules/SynceModule.py	Tue Jul 15 09:15:47 2008
@@ -8,6 +8,7 @@
 import conduit.Exceptions as Exceptions
 
 import xml.dom.minidom
+import vobject
 
 import logging
 log = logging.getLogger("modules.SynCE")
@@ -227,13 +228,24 @@
         c = Contact.Contact()
 	c.set_UID(uid)
 
+        def S(node):
+	    if node and node[0].childNodes:
+	        return node[0].firstChild.wholeText
+	    return ""
+
 	for node in root.childNodes:
 	    if node.nodeName == "FileAs":
 	        pass
 	    elif node.nodeName == "FormattedName":
 	        pass
 	    elif node.nodeName == "Name":
-	        pass
+	        family = S(node.getElementsByTagName('LastName'))
+		given = S(node.getElementsByTagName('FirstName'))
+		try:
+		    c.vcard.n
+		except:
+		    c.vcard.add('n')
+	        c.vcard.n.value = vobject.vcard.Name(family=family, given=given)
 	    elif node.nodeName == "Nickname":
 	        pass
 	    elif node.nodeName == "Photo":



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]