diff options
author | Anton Khirnov <anton@khirnov.net> | 2021-01-29 14:06:56 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2021-01-29 14:07:19 +0100 |
commit | 27e9478faefecf5b290c0fbd3df5b1fe9e18c97f (patch) | |
tree | 0e62d3cba32c83b78f2ec6e6e4d905fcf261fb99 | |
parent | 0f2198c62185837410cf0c8d9a6e7110e4cb965d (diff) |
SendCommand: stop using an instance attribute unnecessarily
-rw-r--r-- | alot/commands/envelope.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py index 72c9d42d..c146dacb 100644 --- a/alot/commands/envelope.py +++ b/alot/commands/envelope.py @@ -154,13 +154,16 @@ class SaveCommand(Command): @registerCommand(MODE, 'send') class SendCommand(Command): """send mail""" + + _mail = None + def __init__(self, mail = None): """ :param mail: email to send :type email: email.message.Message """ super().__init__() - self.mail = mail + self._mail = mail def _get_keys_addresses(self, envelope): addresses = set() @@ -183,7 +186,8 @@ class SendCommand(Command): envelope = None envelope_buffer = None - if self.mail is None: + mail = self._mail + if mail is None: # needed to close later envelope_buffer = ui.current_buffer envelope = envelope_buffer.envelope @@ -234,8 +238,8 @@ class SendCommand(Command): timeout=-1) try: - self.mail = envelope.construct_mail() - self.mail = self.mail.as_string(policy=email.policy.SMTP) + mail = envelope.construct_mail() + mail = mail.as_string(policy=email.policy.SMTP) except GPGProblem as e: ui.clear_notify(clearme) ui.notify(str(e), priority='error') @@ -244,10 +248,10 @@ class SendCommand(Command): ui.clear_notify(clearme) # determine account to use for sending - msg = self.mail + msg = mail if not isinstance(msg, email.message.Message): msg = email.message_from_string( - self.mail, policy=email.policy.SMTP) + mail, policy=email.policy.SMTP) address = msg.get('Resent-From', False) or msg.get('From', '') logging.debug("FROM: \"%s\"" % address) try: @@ -264,7 +268,7 @@ class SendCommand(Command): envelope.sending = True # FIXME XXX horrible hack, fix the type fuckery - to_send = self.mail + to_send = mail if isinstance(to_send, str): to_send = to_send.encode('ascii') else: @@ -305,7 +309,7 @@ class SendCommand(Command): # store mail locally # This can raise StoreMailError - path = account.store_sent_mail(self.mail) + path = account.store_sent_mail(mail) # add mail to index if maildir path available if path is not None: |