Skip to content

Commit

Permalink
Pipe focused mime part from the mime tree.
Browse files Browse the repository at this point in the history
When the mimetree is toggled on and a mime part is focused, pipeto
should pipe the focused mime part rather than the currently selected
part. This is only applicable to --format's that pipe a single part,
which are decoded and mimepart.
  • Loading branch information
ryneeverett committed May 7, 2020
1 parent e506686 commit a15a41e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions alot/commands/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from ..db.utils import decode_header
from ..db.utils import formataddr
from ..db.utils import get_body_part
from ..db.utils import extract_body_part
from ..db.utils import extract_headers
from ..db.utils import clear_my_address
from ..db.utils import ensure_unique_address
Expand Down Expand Up @@ -736,20 +737,22 @@ async def apply(self, ui):
else:
for msg in to_print:
mail = msg.get_email()
mimepart = getattr(
ui.get_deep_focus(), 'mimepart', False) or msg.mime_part
if self.add_tags:
mail.add_header('Tags', ', '.join(msg.get_tags()))
if self.output_format == 'raw':
pipestrings.append(mail.as_string())
elif self.output_format == 'decoded':
headertext = extract_headers(mail)
bodytext = msg.get_body_text()
bodytext = extract_body_part(mimepart)
msgtext = '%s\n\n%s' % (headertext, bodytext)
pipestrings.append(msgtext)
elif self.output_format in ['mimepart', 'plain', 'html']:
if self.output_format in ['plain', 'html']:
mimepart = get_body_part(mail, self.output_format)
pipestrings.append(string_sanitize(remove_cte(
msg.mime_part, as_string=True)))
mimepart, as_string=True)))

if not self.separately:
pipestrings = [separator.join(pipestrings)]
Expand Down

0 comments on commit a15a41e

Please sign in to comment.