]> git.phdru.name Git - mimedecode.git/blobdiff - mimedecode.py
Use list/tuple directly instead of using types module
[mimedecode.git] / mimedecode.py
index b57bd956557624acb899fc786ddfbbb72b7f24cf..569559b19e722e11de98ece1daaec3063fe51521 100755 (executable)
@@ -47,11 +47,10 @@ def _decode_header(s):
     """Return a decoded string according to RFC 2047.
     NOTE: This is almost the same as email.Utils.decode.
     """
-    from types import ListType
     import email.Header
 
     L = email.Header.decode_header(s)
-    if not isinstance(L, ListType):
+    if not isinstance(L, list):
         # s wasn't decoded
         return s
 
@@ -87,14 +86,11 @@ def decode_header_param(msg, header, param):
     if msg.has_key(header):
         value = msg.get_param(param, header=header)
         if value:
-            from types import TupleType
-            if isinstance(value, TupleType):
+            if isinstance(value, tuple):
                 new_value = _decode_header_param(value)
-                changed = new_value <> value[2]
             else:
                 new_value = _decode_header(value)
-                changed = new_value <> value
-            if changed: # do not bother to touch msg if not changed
+            if new_value <> value: # do not bother to touch msg if not changed
                 msg.set_param(param, new_value, header)
 
 
@@ -275,11 +271,15 @@ class GlobalOptions:
 
     host_name = None
 
-    decode_headers = ["From", "To", "Subject"] # A list of headers to decode
+    # A list of headers to decode
+    decode_headers = ["From", "To", "Cc", "Reply-To", "Mail-Followup-To",
+                      "Subject"]
+
+    # A list of headers' parameters to decode
     decode_header_params = [
         ("Content-Type", "name"),
         ("Content-Disposition", "filename"),
-    ] # A list of headers' parameters to decode
+    ]
 
     totext_mask = [] # A list of content-types to decode
     binary_mask = [] # A list to pass through