summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2018-06-12 17:21:08 -0400
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>2019-09-14 14:58:06 -0400
commit4aa83c9d18252c44814668cdd4a39b65f8f54234 (patch)
tree8fb6ca1fec1c0a4c676962423cb5c585ef56cda3
parentdc1d376ae6881c364142899d20ca0053b65039da (diff)
downloadmailscripts-4aa83c9d18252c44814668cdd4a39b65f8f54234.tar.gz
devel: make printmimestructure py3 compatible
Make printmimestructure work in python3 as well as python2. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
-rwxr-xr-xprintmimestructure6
1 files changed, 4 insertions, 2 deletions
diff --git a/printmimestructure b/printmimestructure
index 34d1293..a5fc83e 100755
--- a/printmimestructure
+++ b/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), '└')