1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-03-22 05:09:12 +00:00

modules h*: use f-strings (#10959)

* modules h*: use f-strings

* add changelog frag
This commit is contained in:
Alexei Znamensky 2025-10-25 11:59:12 +13:00 committed by GitHub
parent b67e7c83cf
commit f9b4abf930
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 242 additions and 402 deletions

View file

@ -202,8 +202,7 @@ def main():
else:
v = search_resource(config)
if len(v) > 1:
raise Exception("Found more than one resource(%s)" % ", ".join([
navigate_value(i, ["id"]) for i in v]))
raise Exception(f"Found more than one resource({', '.join([navigate_value(i, ['id']) for i in v])})")
if len(v) == 1:
resource = v[0]
@ -221,8 +220,7 @@ def main():
expect = user_input_parameters(module)
if are_different_dicts(expect, current):
raise Exception(
"Cannot change option from (%s) to (%s) for an"
" existing security group(%s)." % (current, expect, module.params.get('id')))
f"Cannot change option from ({current}) to ({expect}) for an existing security group({module.params.get('id')}).")
result = read_resource(config)
result['id'] = module.params.get('id')
else:
@ -286,7 +284,7 @@ def _build_query_link(opts):
query_link = "?marker={marker}&limit=10"
v = navigate_value(opts, ["security_group_id"])
if v:
query_link += "&security_group_id=" + str(v)
query_link += f"&security_group_id={v}"
return query_link
@ -297,7 +295,7 @@ def search_resource(config):
opts = user_input_parameters(module)
identity_obj = _build_identity_object(opts)
query_link = _build_query_link(opts)
link = "security-group-rules" + query_link
link = f"security-group-rules{query_link}"
result = []
p = {'marker': ''}
@ -372,8 +370,7 @@ def send_create_request(module, params, client):
try:
r = client.post(url, params)
except HwcClientException as ex:
msg = ("module(hwc_vpc_security_group_rule): error running "
"api(create), error: %s" % str(ex))
msg = f"module(hwc_vpc_security_group_rule): error running api(create), error: {ex}"
module.fail_json(msg=msg)
return r
@ -385,8 +382,7 @@ def send_delete_request(module, params, client):
try:
r = client.delete(url, params)
except HwcClientException as ex:
msg = ("module(hwc_vpc_security_group_rule): error running "
"api(delete), error: %s" % str(ex))
msg = f"module(hwc_vpc_security_group_rule): error running api(delete), error: {ex}"
module.fail_json(msg=msg)
return r
@ -399,8 +395,7 @@ def send_read_request(module, client):
try:
r = client.get(url)
except HwcClientException as ex:
msg = ("module(hwc_vpc_security_group_rule): error running "
"api(read), error: %s" % str(ex))
msg = f"module(hwc_vpc_security_group_rule): error running api(read), error: {ex}"
module.fail_json(msg=msg)
return navigate_value(r, ["security_group_rule"], None)
@ -473,8 +468,7 @@ def send_list_request(module, client, url):
try:
r = client.get(url)
except HwcClientException as ex:
msg = ("module(hwc_vpc_security_group_rule): error running "
"api(list), error: %s" % str(ex))
msg = f"module(hwc_vpc_security_group_rule): error running api(list), error: {ex}"
module.fail_json(msg=msg)
return navigate_value(r, ["security_group_rules"], None)