summaryrefslogtreecommitdiff
path: root/alot/message.py
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2011-10-21 14:11:25 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2011-10-21 14:11:25 +0100
commit2d6ac9e84d691192d17a6423ee4884123141a379 (patch)
treef854f97e9492e4987327d9da2e3d41259d9dfc0b /alot/message.py
parent4f338f321c7530ae00e7c29bf3131768230ec914 (diff)
added global tabwidth config
no. of spaces to replace tabs in body _and_ headers. issues #99, #106
Diffstat (limited to 'alot/message.py')
-rw-r--r--alot/message.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/alot/message.py b/alot/message.py
index 0459649c..c2927a85 100644
--- a/alot/message.py
+++ b/alot/message.py
@@ -182,6 +182,7 @@ class Message(object):
def extract_body(mail):
body_parts = []
+ tab_width = config.getint('general', 'tabwidth')
for part in mail.walk():
ctype = part.get_content_type()
enc = part.get_content_charset()
@@ -213,10 +214,11 @@ def extract_body(mail):
#remove tempfile
os.unlink(tmpfile.name)
if rendered_payload: # handler had output
- body_parts.append(rendered_payload.strip())
+ payload = rendered_payload.strip()
elif part.get_content_maintype() == 'text':
- body_parts.append(raw_payload)
+ payload = raw_payload
# else drop
+ body_parts.append(payload.replace('\t', ' ' * tab_width))
return '\n\n'.join(body_parts)
@@ -244,10 +246,11 @@ def decode_header(header):
valuelist = email.header.decode_header(header)
decoded_list = []
+ tab_width = config.getint('general', 'tabwidth')
for v, enc in valuelist:
if enc:
- v = v.decode(enc, errors='replace')
- #v = re.sub('^\s+', ' ', v, flags=re.MULTILINE)
+ v = v.decode(enc, errors='replace').strip()
+ v = v.replace('\t', ' ' * tab_width)
decoded_list.append(v)
return u' '.join(decoded_list)