Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 23C16429E4C for ; Wed, 14 Dec 2011 04:56:56 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] 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 rn-WvPHcWCOa for ; Wed, 14 Dec 2011 04:56:55 -0800 (PST) Received: from mail.cryptobitch.de (cryptobitch.de [88.198.7.68]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 37544429E4A for ; Wed, 14 Dec 2011 04:56:55 -0800 (PST) Received: from mail.jade-hamburg.de (unknown [85.183.11.228]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.cryptobitch.de (Postfix) with ESMTPSA id DC99B50F4C6 for ; Wed, 14 Dec 2011 13:56:53 +0100 (CET) Received: by mail.jade-hamburg.de (Postfix, from userid 401) id 5BA56DF2A1; Wed, 14 Dec 2011 13:56:53 +0100 (CET) Received: from thinkbox.jade-hamburg.de (unknown [85.183.11.228]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: teythoon) by mail.jade-hamburg.de (Postfix) with ESMTPSA id A6597DF29F; Wed, 14 Dec 2011 13:56:51 +0100 (CET) Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.77) (envelope-from ) id 1RaoOA-0007ka-G7; Wed, 14 Dec 2011 13:56:50 +0100 Content-Type: multipart/mixed; boundary="===============2021153055585812822==" MIME-Version: 1.0 References: <1323860305-15802-1-git-send-email-4winter@informatik.uni-hamburg.de> <1323860305-15802-7-git-send-email-4winter@informatik.uni-hamburg.de> To: Tomi Ollila , notmuch@notmuchmail.org In-Reply-To: From: Justus Winter <4winter@informatik.uni-hamburg.de> Subject: Re: [PATCH 6/7] py3k: Add and use a mixin class that implements __str__ Date: Wed, 14 Dec 2011 13:56:50 +0100 Message-Id: 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, 14 Dec 2011 12:56:56 -0000 --===============2021153055585812822== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Quoting Tomi Ollila (2011-12-14 13:26:38) >On Wed, 14 Dec 2011 11:58:24 +0100, Justus Winter <4winter@informatik.uni-= hamburg.de> wrote: >> --- >[ ... snip ... ] > >> = >> -class Filenames(object): >> +class Filenames(Python3StringMixIn): >> """Represents a list of filenames as returned by notmuch >> = >> This object contains the Filenames iterator. The main function is >> @@ -98,9 +98,6 @@ class Filenames(object): >> = >> self._files =3D None >> = >> - def __str__(self): >> - return unicode(self).encode('utf-8') >> - >> def __unicode__(self): >> """Represent Filenames() as newline-separated list of full paths >> = >> diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuc= h/globals.py >> index c52790c..2111b86 100644 >> --- a/bindings/python/notmuch/globals.py >> +++ b/bindings/python/notmuch/globals.py >> @@ -28,6 +28,16 @@ except: >> raise ImportError("Could not find shared 'notmuch' library.") >> = >> = >> +if sys.version_info[0] =3D=3D 2: >> + class Python3StringMixIn(object): >> + def __str__(self): >> + return unicode(self).encode('utf-8') >> +else: >> + class Python3StringMixIn(object): >> + def __str__(self): >> + return self.__unicode__() >> + >> + > >[ ... snip ... ] > >> -class Threads(object): >> +class Threads(Python3StringMixIn): >> """Represents a list of notmuch threads >> = >> This object provides an iterator over a list of notmuch threads >> @@ -393,7 +393,7 @@ class Thread(object): >> return Tags(tags_p, self) >> = >> def __str__(self): >> - return unicode(self).encode('utf-8') >> + return self.__unicode__().encode('utf-8') >> = >> def __unicode__(self): >> frm =3D "thread:%s %12s [%d/%d] %s; %s (%s)" > >Is this class special case ? in all other classes >the __str__() function has been removed (using inherited >function) ? Damn, I missed that one... that was my first approach but that obviously didn't worked out... I'll send an updated patch. >Otherwise LGTM -- pretty simple and effective (all 7 patches). Thanks :) Note that I do not know how complete the port is. But the stuff used by my tagging application (afew) works. Justus --===============2021153055585812822== Content-Type: application/octet-stream MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=".signature" bG92ZSB1IGFsb3QgQCxACgo= --===============2021153055585812822==--