1 #!/usr/bin/env python 2 3 from email.mime.multipart import MIMEMultipart 4 from email.mime.application import MIMEApplication 5 from email.mime.base import MIMEBase 6 from email import message_from_string 7 from MoinMessage import as_string 8 import sys 9 10 if __name__ == "__main__": 11 message = sys.argv[1] 12 text = open(message).read() 13 signature = sys.stdin.read() 14 protocol = "application/pgp-signature" 15 subtype = "signed" 16 17 # Make the container for the message. 18 19 message = MIMEMultipart(subtype, protocol=protocol) 20 21 submessage = message_from_string(text) 22 message.attach(submessage) 23 24 signature_part = MIMEBase("application", "pgp-signature") 25 signature_part.set_payload(signature) 26 message.attach(signature_part) 27 28 # Show the resulting message text. 29 30 text = as_string(message) 31 32 print text 33 34 # vim: tabstop=4 expandtab shiftwidth=4