1 #!/usr/bin/env python 2 3 from MoinMessage import Message 4 from email.mime.multipart import MIMEMultipart 5 from email.mime.text import MIMEText 6 import sys 7 8 if __name__ == "__main__": 9 try: 10 type = sys.argv[1] 11 action = sys.argv[2] 12 args = sys.argv[3:] 13 except IndexError: 14 args = None 15 16 if not args: 17 print >>sys.stderr, "Need an update type, update action and some updates as arguments to this program." 18 sys.exit(1) 19 20 message = Message() 21 parts = [] 22 23 # Add each content fragment as either a separate update to a collection of 24 # updates or as an alternative part to a single update. 25 26 for arg in args: 27 part = MIMEText(arg, "moin", sys.stdin.encoding) 28 if type == "collection": 29 part["Update-Action"] = action 30 message.add_update(part) 31 else: 32 parts.append(part) 33 34 if type != "collection": 35 multipart = message.get_update(parts) 36 multipart["Update-Action"] = action 37 message.add_update(multipart) 38 39 text = message.get_payload() 40 print text 41 42 # vim: tabstop=4 expandtab shiftwidth=4