summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-05-15 18:36:15 +0200
committerAnton Khirnov <anton@khirnov.net>2021-05-15 18:36:15 +0200
commit179a9d6c0c15be9383940259c98ab9cd41440b40 (patch)
tree57866f6e2712935f478bb4af8a5c73e2f01ca4ff
parent4d5af6a8d09e64ac94efc4dd4025366a4aef34d9 (diff)
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.
-rw-r--r--alot/commands/globals.py34
1 files 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)