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:
Dag Wieers 2016-11-17 15:08:12 +01:00 committed by Brian Coca
commit 1ca4add91c
7 changed files with 15 additions and 15 deletions

View file

@ -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)