Package turbomail :: Module compat
[hide private]
[frames] | no frames]

Source Code for Module turbomail.compat

 1  # encoding: utf-8 
 2   
 3  """Compatibility module that exports symbols in a unified way on different  
 4  versions of Python.""" 
 5   
 6   
 7  # Python 2.3 does not have the built-in type 'set' 
 8  try: 
 9      set = set 
10   
11  except NameError: 
12      from sets import Set as set 
13   
14   
15  # In Python 2.5 the email modules were renamed for PEP-8 compliance 
16  try: 
17      from email import charset 
18      from email.encoders import encode_base64 
19      from email.header import Header 
20      from email.mime.base import MIMEBase 
21      from email.mime.image import MIMEImage 
22      from email.mime.multipart import MIMEMultipart 
23      from email.mime.text import MIMEText 
24      from email.utils import formataddr, formatdate, make_msgid, parseaddr, parsedate_tz 
25   
26  except ImportError: 
27      from email import Charset as charset 
28      from email.Encoders import encode_base64 
29      from email.Header import Header 
30      from email.MIMEBase import MIMEBase 
31      from email.MIMEImage import MIMEImage 
32      from email.MIMEMultipart import MIMEMultipart 
33      from email.MIMEText import MIMEText 
34      from email.Utils import formataddr, formatdate, make_msgid, parseaddr, parsedate_tz 
35   
36   
37 -def get_message(e):
38 # In Python 2.6 direct access to the property e.message is deprecated 39 # (see PEP 352). To circumvent the DeprecationWarnings we just use the same 40 # algorithm as Python 2.6 itself. Furthermore e.message won't work for 41 # Python 2.3 so probably it's best just to access e.args[0] for Python 2.x. 42 if hasattr(e, 'args') and len(e.args) == 1: 43 return e.args[0] 44 else: 45 return ''
46