From: Tomi Ollila <tomi.ollila@iki.fi>
To: Daniel Kahn Gillmor <dkg@fifthhorseman.net>,
Notmuch Mail <notmuch@notmuchmail.org>
Subject: Re: [PATCH] devel: make printmimestructure py3 compatible
Date: Tue, 12 Jun 2018 11:35:09 +0300 [thread overview]
Message-ID: <m2h8m81jya.fsf@guru.guru-group.fi> (raw)
In-Reply-To: <20180611232244.27207-1-dkg@fifthhorseman.net>
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
-#!/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 -*-
>
> # Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
> @@ -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
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
next prev parent reply other threads:[~2018-06-12 8:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-11 23:22 [PATCH] devel: make printmimestructure py3 compatible Daniel Kahn Gillmor
2018-06-12 2:00 ` [PATCH] minor cleanup to printmimestructure Jameson Graef Rollins
2018-06-12 8:35 ` Tomi Ollila [this message]
2018-06-12 8:53 ` [PATCH] devel: make printmimestructure py3 compatible Reto Brunner
2018-06-12 10:47 ` Thomas Schneider
2018-06-12 13:57 ` Daniel Kahn Gillmor
2018-06-12 21:25 ` Daniel Kahn Gillmor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2h8m81jya.fsf@guru.guru-group.fi \
--to=tomi.ollila@iki.fi \
--cc=dkg@fifthhorseman.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).