From 179a9d6c0c15be9383940259c98ab9cd41440b40 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 15 May 2021 18:36:15 +0200 Subject: commands/globals: remove special treatment for a missing signature file It is unnecessary extra complexity. If the user set a signature, then it must exist. If it does not exist, the user should unset the signature path. --- alot/commands/globals.py | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/alot/commands/globals.py b/alot/commands/globals.py index 885e3575..bcd9a2c3 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -793,33 +793,25 @@ class ComposeCommand(Command): if self.envelope.account is None: self.envelope.account = account - async def _set_signature(self, ui): + def _set_signature(self, ui): account = self.envelope.account if self.omit_signature or not account.signature: return logging.debug('has signature') sig = os.path.expanduser(account.signature) - if os.path.isfile(sig): - logging.debug('is file') - if account.signature_as_attachment: - name = account.signature_filename or None - self.envelope.attach_file(sig, filename = name) - logging.debug('attached') - else: - try: - with open(sig, 'r') as f: - sigcontent = f.read() - except UnicodeDecodeError: - ui.notify('Could not read signature', priority = 'error') - else: - self.envelope.body += '\n' + sigcontent + if account.signature_as_attachment: + name = account.signature_filename or None + self.envelope.attach_file(sig, filename = name) + logging.debug('attached') else: - ui.notify('could not locate signature: %s' % sig, - priority='error') - if (await ui.choice('send without signature?', 'yes', - 'no')) == 'no': - raise self.ApplyError + try: + with open(sig, 'r') as f: + sigcontent = f.read() + except UnicodeDecodeError: + ui.notify('Could not read signature', priority = 'error') + else: + self.envelope.body += '\n' + sigcontent async def apply(self, ui): try: @@ -963,7 +955,7 @@ class ComposeCommand(Command): await self._get_sender_details(ui) # add signature - await self._set_signature(ui) + self._set_signature(ui) # Figure out whether we should GPG sign messages by default # and look up key if so self._set_gpg_sign(ui) -- cgit v1.2.3