From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id C658041ED91 for ; Wed, 1 Feb 2012 10:14:10 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.201 X-Spam-Level: X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FLIahZaun-wX for ; Wed, 1 Feb 2012 10:14:10 -0800 (PST) Received: from mail-tul01m020-f181.google.com (mail-tul01m020-f181.google.com [209.85.214.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 3E5E6421192 for ; Wed, 1 Feb 2012 10:14:10 -0800 (PST) Received: by obbup10 with SMTP id up10so1844034obb.26 for ; Wed, 01 Feb 2012 10:14:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:user-agent:date:message-id:mime-version :content-type; bh=XefO5mXG+rN9Xb+46IV3pxKj0C2+NNVwENcKfLTn1I4=; b=b4cW42O5Fxs2u2i9hEa10vNpMaeC2uSmHzUYFmULzVFQ+ME21JYR7Q+KdBXH7eBLvF Ot1ov1J7BS3oTo3/zLxiRudiQtPgwLAGaeGZKnvQxQ7RHr6UOzI06cYOziw9Lqr71h00 LL1EBbsCx5T14z5+sR8GK1ojXAPImcjO2yl38= Received: by 10.182.192.8 with SMTP id hc8mr31011131obc.25.1328120048575; Wed, 01 Feb 2012 10:14:08 -0800 (PST) Received: from stravy ([189.249.68.40]) by mx.google.com with ESMTPS id p3sm10125979obm.9.2012.02.01.10.14.06 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 01 Feb 2012 10:14:07 -0800 (PST) From: Joshua Ismael Haase Hernandez To: Notmuch Subject: [patch] notmuch-addresses.py fix UnicodeDecodeError User-Agent: Notmuch/0.10.2 (http://notmuchmail.org) Emacs/23.3.1 (mips64el-unknown-linux-gnu) Date: Wed, 01 Feb 2012 12:09:49 -0600 Message-ID: <874nva2zo2.fsf@stravy.i-did-not-set--mail-host-address--so-tickle-me> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Mailman-Approved-At: Thu, 02 Feb 2012 08:56:31 -0800 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Feb 2012 18:14:10 -0000 --=-=-= Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --==-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 '=C3=B1', so python script failed for them. I attach the fix, sorry about emacs blank spaces cleanup. --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBAgAGBQJPKX/xAAoJECS+N057RKv5HGQP/3FZjKZGlneBtWipc8CHshhR 7L9Oh6Iwktx7MZwOd9Cl2s44KV1tTPyWQP3csJp9IwT+YTlDHOs51A5bIRyXpCPI IL6AuiU3fgJjYsLKH+Niss3i3IqiWCPk4DFtoRvM6fp1DmkczK2oTSzTrGe0Nu6Q qA7JEeiN4+YbeVCTzPflzybrJOD01LnwrQxkqrirZLmLSgdZWiZezn4SsBkRWDBc 4+zvN0eeLwmNefSqk0NoPepaFb0AF25XY4eQEXwXjhpxn7JEU3BMqQKoSq8kWn15 LVOABe1fMi1ddt5xcV8wPa5gcVaRHjPqkJFWsfQKlS0sThyZ7OuEZIDGqr7Z+sj5 44QR588Z36M1GreesfRDiyhyOCU+Th1y1aueLBPcRk7LS1UCN3Skiy+W02a++Ne0 MQQ4BJ5PM82+Ci2wrhNb1hgv0ysghci85HwJ4UFkNipmPc3CuSNvTUWgNkG27uhr hVeHouPoVBgNJUF6n/3EHud4YCUwrmxsVAZZ2e7S5vYaHx5kA+sMFeKdL1czaM37 64DHD7s2sjnLH9F6k99wIu7c3AD3Xd8UfAhSQ791BHyn5VGZiSemmlRLBUao6svn tdhKWy8pMXOvWYgIQbQUHSfs4YmBxcLRXtgTGZJbiU06498YcP6Z2QVCcpSv+2dh RBesVOIbNKDOh2LMfHWD =VPDb -----END PGP SIGNATURE----- --==-=-=-- --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=fix-decodeError-non-ascii.patch Content-Description: Fix UnicodeDecodeError 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')) --=-=-=--