[Erp5-report] r35346 nicolas - /erp5/trunk/products/ERP5/Document/EmailDocument.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri May 14 15:22:56 CEST 2010


Author: nicolas
Date: Fri May 14 15:22:49 2010
New Revision: 35346

URL: http://svn.erp5.org?rev=35346&view=rev
Log:
Code optimisation, thanks Luke

Modified:
    erp5/trunk/products/ERP5/Document/EmailDocument.py

Modified: erp5/trunk/products/ERP5/Document/EmailDocument.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/EmailDocument.py?rev=35346&r1=35345&r2=35346&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/EmailDocument.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/EmailDocument.py [utf8] Fri May 14 15:22:49 2010
@@ -238,12 +238,8 @@
           # get_filename return name only from Content-Disposition header
           # of the message but sometimes this value is stored in
           # Content-Type header
-          if 'Content-Type' in kw:
-            content_type_header = kw['Content-Type']
-          elif 'Content-type' in kw:
-            content_type_header = kw['Content-type']
-          else:
-            content_type_header = ''
+          content_type_header = kw.get('Content-Type',
+                                                    kw.get('Content-type', ''))
           file_name_list = re.findall(file_name_regexp,
                                       content_type_header,
                                       re.MULTILINE)
@@ -252,12 +248,9 @@
         if file_name:
           kw['file_name'] = file_name
         else:
-          content_disposition = None
+          content_disposition = kw.get('Content-Disposition', 
+                                           kw.get('Content-disposition'), None)
           prefix = 'part_'
-          if 'Content-Disposition' in kw:
-            content_disposition = kw['Content-Disposition']
-          elif 'Content-disposition' in kw:
-            content_disposition = kw['Content-disposition']
           if content_disposition:
             if content_disposition.split(';')[0] == 'attachment':
               prefix = 'attachment_'
@@ -285,10 +278,8 @@
             # get_filename return name only from Content-Disposition header
             # of the message but sometimes this value is stored in
             # Content-Type header
-            if 'Content-Type' in kw:
-              content_type_header = kw['Content-Type']
-            elif 'Content-type' in kw:
-              content_type_header = kw['Content-Type']
+            content_type_header = kw.get('Content-Type',
+                                                    kw.get('Content-type', ''))
             file_name_list = re.findall(file_name_regexp,
                                         content_type_header,
                                         re.MULTILINE)




More information about the Erp5-report mailing list