]> git.notmuchmail.org Git - notmuch/commitdiff
devel: make printmimestructure py3 compatible
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Tue, 12 Jun 2018 21:21:08 +0000 (17:21 -0400)
committerDavid Bremner <david@tethera.net>
Thu, 14 Jun 2018 23:33:17 +0000 (20:33 -0300)
Make printmimestructure work in python3 as well as python2.

devel/printmimestructure

index 34d12930b4c986b82252689b567517b729c6155b..a5fc83e7ec433416b4aee73017674c88566d33ac 100755 (executable)
@@ -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), '└')