paul@565 | 1 | #!/usr/bin/env python |
paul@565 | 2 | |
paul@564 | 3 | from email import message_from_file |
paul@564 | 4 | import sys |
paul@564 | 5 | |
paul@564 | 6 | def decode(part): |
paul@564 | 7 | for key, value in part.items(): |
paul@687 | 8 | if key != "Content-Transfer-Encoding": |
paul@687 | 9 | print "%s: %s" % (key, value) |
paul@564 | 10 | print |
paul@564 | 11 | decoded = part.get_payload(decode=True) |
paul@564 | 12 | if decoded: |
paul@564 | 13 | print decoded |
paul@564 | 14 | print |
paul@564 | 15 | else: |
paul@564 | 16 | for part in part.get_payload(): |
paul@564 | 17 | decode(part) |
paul@564 | 18 | |
paul@564 | 19 | message = message_from_file(sys.stdin) |
paul@564 | 20 | decode(message) |
paul@572 | 21 | |
paul@572 | 22 | # vim: tabstop=4 expandtab shiftwidth=4 |