mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 04:11:25 -07:00
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:
parent
2005125af4
commit
6cd3f79e19
31 changed files with 165 additions and 149 deletions
|
@ -306,14 +306,14 @@ class TSSClient(object):
|
|||
return TSSClientV0(**server_parameters)
|
||||
|
||||
def get_secret(self, term, secret_path, fetch_file_attachments, file_download_path):
|
||||
display.debug("tss_lookup term: %s" % term)
|
||||
display.debug(f"tss_lookup term: {term}")
|
||||
secret_id = self._term_to_secret_id(term)
|
||||
if secret_id == 0 and secret_path:
|
||||
fetch_secret_by_path = True
|
||||
display.vvv(u"Secret Server lookup of Secret with path %s" % secret_path)
|
||||
display.vvv(f"Secret Server lookup of Secret with path {secret_path}")
|
||||
else:
|
||||
fetch_secret_by_path = False
|
||||
display.vvv(u"Secret Server lookup of Secret with ID %d" % secret_id)
|
||||
display.vvv(f"Secret Server lookup of Secret with ID {secret_id}")
|
||||
|
||||
if fetch_file_attachments:
|
||||
if fetch_secret_by_path:
|
||||
|
@ -325,12 +325,12 @@ class TSSClient(object):
|
|||
if i['isFile']:
|
||||
try:
|
||||
file_content = i['itemValue'].content
|
||||
with open(os.path.join(file_download_path, str(obj['id']) + "_" + i['slug']), "wb") as f:
|
||||
with open(os.path.join(file_download_path, f"{str(obj['id'])}_{i['slug']}"), "wb") as f:
|
||||
f.write(file_content)
|
||||
except ValueError:
|
||||
raise AnsibleOptionsError("Failed to download {0}".format(str(i['slug'])))
|
||||
raise AnsibleOptionsError(f"Failed to download {str(i['slug'])}")
|
||||
except AttributeError:
|
||||
display.warning("Could not read file content for {0}".format(str(i['slug'])))
|
||||
display.warning(f"Could not read file content for {str(i['slug'])}")
|
||||
finally:
|
||||
i['itemValue'] = "*** Not Valid For Display ***"
|
||||
else:
|
||||
|
@ -343,9 +343,9 @@ class TSSClient(object):
|
|||
return self._client.get_secret_json(secret_id)
|
||||
|
||||
def get_secret_ids_by_folderid(self, term):
|
||||
display.debug("tss_lookup term: %s" % term)
|
||||
display.debug(f"tss_lookup term: {term}")
|
||||
folder_id = self._term_to_folder_id(term)
|
||||
display.vvv(u"Secret Server lookup of Secret id's with Folder ID %d" % folder_id)
|
||||
display.vvv(f"Secret Server lookup of Secret id's with Folder ID {folder_id}")
|
||||
|
||||
return self._client.get_secret_ids_by_folderid(folder_id)
|
||||
|
||||
|
@ -447,4 +447,4 @@ class LookupModule(LookupBase):
|
|||
for term in terms
|
||||
]
|
||||
except SecretServerError as error:
|
||||
raise AnsibleError("Secret Server lookup failure: %s" % error.message)
|
||||
raise AnsibleError(f"Secret Server lookup failure: {error.message}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue