Skip to content
Snippets Groups Projects
Commit 89f6b9de authored by Moul's avatar Moul
Browse files

[mod] #194: {cli,crypto}_tools: Use f-string

parent 4bc8a211
No related branches found
No related tags found
1 merge request!195#194, #376: Use f-string and sys.exit()
......@@ -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)
......@@ -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."
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment