Attempt to normalize strings to avoid accent problems
authorAndrew Flegg <andrew@bleb.org>
Sat, 17 Oct 2009 19:42:28 +0000 (20:42 +0100)
committerAndrew Flegg <andrew@bleb.org>
Sat, 17 Oct 2009 19:42:28 +0000 (20:42 +0100)
package/src/hermes.py
package/src/names.py

index 81faeac..ffed489 100644 (file)
@@ -2,6 +2,7 @@ import os.path
 import evolution
 from facebook import Facebook, FacebookError
 import twitter
+import unicodedata
 import gnome.gconf
 from contacts import ContactStore
 import names
@@ -118,7 +119,8 @@ class Hermes:
       # Get the list of friends...
       attrs = ['uid', 'name', 'pic_big', 'birthday_date', 'profile_url']
       for friend in self.fb.users.getInfo(self.fb.friends.get(), attrs):
-        friend['pic'] = friend[attrs[2]]
+        friend['name'] = unicodedata.normalize('NFKD', unicode(friend['name']))
+        friend['pic']  = friend[attrs[2]]
         self.friends[friend['name']] = friend
         if not friend['pic']:
           self.blocked_pictures.append(friend)
@@ -130,7 +132,7 @@ class Hermes:
       api = twitter.Api(username=user, password=passwd)
       users = api.GetFriends()
       for friend in api.GetFriends():
-        self.friends[friend.name] = {'name': friend.name, 'pic': friend.profile_image_url, 'birthday_date': None, 'twitter_url': 'http://twitter.com/%s' % (friend.screen_name), 'homepage' : friend.url}
+        self.friends[friend.name] = {'name': unicodedata.normalize('NFKD', unicode(friend.name)), 'pic': friend.profile_image_url, 'birthday_date': None, 'twitter_url': 'http://twitter.com/%s' % (friend.screen_name), 'homepage' : friend.url}
   
     # TODO What if the user has *no* contacts?
 
index b0b5fd0..d560841 100644 (file)
@@ -1,3 +1,5 @@
+import unicodedata
+
 """Utilities for determing name variants.
 
    Copyright (c) Andrew Flegg <andrew@bleb.org> 2009.
@@ -32,6 +34,7 @@ def variants(name):
     if (name is None):
       return result
     
+    name = unicodedata.normalize('NFKD', unicode(name))
     result.add(name)
     bits = name.split(' ')
     for bit in bits: