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 C8FC66DE16BA for ; Tue, 12 Jun 2018 14:21:17 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.013 X-Spam-Level: X-Spam-Status: No, score=-0.013 tagged_above=-999 required=5 tests=[AWL=-0.023, 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 4kkbxV7l9huF for ; Tue, 12 Jun 2018 14:21:17 -0700 (PDT) Received: from che.mayfirst.org (che.mayfirst.org [162.247.75.118]) by arlo.cworth.org (Postfix) with ESMTPS id E785C6DE16BF for ; Tue, 12 Jun 2018 14:21:15 -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 96F61F99B for ; Tue, 12 Jun 2018 17:21:14 -0400 (EDT) Received: by fifthhorseman.net (Postfix, from userid 1000) id 3002F20323; Tue, 12 Jun 2018 17:21:10 -0400 (EDT) From: Daniel Kahn Gillmor To: Notmuch Mail Subject: [PATCH v2 1/3] devel: make printmimestructure py3 compatible Date: Tue, 12 Jun 2018 17:21:08 -0400 Message-Id: <20180612212110.32533-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: Tue, 12 Jun 2018 21:21:17 -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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/devel/printmimestructure b/devel/printmimestructure index 34d12930..a5fc83e7 100755 --- a/devel/printmimestructure +++ b/devel/printmimestructure @@ -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