mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 06:10:22 -07:00
Performance improvement using in-operator on dicts
Just a small cleanup for the existing occurrences. Using the in-operator for hash lookups is faster than using .keys() http://stackoverflow.com/questions/29314269/why-do-key-in-dict-and-key-in-dict-keys-have-the-same-output
This commit is contained in:
parent
b79bf14607
commit
1ca4add91c
7 changed files with 15 additions and 15 deletions
|
@ -92,13 +92,13 @@ class CallbackModule(CallbackBase):
|
|||
subject = 'Failed: %s' % attach
|
||||
body = 'The following task failed for host ' + host + ':\n\n%s\n\n' % attach
|
||||
|
||||
if 'stdout' in res._result.keys() and res._result['stdout']:
|
||||
if 'stdout' in res._result and res._result['stdout']:
|
||||
subject = res._result['stdout'].strip('\r\n').split('\n')[-1]
|
||||
body += 'with the following output in standard output:\n\n' + res._result['stdout'] + '\n\n'
|
||||
if 'stderr' in res._result.keys() and res._result['stderr']:
|
||||
if 'stderr' in res._result and res._result['stderr']:
|
||||
subject = res._result['stderr'].strip('\r\n').split('\n')[-1]
|
||||
body += 'with the following output in standard error:\n\n' + res._result['stderr'] + '\n\n'
|
||||
if 'msg' in res._result.keys() and res._result['msg']:
|
||||
if 'msg' in res._result and res._result['msg']:
|
||||
subject = res._result['msg'].strip('\r\n').split('\n')[0]
|
||||
body += 'with the following message:\n\n' + res._result['msg'] + '\n\n'
|
||||
body += 'A complete dump of the error:\n\n' + self._dump_results(res._result)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue