Skip to content

Commit

Permalink
use dict comprehension in plugins, part 4 (#8858)
Browse files Browse the repository at this point in the history
* use dict comprehension in plugins, part 4

* add changelog frag
  • Loading branch information
russoz authored Sep 13, 2024
1 parent 37dd6ec commit 94472dd
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 30 deletions.
11 changes: 11 additions & 0 deletions changelogs/fragments/8858-dict-comprehension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
minor_changes:
- scaleway_container - replace Python 2.6 construct with dict comprehensions (https://github.com/ansible-collections/community.general/pull/8858).
- scaleway_container_info - replace Python 2.6 construct with dict comprehensions (https://github.com/ansible-collections/community.general/pull/8858).
- scaleway_container_namespace - replace Python 2.6 construct with dict comprehensions (https://github.com/ansible-collections/community.general/pull/8858).
- scaleway_container_namespace_info - replace Python 2.6 construct with dict comprehensions (https://github.com/ansible-collections/community.general/pull/8858).
- scaleway_container_registry - replace Python 2.6 construct with dict comprehensions (https://github.com/ansible-collections/community.general/pull/8858).
- scaleway_container_registry_info - replace Python 2.6 construct with dict comprehensions (https://github.com/ansible-collections/community.general/pull/8858).
- scaleway_function - replace Python 2.6 construct with dict comprehensions (https://github.com/ansible-collections/community.general/pull/8858).
- scaleway_function_info - replace Python 2.6 construct with dict comprehensions (https://github.com/ansible-collections/community.general/pull/8858).
- scaleway_function_namespace - replace Python 2.6 construct with dict comprehensions (https://github.com/ansible-collections/community.general/pull/8858).
- scaleway_function_namespace_info - replace Python 2.6 construct with dict comprehensions (https://github.com/ansible-collections/community.general/pull/8858).
6 changes: 2 additions & 4 deletions plugins/modules/scaleway_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ def absent_strategy(api, wished_cn):
changed = False

cn_list = api.fetch_all_resources("containers")
cn_lookup = dict((cn["name"], cn)
for cn in cn_list)
cn_lookup = {cn["name"]: cn for cn in cn_list}

if wished_cn["name"] not in cn_lookup:
return changed, {}
Expand All @@ -285,8 +284,7 @@ def present_strategy(api, wished_cn):
changed = False

cn_list = api.fetch_all_resources("containers")
cn_lookup = dict((cn["name"], cn)
for cn in cn_list)
cn_lookup = {cn["name"]: cn for cn in cn_list}

payload_cn = payload_from_wished_cn(wished_cn)

Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/scaleway_container_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@

def info_strategy(api, wished_cn):
cn_list = api.fetch_all_resources("containers")
cn_lookup = dict((fn["name"], fn)
for fn in cn_list)
cn_lookup = {cn["name"]: cn for cn in cn_list}

if wished_cn["name"] not in cn_lookup:
msg = "Error during container lookup: Unable to find container named '%s' in namespace '%s'" % (wished_cn["name"],
Expand Down
6 changes: 2 additions & 4 deletions plugins/modules/scaleway_container_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ def absent_strategy(api, wished_cn):
changed = False

cn_list = api.fetch_all_resources("namespaces")
cn_lookup = dict((cn["name"], cn)
for cn in cn_list)
cn_lookup = {cn["name"]: cn for cn in cn_list}

if wished_cn["name"] not in cn_lookup:
return changed, {}
Expand All @@ -192,8 +191,7 @@ def present_strategy(api, wished_cn):
changed = False

cn_list = api.fetch_all_resources("namespaces")
cn_lookup = dict((cn["name"], cn)
for cn in cn_list)
cn_lookup = {cn["name"]: cn for cn in cn_list}

payload_cn = payload_from_wished_cn(wished_cn)

Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/scaleway_container_namespace_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@

def info_strategy(api, wished_cn):
cn_list = api.fetch_all_resources("namespaces")
cn_lookup = dict((fn["name"], fn)
for fn in cn_list)
cn_lookup = {cn["name"]: cn for cn in cn_list}

if wished_cn["name"] not in cn_lookup:
msg = "Error during container namespace lookup: Unable to find container namespace named '%s' in project '%s'" % (wished_cn["name"],
Expand Down
6 changes: 2 additions & 4 deletions plugins/modules/scaleway_container_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ def absent_strategy(api, wished_cr):
changed = False

cr_list = api.fetch_all_resources("namespaces")
cr_lookup = dict((cr["name"], cr)
for cr in cr_list)
cr_lookup = {cr["name"]: cr for cr in cr_list}

if wished_cr["name"] not in cr_lookup:
return changed, {}
Expand All @@ -175,8 +174,7 @@ def present_strategy(api, wished_cr):
changed = False

cr_list = api.fetch_all_resources("namespaces")
cr_lookup = dict((cr["name"], cr)
for cr in cr_list)
cr_lookup = {cr["name"]: cr for cr in cr_list}

payload_cr = payload_from_wished_cr(wished_cr)

Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/scaleway_container_registry_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@

def info_strategy(api, wished_cn):
cn_list = api.fetch_all_resources("namespaces")
cn_lookup = dict((fn["name"], fn)
for fn in cn_list)
cn_lookup = {cn["name"]: cn for cn in cn_list}

if wished_cn["name"] not in cn_lookup:
msg = "Error during container registries lookup: Unable to find container registry named '%s' in project '%s'" % (wished_cn["name"],
Expand Down
6 changes: 2 additions & 4 deletions plugins/modules/scaleway_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ def absent_strategy(api, wished_fn):
changed = False

fn_list = api.fetch_all_resources("functions")
fn_lookup = dict((fn["name"], fn)
for fn in fn_list)
fn_lookup = {fn["name"]: fn for fn in fn_list}

if wished_fn["name"] not in fn_lookup:
return changed, {}
Expand All @@ -270,8 +269,7 @@ def present_strategy(api, wished_fn):
changed = False

fn_list = api.fetch_all_resources("functions")
fn_lookup = dict((fn["name"], fn)
for fn in fn_list)
fn_lookup = {fn["name"]: fn for fn in fn_list}

payload_fn = payload_from_wished_fn(wished_fn)

Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/scaleway_function_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@

def info_strategy(api, wished_fn):
fn_list = api.fetch_all_resources("functions")
fn_lookup = dict((fn["name"], fn)
for fn in fn_list)
fn_lookup = {fn["name"]: fn for fn in fn_list}

if wished_fn["name"] not in fn_lookup:
msg = "Error during function lookup: Unable to find function named '%s' in namespace '%s'" % (wished_fn["name"],
Expand Down
6 changes: 2 additions & 4 deletions plugins/modules/scaleway_function_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ def absent_strategy(api, wished_fn):
changed = False

fn_list = api.fetch_all_resources("namespaces")
fn_lookup = dict((fn["name"], fn)
for fn in fn_list)
fn_lookup = {fn["name"]: fn for fn in fn_list}

if wished_fn["name"] not in fn_lookup:
return changed, {}
Expand All @@ -193,8 +192,7 @@ def present_strategy(api, wished_fn):
changed = False

fn_list = api.fetch_all_resources("namespaces")
fn_lookup = dict((fn["name"], fn)
for fn in fn_list)
fn_lookup = {fn["name"]: fn for fn in fn_list}

payload_fn = payload_from_wished_fn(wished_fn)

Expand Down
3 changes: 1 addition & 2 deletions plugins/modules/scaleway_function_namespace_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@

def info_strategy(api, wished_fn):
fn_list = api.fetch_all_resources("namespaces")
fn_lookup = dict((fn["name"], fn)
for fn in fn_list)
fn_lookup = {fn["name"]: fn for fn in fn_list}

if wished_fn["name"] not in fn_lookup:
msg = "Error during function namespace lookup: Unable to find function namespace named '%s' in project '%s'" % (wished_fn["name"],
Expand Down

0 comments on commit 94472dd

Please sign in to comment.