Add manual mapping for 0.2.0 release
[hermes] / package / src / contacts.py
index 38b4624..56ebf6b 100644 (file)
@@ -110,7 +110,7 @@ class ContactStore:
     urls = re.findall('(?:(?:ftp|https?):\/\/|\\bwww\.|\\bftp\.)[,\w\.\-\/@:%?&=%+#~_$\*]+[\w=\/&=+#]', str, re.I | re.S)
     updated = False
     for url in urls:
-      updated = self._add_url(contact, url, unique or url) or updated
+      updated = self._add_url(contact, url, unique or re.sub('(?:.*://)?(\w+(?:[\w\.])*).*', '\\1', url)) or updated
 
     return updated
 
@@ -124,11 +124,11 @@ class ContactStore:
     while ai.has_next():
       attr = ai.next(as_a = EVCardAttribute)
       existing = string_at(attr.value().next())
+      #print "Existing URL [%s] when adding [%s] to [%s] with constraint [%s]" % (existing, url, contact.get_name(), unique)
       if existing == unique or existing == url:
         return False
       elif existing.find(unique) > -1:
         url_attr = attr
-        break
       
     if not url_attr:
       ai.add()