pmb.chroot: fix E501, switch to f-strings (MR 2040)

This commit is contained in:
Anri Dellal 2021-03-22 00:19:12 +03:00 committed by Oliver Smith
parent 87c7859b40
commit 88ec1d1106
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
9 changed files with 179 additions and 152 deletions

View file

@ -23,7 +23,7 @@ def list_chroot(args, suffix, remove_prefix=True):
def list_aports(args):
ret = []
prefix = pmb.config.initfs_hook_prefix
for path in glob.glob(args.aports + "/*/" + prefix + "*"):
for path in glob.glob(f"{args.aports}/*/{prefix}*"):
ret.append(os.path.basename(path)[len(prefix):])
return ret
@ -33,27 +33,24 @@ def ls(args, suffix):
hooks_aports = list_aports(args)
for hook in hooks_aports:
line = "* " + hook
if hook in hooks_chroot:
line += " (installed)"
else:
line += " (not installed)"
line = f"* {hook} ({'' if hook in hooks_chroot else 'not '}installed)"
logging.info(line)
def add(args, hook, suffix):
if hook not in list_aports(args):
raise RuntimeError("Invalid hook name! Run 'pmbootstrap initfs hook_ls'"
raise RuntimeError("Invalid hook name!"
" Run 'pmbootstrap initfs hook_ls'"
" to get a list of all hooks.")
prefix = pmb.config.initfs_hook_prefix
pmb.chroot.apk.install(args, [prefix + hook], suffix)
pmb.chroot.apk.install(args, [f"{prefix}{hook}"], suffix)
def delete(args, hook, suffix):
if hook not in list_chroot(args, suffix):
raise RuntimeError("There is no such hook installed!")
prefix = pmb.config.initfs_hook_prefix
pmb.chroot.root(args, ["apk", "del", prefix + hook], suffix)
pmb.chroot.root(args, ["apk", "del", f"{prefix}{hook}"], suffix)
def update(args, suffix):