diff options
author | Anton Khirnov <anton@khirnov.net> | 2021-05-15 18:32:47 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2021-05-15 18:32:47 +0200 |
commit | 4d5af6a8d09e64ac94efc4dd4025366a4aef34d9 (patch) | |
tree | b2d12b9e22682ee1f8ae0d7d6396ec9c24680121 | |
parent | 4bfcf4787a1528744624701f7634928d991f7a53 (diff) |
commands/globals: invert a condition to reduce indent level
-rw-r--r-- | alot/commands/globals.py | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py index 76ecc1f4..885e3575 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -795,29 +795,31 @@ class ComposeCommand(Command): async def _set_signature(self, ui): account = self.envelope.account - if not self.omit_signature and account.signature: - 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 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: - 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 + else: + ui.notify('could not locate signature: %s' % sig, + priority='error') + if (await ui.choice('send without signature?', 'yes', + 'no')) == 'no': + raise self.ApplyError async def apply(self, ui): try: |