unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [patch] notmuch-addresses.py fix UnicodeDecodeError
@ 2012-02-01 18:09 Joshua Ismael Haase Hernandez
  0 siblings, 0 replies; only message in thread
From: Joshua Ismael Haase Hernandez @ 2012-02-01 18:09 UTC (permalink / raw)
  To: Notmuch


[-- Attachment #1.1: Type: text/plain, Size: 266 bytes --]

Hi there.

I am using notmuch and notmuch-adresses.py for adress completion. My
native language is spanish and so most of my contact names contain
accents or 'ñ', so python script failed for them.

I attach the fix, sorry about emacs blank spaces cleanup.


[-- Attachment #1.2: Type: application/pgp-signature, Size: 835 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Fix UnicodeDecodeError --]
[-- Type: text/x-patch, Size: 2097 bytes --]

diff --git a/notmuch_addresses.py b/notmuch_addresses.py
index 74a743c..866b327 100755
--- a/notmuch_addresses.py
+++ b/notmuch_addresses.py
@@ -15,7 +15,7 @@
 ## GNU General Public License for more details.
 
 ## NOTE: This script requires the notmuch python bindings.
-  
+
 import notmuch
 import ConfigParser
 import optparse
@@ -43,7 +43,7 @@ class EmailsWithNames(object):
     as a list email addresses (with or without best-choice real
     names), sorted by frequency.
     """
-    
+
     def __init__(self):
         self.emails = {}
 
@@ -92,7 +92,7 @@ class EmailsWithNames(object):
                 return names[1]
 
     def sorted_email_list(self):
-        return sorted(self.emails.keys(), 
+        return sorted(self.emails.keys(),
                       key=self.email_freq,
                       reverse=True)
 
@@ -105,7 +105,7 @@ class NotmuchAddressMatcher(object):
     """A simple address matcher, based on information information from
     the user's $HOME/.notmuch-config file.
     """
-    
+
     def __init__(self, query_name, match_function=None):
         """
         """
@@ -167,15 +167,15 @@ class NotmuchAddressMatcher(object):
                 full_name = addr[0]
                 split_names = full_name.split(" ")
                 mail = addr[1]
-                if (len([name for name in split_names 
+                if (len([name for name in split_names
                          if self.match_function(name)]) > 0
-                    or 
+                    or
                     self.match_function(full_name)
-                    or 
+                    or
                     self.match_function(mail)):
-                    
+
                     emails.add_email_and_name(mail, addr[0])
-     
+
         self.matches = emails.sorted_email_and_names_list()
 
 if __name__ == '__main__':
@@ -187,4 +187,4 @@ if __name__ == '__main__':
         matcher = NotmuchAddressMatcher(name)
         matcher.generate_matches()
 
-        for elem in matcher.matches: print (elem)
+        for elem in matcher.matches: print (elem.encode('utf-8'))

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-02-01 18:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-01 18:09 [patch] notmuch-addresses.py fix UnicodeDecodeError Joshua Ismael Haase Hernandez

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).