imip-agent

Annotated tools/showmail.py

686:b5bdf9dcad0f
2015-09-04 Paul Boddie Added docstrings.
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@564 8
        print "%s: %s" % (key, value)
paul@564 9
    print
paul@564 10
    decoded = part.get_payload(decode=True)
paul@564 11
    if decoded:
paul@564 12
        print decoded
paul@564 13
        print
paul@564 14
    else:
paul@564 15
        for part in part.get_payload():
paul@564 16
            decode(part)
paul@564 17
paul@564 18
message = message_from_file(sys.stdin)
paul@564 19
decode(message)
paul@572 20
paul@572 21
# vim: tabstop=4 expandtab shiftwidth=4