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 98C946DE1613 for ; Mon, 11 Jun 2018 16:22:51 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.014 X-Spam-Level: X-Spam-Status: No, score=-0.014 tagged_above=-999 required=5 tests=[AWL=-0.024, RCVD_IN_DNSWL_NONE=-0.0001, T_SPF_PERMERROR=0.01] 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 E7kIl3_QWrYQ for ; Mon, 11 Jun 2018 16:22:50 -0700 (PDT) Received: from che.mayfirst.org (che.mayfirst.org [162.247.75.118]) by arlo.cworth.org (Postfix) with ESMTPS id 561276DE160A for ; Mon, 11 Jun 2018 16:22:50 -0700 (PDT) Received: from fifthhorseman.net (unknown [38.109.115.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by che.mayfirst.org (Postfix) with ESMTPSA id F3ECFF99A for ; Mon, 11 Jun 2018 19:22:48 -0400 (EDT) Received: by fifthhorseman.net (Postfix, from userid 1000) id 6B15920465; Mon, 11 Jun 2018 19:22:44 -0400 (EDT) From: Daniel Kahn Gillmor To: Notmuch Mail Subject: [PATCH] devel: make printmimestructure py3 compatible Date: Mon, 11 Jun 2018 19:22:44 -0400 Message-Id: <20180611232244.27207-1-dkg@fifthhorseman.net> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Mon, 11 Jun 2018 23:22:51 -0000 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. --- 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 -*- # 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" +from __future__ import print_function + import email import sys @@ -34,7 +36,7 @@ def test(z, prefix=''): if d[0] in [ 'attachment', 'inline' ]: disposition = ' ' + d[0] if (z.is_multipart()): - print prefix + '┬╴' + z.get_content_type() + cset + disposition + fname, z.as_string().__len__().__str__() + ' bytes' + print(prefix + '┬╴' + z.get_content_type() + cset + disposition + fname, z.as_string().__len__().__str__() + ' bytes') if prefix.endswith('└'): prefix = prefix.rpartition('└')[0] + ' ' if prefix.endswith('├'): @@ -47,6 +49,6 @@ def test(z, prefix=''): test(parts[i], prefix + '└') # FIXME: show epilogue? else: - print prefix + '─╴'+ z.get_content_type() + cset + disposition + fname, z.get_payload().__len__().__str__(), 'bytes' + print(prefix + '─╴'+ z.get_content_type() + cset + disposition + fname, z.get_payload().__len__().__str__(), 'bytes') test(email.message_from_file(sys.stdin), '└') -- 2.17.1