mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
use dict comprehension in plugins, part 3 (#8833)
* use dict comprehension in plugins, part 3 * add changelog frag
This commit is contained in:
parent
43f8adf1a5
commit
26df6c7657
25 changed files with 81 additions and 61 deletions
|
@ -56,7 +56,7 @@ class OcapiUtils(object):
|
|||
follow_redirects='all',
|
||||
use_proxy=True, timeout=self.timeout)
|
||||
data = json.loads(to_native(resp.read()))
|
||||
headers = dict((k.lower(), v) for (k, v) in resp.info().items())
|
||||
headers = {k.lower(): v for (k, v) in resp.info().items()}
|
||||
except HTTPError as e:
|
||||
return {'ret': False,
|
||||
'msg': "HTTP Error %s on GET request to '%s'"
|
||||
|
@ -86,7 +86,7 @@ class OcapiUtils(object):
|
|||
data = json.loads(to_native(resp.read()))
|
||||
else:
|
||||
data = ""
|
||||
headers = dict((k.lower(), v) for (k, v) in resp.info().items())
|
||||
headers = {k.lower(): v for (k, v) in resp.info().items()}
|
||||
except HTTPError as e:
|
||||
return {'ret': False,
|
||||
'msg': "HTTP Error %s on DELETE request to '%s'"
|
||||
|
@ -113,7 +113,7 @@ class OcapiUtils(object):
|
|||
force_basic_auth=basic_auth, validate_certs=False,
|
||||
follow_redirects='all',
|
||||
use_proxy=True, timeout=self.timeout)
|
||||
headers = dict((k.lower(), v) for (k, v) in resp.info().items())
|
||||
headers = {k.lower(): v for (k, v) in resp.info().items()}
|
||||
except HTTPError as e:
|
||||
return {'ret': False,
|
||||
'msg': "HTTP Error %s on PUT request to '%s'"
|
||||
|
@ -144,7 +144,7 @@ class OcapiUtils(object):
|
|||
force_basic_auth=basic_auth, validate_certs=False,
|
||||
follow_redirects='all',
|
||||
use_proxy=True, timeout=self.timeout if timeout is None else timeout)
|
||||
headers = dict((k.lower(), v) for (k, v) in resp.info().items())
|
||||
headers = {k.lower(): v for (k, v) in resp.info().items()}
|
||||
except HTTPError as e:
|
||||
return {'ret': False,
|
||||
'msg': "HTTP Error %s on POST request to '%s'"
|
||||
|
|
|
@ -151,7 +151,7 @@ class RedfishUtils(object):
|
|||
force_basic_auth=basic_auth, validate_certs=False,
|
||||
follow_redirects='all',
|
||||
use_proxy=True, timeout=timeout, ciphers=self.ciphers)
|
||||
headers = dict((k.lower(), v) for (k, v) in resp.info().items())
|
||||
headers = {k.lower(): v for (k, v) in resp.info().items()}
|
||||
try:
|
||||
if headers.get('content-encoding') == 'gzip' and LooseVersion(ansible_version) < LooseVersion('2.14'):
|
||||
# Older versions of Ansible do not automatically decompress the data
|
||||
|
@ -206,7 +206,7 @@ class RedfishUtils(object):
|
|||
except Exception as e:
|
||||
# No response data; this is okay in many cases
|
||||
data = None
|
||||
headers = dict((k.lower(), v) for (k, v) in resp.info().items())
|
||||
headers = {k.lower(): v for (k, v) in resp.info().items()}
|
||||
except HTTPError as e:
|
||||
msg = self._get_extended_message(e)
|
||||
return {'ret': False,
|
||||
|
@ -610,8 +610,7 @@ class RedfishUtils(object):
|
|||
data = response['data']
|
||||
if 'Parameters' in data:
|
||||
params = data['Parameters']
|
||||
ai = dict((p['Name'], p)
|
||||
for p in params if 'Name' in p)
|
||||
ai = {p['Name']: p for p in params if 'Name' in p}
|
||||
if not ai:
|
||||
ai = {
|
||||
k[:-24]: {'AllowableValues': v}
|
||||
|
|
|
@ -140,7 +140,7 @@ def resource_attributes_should_be_changed(target, wished, verifiable_mutable_att
|
|||
diff[attr] = wished[attr]
|
||||
|
||||
if diff:
|
||||
return dict((attr, wished[attr]) for attr in mutable_attributes)
|
||||
return {attr: wished[attr] for attr in mutable_attributes}
|
||||
else:
|
||||
return diff
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue