[patch] notmuch-addresses.py fix UnicodeDecodeError
authorJoshua Ismael Haase Hernandez <hahj87@gmail.com>
Wed, 1 Feb 2012 18:09:49 +0000 (12:09 +1800)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:43:54 +0000 (09:43 -0800)
26/bbfb475538bdc7ef528a6c03e4e8dd9585c93f [new file with mode: 0644]

diff --git a/26/bbfb475538bdc7ef528a6c03e4e8dd9585c93f b/26/bbfb475538bdc7ef528a6c03e4e8dd9585c93f
new file mode 100644 (file)
index 0000000..250de8b
--- /dev/null
@@ -0,0 +1,175 @@
+Return-Path: <hahj87@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id C658041ED91\r
+       for <notmuch@notmuchmail.org>; Wed,  1 Feb 2012 10:14:10 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+       RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id FLIahZaun-wX for <notmuch@notmuchmail.org>;\r
+       Wed,  1 Feb 2012 10:14:10 -0800 (PST)\r
+Received: from mail-tul01m020-f181.google.com (mail-tul01m020-f181.google.com\r
+       [209.85.214.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 3E5E6421192\r
+       for <notmuch@notmuchmail.org>; Wed,  1 Feb 2012 10:14:10 -0800 (PST)\r
+Received: by obbup10 with SMTP id up10so1844034obb.26\r
+       for <notmuch@notmuchmail.org>; Wed, 01 Feb 2012 10:14:08 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=from:to:subject:user-agent:date:message-id:mime-version\r
+       :content-type; bh=XefO5mXG+rN9Xb+46IV3pxKj0C2+NNVwENcKfLTn1I4=;\r
+       b=b4cW42O5Fxs2u2i9hEa10vNpMaeC2uSmHzUYFmULzVFQ+ME21JYR7Q+KdBXH7eBLvF\r
+       Ot1ov1J7BS3oTo3/zLxiRudiQtPgwLAGaeGZKnvQxQ7RHr6UOzI06cYOziw9Lqr71h00\r
+       LL1EBbsCx5T14z5+sR8GK1ojXAPImcjO2yl38=\r
+Received: by 10.182.192.8 with SMTP id hc8mr31011131obc.25.1328120048575;\r
+       Wed, 01 Feb 2012 10:14:08 -0800 (PST)\r
+Received: from stravy ([189.249.68.40])\r
+       by mx.google.com with ESMTPS id p3sm10125979obm.9.2012.02.01.10.14.06\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Wed, 01 Feb 2012 10:14:07 -0800 (PST)\r
+From: Joshua Ismael Haase Hernandez <hahj87@gmail.com>\r
+To: Notmuch <notmuch@notmuchmail.org>\r
+Subject: [patch] notmuch-addresses.py fix UnicodeDecodeError\r
+User-Agent: Notmuch/0.10.2 (http://notmuchmail.org) Emacs/23.3.1\r
+       (mips64el-unknown-linux-gnu)\r
+Date: Wed, 01 Feb 2012 12:09:49 -0600\r
+Message-ID:\r
+ <874nva2zo2.fsf@stravy.i-did-not-set--mail-host-address--so-tickle-me>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/mixed; boundary="=-=-="\r
+X-Mailman-Approved-At: Thu, 02 Feb 2012 08:56:31 -0800\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 01 Feb 2012 18:14:10 -0000\r
+\r
+--=-=-=\r
+Content-Type: multipart/signed; boundary="==-=-=";\r
+       micalg=pgp-sha1; protocol="application/pgp-signature"\r
+\r
+--==-=-=\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+Hi there.\r
+\r
+I am using notmuch and notmuch-adresses.py for adress completion. My\r
+native language is spanish and so most of my contact names contain\r
+accents or '=C3=B1', so python script failed for them.\r
+\r
+I attach the fix, sorry about emacs blank spaces cleanup.\r
+\r
+\r
+--==-=-=\r
+Content-Type: application/pgp-signature\r
+\r
+-----BEGIN PGP SIGNATURE-----\r
+Version: GnuPG v1.4.11 (GNU/Linux)\r
+\r
+iQIcBAEBAgAGBQJPKX/xAAoJECS+N057RKv5HGQP/3FZjKZGlneBtWipc8CHshhR\r
+7L9Oh6Iwktx7MZwOd9Cl2s44KV1tTPyWQP3csJp9IwT+YTlDHOs51A5bIRyXpCPI\r
+IL6AuiU3fgJjYsLKH+Niss3i3IqiWCPk4DFtoRvM6fp1DmkczK2oTSzTrGe0Nu6Q\r
+qA7JEeiN4+YbeVCTzPflzybrJOD01LnwrQxkqrirZLmLSgdZWiZezn4SsBkRWDBc\r
+4+zvN0eeLwmNefSqk0NoPepaFb0AF25XY4eQEXwXjhpxn7JEU3BMqQKoSq8kWn15\r
+LVOABe1fMi1ddt5xcV8wPa5gcVaRHjPqkJFWsfQKlS0sThyZ7OuEZIDGqr7Z+sj5\r
+44QR588Z36M1GreesfRDiyhyOCU+Th1y1aueLBPcRk7LS1UCN3Skiy+W02a++Ne0\r
+MQQ4BJ5PM82+Ci2wrhNb1hgv0ysghci85HwJ4UFkNipmPc3CuSNvTUWgNkG27uhr\r
+hVeHouPoVBgNJUF6n/3EHud4YCUwrmxsVAZZ2e7S5vYaHx5kA+sMFeKdL1czaM37\r
+64DHD7s2sjnLH9F6k99wIu7c3AD3Xd8UfAhSQ791BHyn5VGZiSemmlRLBUao6svn\r
+tdhKWy8pMXOvWYgIQbQUHSfs4YmBxcLRXtgTGZJbiU06498YcP6Z2QVCcpSv+2dh\r
+RBesVOIbNKDOh2LMfHWD\r
+=VPDb\r
+-----END PGP SIGNATURE-----\r
+--==-=-=--\r
+\r
+--=-=-=\r
+Content-Type: text/x-patch\r
+Content-Disposition: attachment; filename=fix-decodeError-non-ascii.patch\r
+Content-Description: Fix UnicodeDecodeError\r
+\r
+diff --git a/notmuch_addresses.py b/notmuch_addresses.py\r
+index 74a743c..866b327 100755\r
+--- a/notmuch_addresses.py\r
++++ b/notmuch_addresses.py\r
+@@ -15,7 +15,7 @@\r
+ ## GNU General Public License for more details.\r
+ \r
+ ## NOTE: This script requires the notmuch python bindings.\r
+-  \r
++\r
+ import notmuch\r
+ import ConfigParser\r
+ import optparse\r
+@@ -43,7 +43,7 @@ class EmailsWithNames(object):\r
+     as a list email addresses (with or without best-choice real\r
+     names), sorted by frequency.\r
+     """\r
+-    \r
++\r
+     def __init__(self):\r
+         self.emails = {}\r
+ \r
+@@ -92,7 +92,7 @@ class EmailsWithNames(object):\r
+                 return names[1]\r
+ \r
+     def sorted_email_list(self):\r
+-        return sorted(self.emails.keys(), \r
++        return sorted(self.emails.keys(),\r
+                       key=self.email_freq,\r
+                       reverse=True)\r
+ \r
+@@ -105,7 +105,7 @@ class NotmuchAddressMatcher(object):\r
+     """A simple address matcher, based on information information from\r
+     the user's $HOME/.notmuch-config file.\r
+     """\r
+-    \r
++\r
+     def __init__(self, query_name, match_function=None):\r
+         """\r
+         """\r
+@@ -167,15 +167,15 @@ class NotmuchAddressMatcher(object):\r
+                 full_name = addr[0]\r
+                 split_names = full_name.split(" ")\r
+                 mail = addr[1]\r
+-                if (len([name for name in split_names \r
++                if (len([name for name in split_names\r
+                          if self.match_function(name)]) > 0\r
+-                    or \r
++                    or\r
+                     self.match_function(full_name)\r
+-                    or \r
++                    or\r
+                     self.match_function(mail)):\r
+-                    \r
++\r
+                     emails.add_email_and_name(mail, addr[0])\r
+-     \r
++\r
+         self.matches = emails.sorted_email_and_names_list()\r
+ \r
+ if __name__ == '__main__':\r
+@@ -187,4 +187,4 @@ if __name__ == '__main__':\r
+         matcher = NotmuchAddressMatcher(name)\r
+         matcher.generate_matches()\r
+ \r
+-        for elem in matcher.matches: print (elem)\r
++        for elem in matcher.matches: print (elem.encode('utf-8'))\r
+\r
+--=-=-=--\r