From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 5EBB76DE1677 for ; Tue, 12 Jun 2018 01:35:23 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.472 X-Spam-Level: X-Spam-Status: No, score=0.472 tagged_above=-999 required=5 tests=[AWL=-0.180, SPF_NEUTRAL=0.652] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fPYR6Icuuqy2 for ; Tue, 12 Jun 2018 01:35:21 -0700 (PDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by arlo.cworth.org (Postfix) with ESMTP id 4F88D6DE1656 for ; Tue, 12 Jun 2018 01:35:20 -0700 (PDT) Received: from guru.guru-group.fi (localhost [IPv6:::1]) by guru.guru-group.fi (Postfix) with ESMTP id 9C8A110008E; Tue, 12 Jun 2018 11:35:09 +0300 (EEST) From: Tomi Ollila To: Daniel Kahn Gillmor , Notmuch Mail Subject: Re: [PATCH] devel: make printmimestructure py3 compatible In-Reply-To: <20180611232244.27207-1-dkg@fifthhorseman.net> References: <20180611232244.27207-1-dkg@fifthhorseman.net> User-Agent: Notmuch/0.26.1+22~g888240d (https://notmuchmail.org) Emacs/25.2.1 (x86_64-unknown-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.26 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: Tue, 12 Jun 2018 08:35:23 -0000 On Mon, Jun 11 2018, Daniel Kahn Gillmor wrote: > Make printmimestructure work in python3 as well as python2. > > PEP 394 suggests that python scripts that work with both python2 and > python3 should have a #!/usr/bin/python command line, so do that too. I did not see PEP 394 suggesting to change=20 -#!/usr/bin/env python +#!/usr/bin/python just that 'python' should be able to run both python2 and python3 code. after the above change the code will not run on (those stupid) systems that install python to e.g. /usr/local/bin/. While I am not against this change, the commit message is misleading. Tomi > --- > devel/printmimestructure | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/devel/printmimestructure b/devel/printmimestructure > index 34d12930..afa0590e 100755 > --- a/devel/printmimestructure > +++ b/devel/printmimestructure > @@ -1,4 +1,4 @@ > -#!/usr/bin/env python > +#!/usr/bin/python > # -*- coding: utf-8 -*- >=20=20 > # Author: Daniel Kahn Gillmor > @@ -19,6 +19,8 @@ > # If you want to number the parts, i suggest piping the output through > # something like "cat -n" >=20=20 > +from __future__ import print_function > + > import email > import sys >=20=20 > @@ -34,7 +36,7 @@ def test(z, prefix=3D''): > if d[0] in [ 'attachment', 'inline' ]: > disposition =3D ' ' + d[0] > if (z.is_multipart()): > - print prefix + '=E2=94=AC=E2=95=B4' + z.get_content_type() + cse= t + disposition + fname, z.as_string().__len__().__str__() + ' bytes' > + print(prefix + '=E2=94=AC=E2=95=B4' + z.get_content_type() + cse= t + disposition + fname, z.as_string().__len__().__str__() + ' bytes') > if prefix.endswith('=E2=94=94'): > prefix =3D prefix.rpartition('=E2=94=94')[0] + ' ' > if prefix.endswith('=E2=94=9C'): > @@ -47,6 +49,6 @@ def test(z, prefix=3D''): > test(parts[i], prefix + '=E2=94=94') > # FIXME: show epilogue? > else: > - print prefix + '=E2=94=80=E2=95=B4'+ z.get_content_type() + cset= + disposition + fname, z.get_payload().__len__().__str__(), 'bytes' > + print(prefix + '=E2=94=80=E2=95=B4'+ z.get_content_type() + cset= + disposition + fname, z.get_payload().__len__().__str__(), 'bytes') >=20=20 > test(email.message_from_file(sys.stdin), '=E2=94=94') > --=20 > 2.17.1 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > https://notmuchmail.org/mailman/listinfo/notmuch