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

Replace % string formatting with f-strings across multiple plugins (#11908)

* Replace % string formatting with f-strings across multiple plugins

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

* Add changelog fragment for PR 11908

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alexei Znamensky 2026-04-22 07:06:27 +12:00 committed by GitHub
parent 253ac45dd3
commit 53397c081a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 65 additions and 64 deletions

View file

@ -184,8 +184,6 @@ def main():
notify = module.params["notify"]
URI = f"https://{subscription}.campfirenow.com"
NSTR = "<message><type>SoundMessage</type><body>%s</body></message>"
MSTR = "<message><body>%s</body></message>"
AGENT = "Ansible/1.2"
# Hack to add basic auth username and password the way fetch_url expects
@ -197,14 +195,21 @@ def main():
# Send some audible notification if requested
if notify:
response, info = fetch_url(module, target_url, data=NSTR % html_escape(notify), headers=headers)
response, info = fetch_url(
module,
target_url,
data=f"<message><type>SoundMessage</type><body>{html_escape(notify)}</body></message>",
headers=headers,
)
if info["status"] not in [200, 201]:
module.fail_json(
msg=f"unable to send msg: '{notify}', campfire api returned error code: '{info['status']}'"
)
# Send the message
response, info = fetch_url(module, target_url, data=MSTR % html_escape(msg), headers=headers)
response, info = fetch_url(
module, target_url, data=f"<message><body>{html_escape(msg)}</body></message>", headers=headers
)
if info["status"] not in [200, 201]:
module.fail_json(msg=f"unable to send msg: '{msg}', campfire api returned error code: '{info['status']}'")