1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-04-08 21:17:20 +00:00

modules bc*: use f-strings (#10945)

* modules bc*: use f-strings

* no quotes or backticks inside f-strs

* add changelog frag

* rename chglof frag file

* rename chglof frag file

* copr: re-applied change maintain original logic
This commit is contained in:
Alexei Znamensky 2025-10-25 12:45:40 +13:00 committed by GitHub
parent f9b4abf930
commit 0ef2235929
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 197 additions and 202 deletions

View file

@ -116,13 +116,13 @@ class CapabilitiesModule(object):
# If the file does not exist, the stderr will be (with rc == 0...):
# '/foo (No such file or directory)'
if rc != 0 or stderr != "":
self.module.fail_json(msg="Unable to get capabilities of %s" % path, stdout=stdout.strip(), stderr=stderr)
self.module.fail_json(msg=f"Unable to get capabilities of {path}", stdout=stdout.strip(), stderr=stderr)
if stdout.strip() != path:
if ' =' in stdout:
# process output of an older version of libcap
caps = stdout.split(' =')[1].strip().split()
elif stdout.strip().endswith(")"): # '/foo (Error Message)'
self.module.fail_json(msg="Unable to get capabilities of %s" % path, stdout=stdout.strip(), stderr=stderr)
self.module.fail_json(msg=f"Unable to get capabilities of {path}", stdout=stdout.strip(), stderr=stderr)
else:
# otherwise, we have a newer version here
# see original commit message of cap/v0.2.40-18-g177cd41 in libcap.git
@ -145,7 +145,7 @@ class CapabilitiesModule(object):
cmd = [self.setcap_cmd, caps, path]
rc, stdout, stderr = self.module.run_command(cmd)
if rc != 0:
self.module.fail_json(msg="Unable to set capabilities of %s" % path, stdout=stdout, stderr=stderr)
self.module.fail_json(msg=f"Unable to set capabilities of {path}", stdout=stdout, stderr=stderr)
else:
return stdout
@ -158,7 +158,7 @@ class CapabilitiesModule(object):
i += 1
except Exception:
if op_required:
self.module.fail_json(msg="Couldn't find operator (one of: %s)" % str(OPS))
self.module.fail_json(msg=f"Couldn't find operator (one of: {OPS})")
else:
return (cap, None, None)
op = cap[opind]