Use literal string interpolation in core (f-strings) (#26166)

This commit is contained in:
Franck Nijhof 2019-08-23 18:53:33 +02:00 committed by Paulus Schoutsen
parent 1efa29d6ff
commit decf13b948
67 changed files with 180 additions and 246 deletions

View file

@ -36,29 +36,27 @@ def run(args):
if args.action == "info":
keyr = keyring.get_keyring()
print("Keyring version {}\n".format(REQUIREMENTS[0].split("==")[1]))
print("Active keyring : {}".format(keyr.__module__))
print(f"Active keyring : {keyr.__module__}")
config_name = os.path.join(platform.config_root(), "keyringrc.cfg")
print("Config location : {}".format(config_name))
print(f"Config location : {config_name}")
print("Data location : {}\n".format(platform.data_root()))
elif args.name is None:
parser.print_help()
return 1
if args.action == "set":
entered_secret = getpass.getpass(
"Please enter the secret for {}: ".format(args.name)
)
entered_secret = getpass.getpass(f"Please enter the secret for {args.name}: ")
keyring.set_password(_SECRET_NAMESPACE, args.name, entered_secret)
print("Secret {} set successfully".format(args.name))
print(f"Secret {args.name} set successfully")
elif args.action == "get":
the_secret = keyring.get_password(_SECRET_NAMESPACE, args.name)
if the_secret is None:
print("Secret {} not found".format(args.name))
print(f"Secret {args.name} not found")
else:
print("Secret {}={}".format(args.name, the_secret))
print(f"Secret {args.name}={the_secret}")
elif args.action == "del":
try:
keyring.delete_password(_SECRET_NAMESPACE, args.name)
print("Deleted secret {}".format(args.name))
print(f"Deleted secret {args.name}")
except keyring.errors.PasswordDeleteError:
print("Secret {} not found".format(args.name))
print(f"Secret {args.name} not found")