]> git.phdru.name Git - mimedecode.git/blobdiff - mimedecode.py
Split decode_message into decode_multipart
[mimedecode.git] / mimedecode.py
index 884f3582dd2b6b6987787b093623199bb4fddad0..d3d23ff2595418c7cc68557d63d822802caf865e 100755 (executable)
@@ -231,8 +231,8 @@ def decode_part(msg):
     totext(msg, outstring)
 
 
-def decode_message(msg):
-    "Decode message"
+def decode_multipart(msg):
+    "Decode multipart"
 
     if msg.is_multipart():
         decode_headers(msg)
@@ -247,10 +247,8 @@ def decode_message(msg):
             if boundary:
                 output("\n--%s\n" % boundary)
 
-            if subpart.is_multipart(): # Recursively decode all parts of the subpart
-                decode_message(subpart)
-            else:
-                decode_part(subpart)
+            # Recursively decode all parts of the subpart
+            decode_message(subpart)
 
         if boundary:
             output("\n--%s--\n" % boundary)
@@ -258,12 +256,15 @@ def decode_message(msg):
         if msg.epilogue:
             output(msg.epilogue)
 
-    else:
-        if msg.has_key("Content-Type"): # Simple one-part message - decode it
-            decode_part(msg)
+def decode_message(msg):
+    "Decode message"
 
-        else: # Not a message, just text - copy it literally
-            output(msg.as_string())
+    if msg.is_multipart():
+        decode_multipart(msg)
+    elif msg.has_key("Content-Type"): # Simple one-part message - decode it
+        decode_part(msg)
+    else: # Not a message, just text - copy it literally
+        output(msg.as_string())
 
 
 class GlobalOptions: