lookup plugins: use f-strings (#9324)

* lookup plugins: use f-strings

* add changelog frag

* manual change for few occurrences

* Update plugins/lookup/dependent.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* adjustment from review

* no f-string for you

* Update plugins/lookup/dependent.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Alexei Znamensky 2024-12-25 21:48:06 +13:00 committed by GitHub
parent 2005125af4
commit 6cd3f79e19
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 165 additions and 149 deletions

View file

@ -105,7 +105,7 @@ class CyberarkPassword:
self.extra_parms = []
for key, value in kwargs.items():
self.extra_parms.append('-p')
self.extra_parms.append("%s=%s" % (key, value))
self.extra_parms.append(f"{key}={value}")
if self.appid is None:
raise AnsibleError("CyberArk Error: No Application ID specified")
@ -130,8 +130,8 @@ class CyberarkPassword:
all_parms = [
CLIPASSWORDSDK_CMD,
'GetPassword',
'-p', 'AppDescs.AppID=%s' % self.appid,
'-p', 'Query=%s' % self.query,
'-p', f'AppDescs.AppID={self.appid}',
'-p', f'Query={self.query}',
'-o', self.output,
'-d', self.b_delimiter]
all_parms.extend(self.extra_parms)
@ -144,7 +144,7 @@ class CyberarkPassword:
b_credential = to_bytes(tmp_output)
if tmp_error:
raise AnsibleError("ERROR => %s " % (tmp_error))
raise AnsibleError(f"ERROR => {tmp_error} ")
if b_credential and b_credential.endswith(b'\n'):
b_credential = b_credential[:-1]
@ -164,7 +164,7 @@ class CyberarkPassword:
except subprocess.CalledProcessError as e:
raise AnsibleError(e.output)
except OSError as e:
raise AnsibleError("ERROR - AIM not installed or clipasswordsdk not in standard location. ERROR=(%s) => %s " % (to_text(e.errno), e.strerror))
raise AnsibleError(f"ERROR - AIM not installed or clipasswordsdk not in standard location. ERROR=({to_text(e.errno)}) => {e.strerror} ")
return [result_dict]
@ -177,11 +177,11 @@ class LookupModule(LookupBase):
"""
def run(self, terms, variables=None, **kwargs):
display.vvvv("%s" % terms)
display.vvvv(f"{terms}")
if isinstance(terms, list):
return_values = []
for term in terms:
display.vvvv("Term: %s" % term)
display.vvvv(f"Term: {term}")
cyberark_conn = CyberarkPassword(**term)
return_values.append(cyberark_conn.get())
return return_values