Commit a8092373 authored by Kevin Deldycke's avatar Kevin Deldycke

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
parent e8181fa1
...@@ -45,32 +45,22 @@ from zLOG import LOG ...@@ -45,32 +45,22 @@ from zLOG import LOG
# Support mail decoding in both python v2.3 and v2.4. # 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. # See http://www.freesoft.org/CIE/RFC/1521/5.htm for 'content-transfer-encoding' explaination.
import base64 import binascii
global supported_decoding
supported_decoding = {}
try: 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 # python v2.3 API
import binascii from base64 import decodestring as b64decode
supported_decoding = { except AttributeError:
'base64' : base64.decodestring # python v2.4 API
, 'quoted-printable': binascii.a2b_qp from base64 import b64decode
# "8bit", "7bit", and "binary" values all mean that NO encoding has been performed global supported_decoding
, '8bit' : None supported_decoding = {
, '7bit' : None 'base64' : base64.b64decode
, 'binary' : None , '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): class MailMessage(XMLObject, Event, CMFMailInMessage):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment