]> git.phdru.name Git - mimedecode.git/blobdiff - mimedecode.py
Rename get_opt to get_opts
[mimedecode.git] / mimedecode.py
index c12afbb963bcdd60eeaee789d6de8848d8ee1a26..64281715ac0a213f584eb66e41ea20936bde1bd7 100755 (executable)
@@ -325,12 +325,19 @@ def decode_multipart(msg):
 
     if msg.preamble: # Preserve the first part, it is probably not a RFC822-message
         output(msg.preamble) # Usually it is just a few lines of text (MIME warning)
+    if msg.preamble is not None:
+        output("\n")
 
+    first_subpart = True
     boundary = msg.get_boundary()
 
     for subpart in msg.get_payload():
         if boundary:
-            output("\n--%s\n" % boundary)
+            if first_subpart:
+                first_subpart = False
+            else:
+                output("\n")
+            output("--%s\n" % boundary)
 
         # Recursively decode all parts of the subpart
         decode_message(subpart)
@@ -391,7 +398,7 @@ class GlobalOptions:
 gopts = GlobalOptions
 
 
-def get_opt():
+def get_opts():
     from getopt import getopt, GetoptError
 
     try:
@@ -456,7 +463,7 @@ def get_opt():
 
 
 if __name__ == "__main__":
-    arguments = get_opt()
+    arguments = get_opts()
 
     la = len(arguments)
     if la == 0: