diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2012-09-16 14:20:21 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2012-09-16 14:20:21 +0100 |
commit | 126c0387d94b04c617ac279ba377cae308f230c0 (patch) | |
tree | 9233e21f92293a7cb67791123b4285ceb9e3d346 | |
parent | 2e213c05aee22163ff0e6c3b24497d14364cb79a (diff) |
interpret 'Attach' pseudo header
cf issue #519
-rw-r--r-- | alot/db/envelope.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/alot/db/envelope.py b/alot/db/envelope.py index 041b26d6..f63c671b 100644 --- a/alot/db/envelope.py +++ b/alot/db/envelope.py @@ -4,6 +4,7 @@ import os import email import re +import glob import email.charset as charset charset.add_charset('utf-8', charset.QP, charset.QP, 'utf-8') from email.encoders import encode_7or8bit @@ -266,3 +267,14 @@ class Envelope(object): value += line if key and value: # save last one if present self.add(key, value) + + # interpret 'Attach' pseudo header + if 'Attach' in self: + to_attach = [] + for line in self['Attach']: + gpath = os.path.expanduser(line.strip()) + to_attach += filter(os.path.isfile, glob.glob(gpath)) + logging.debug('Attaching: %s' % to_attach) + for path in to_attach: + self.attach(path) + del(self['Attach']) |