Commit 8a33ff96 authored by Nicolas Delaby's avatar Nicolas Delaby

Code optimisation, thanks Luke

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35346 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 242767ba
...@@ -238,12 +238,8 @@ class EmailDocument(TextDocument): ...@@ -238,12 +238,8 @@ class EmailDocument(TextDocument):
# get_filename return name only from Content-Disposition header # get_filename return name only from Content-Disposition header
# of the message but sometimes this value is stored in # of the message but sometimes this value is stored in
# Content-Type header # Content-Type header
if 'Content-Type' in kw: content_type_header = kw.get('Content-Type',
content_type_header = kw['Content-Type'] kw.get('Content-type', ''))
elif 'Content-type' in kw:
content_type_header = kw['Content-type']
else:
content_type_header = ''
file_name_list = re.findall(file_name_regexp, file_name_list = re.findall(file_name_regexp,
content_type_header, content_type_header,
re.MULTILINE) re.MULTILINE)
...@@ -252,12 +248,9 @@ class EmailDocument(TextDocument): ...@@ -252,12 +248,9 @@ class EmailDocument(TextDocument):
if file_name: if file_name:
kw['file_name'] = file_name kw['file_name'] = file_name
else: else:
content_disposition = None content_disposition = kw.get('Content-Disposition',
kw.get('Content-disposition'), None)
prefix = 'part_' 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:
if content_disposition.split(';')[0] == 'attachment': if content_disposition.split(';')[0] == 'attachment':
prefix = 'attachment_' prefix = 'attachment_'
...@@ -285,10 +278,8 @@ class EmailDocument(TextDocument): ...@@ -285,10 +278,8 @@ class EmailDocument(TextDocument):
# get_filename return name only from Content-Disposition header # get_filename return name only from Content-Disposition header
# of the message but sometimes this value is stored in # of the message but sometimes this value is stored in
# Content-Type header # Content-Type header
if 'Content-Type' in kw: content_type_header = kw.get('Content-Type',
content_type_header = kw['Content-Type'] kw.get('Content-type', ''))
elif 'Content-type' in kw:
content_type_header = kw['Content-Type']
file_name_list = re.findall(file_name_regexp, file_name_list = re.findall(file_name_regexp,
content_type_header, content_type_header,
re.MULTILINE) re.MULTILINE)
......
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