From a8092373cdadcfc58fbba22285ae04c6a8e37ec2 Mon Sep 17 00:00:00 2001
From: Kevin Deldycke <kevin@nexedi.com>
Date: Mon, 3 Apr 2006 15:41:51 +0000
Subject: [PATCH] Add support of quoted-printable encoding for python 2.4
 Reduce the code complexity

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6435 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/MailMessage.py | 38 ++++++++++------------------
 1 file changed, 14 insertions(+), 24 deletions(-)

diff --git a/product/ERP5/Document/MailMessage.py b/product/ERP5/Document/MailMessage.py
index 60e9ea567b..5ed1f4bf32 100644
--- a/product/ERP5/Document/MailMessage.py
+++ b/product/ERP5/Document/MailMessage.py
@@ -45,32 +45,22 @@ from zLOG import LOG
 
 # Support mail decoding in both python v2.3 and v2.4.
 # See http://www.freesoft.org/CIE/RFC/1521/5.htm for 'content-transfer-encoding' explaination.
-import base64
-global supported_decoding
-supported_decoding = {}
+import binascii
 try:
-  # python v2.4 API
-  supported_decoding = {
-      'base64'          : base64.b64decode
-    , 'base32'          : base64.b32decode
-    , 'base16'          : base64.b16decode
-#    , 'quoted-printable': None
-    # "8bit", "7bit", and "binary" values all mean that NO encoding has been performed
-    , '8bit'            : None
-    , '7bit'            : None
-    , 'binary'          : None
-    }
-except AttributeError:
   # python v2.3 API
-  import binascii
-  supported_decoding = {
-      'base64'          : base64.decodestring
-    , 'quoted-printable': binascii.a2b_qp
-    # "8bit", "7bit", and "binary" values all mean that NO encoding has been performed
-    , '8bit'            : None
-    , '7bit'            : None
-    , 'binary'          : None
-    }
+  from base64 import decodestring as b64decode
+except AttributeError:
+  # python v2.4 API
+  from base64 import b64decode
+global supported_decoding
+supported_decoding = {
+    'base64'          : base64.b64decode
+  , 'quoted-printable': binascii.a2b_qp
+  # "8bit", "7bit", and "binary" values all mean that NO encoding has been performed
+  , '8bit'            : None
+  , '7bit'            : None
+  , 'binary'          : None
+  }
 
 
 class MailMessage(XMLObject, Event, CMFMailInMessage):
-- 
2.30.9