From 89f6b9decc80599e3129e1e5df09e64e1a035362 Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Sun, 26 Sep 2021 13:28:00 +0200 Subject: [PATCH] [mod] #194: {cli,crypto}_tools: Use f-string --- silkaj/cli_tools.py | 11 +++++------ silkaj/crypto_tools.py | 9 +++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/silkaj/cli_tools.py b/silkaj/cli_tools.py index 5aa0c6c8..1e658ecb 100644 --- a/silkaj/cli_tools.py +++ b/silkaj/cli_tools.py @@ -22,17 +22,16 @@ class MutuallyExclusiveOption(Option): help = kwargs.get("help", "") if self.mutually_exclusive: ex_str = ", ".join(self.mutually_exclusive) - kwargs["help"] = help + ( - " NOTE: This argument is mutually exclusive with " - " arguments: [" + ex_str + "]." - ) + kwargs[ + "help" + ] = f"{help} NOTE: This argument is mutually exclusive with arguments: [{ex_str}]." super().__init__(*args, **kwargs) def handle_parse_result(self, ctx, opts, args): if self.mutually_exclusive.intersection(opts) and self.name in opts: + arguments = ", ".join(self.mutually_exclusive) raise UsageError( - "Usage: `{}` is mutually exclusive with " - "arguments `{}`.".format(self.name, ", ".join(self.mutually_exclusive)) + f"Usage: `{self.name}` is mutually exclusive with arguments `{arguments}`." ) return super().handle_parse_result(ctx, opts, args) diff --git a/silkaj/crypto_tools.py b/silkaj/crypto_tools.py index 60ae6e54..429ffc65 100644 --- a/silkaj/crypto_tools.py +++ b/silkaj/crypto_tools.py @@ -51,7 +51,7 @@ def check_pubkey_format(pubkey, display_error=True): elif re.search(re.compile(PUBKEY_CHECKSUM_PATTERN), pubkey): return True elif display_error: - message_exit("Error: bad format for following public key: " + pubkey) + message_exit(f"Error: bad format for following public key: {pubkey}") return @@ -65,11 +65,8 @@ def validate_checksum(pubkey_checksum): if checksum == gen_checksum(pubkey): return pubkey message_exit( - "Error: public key '" - + pubkey - + "' does not match checksum '" - + checksum - + "'.\nPlease verify the public key." + f"Error: public key '{pubkey}' does not match checksum '{checksum}'.\n\ +Please verify the public key." ) -- GitLab