From 4d5af6a8d09e64ac94efc4dd4025366a4aef34d9 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 15 May 2021 18:32:47 +0200 Subject: commands/globals: invert a condition to reduce indent level --- alot/commands/globals.py | 46 ++++++++++++++++++++++++---------------------- 1 file 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: -- cgit v1.2.3