heat: replace dict key checking with .get() 09/29409/1
authorRoss Brattain <ross.b.brattain@intel.com>
Mon, 27 Feb 2017 02:57:46 +0000 (18:57 -0800)
committerRoss Brattain <ross.b.brattain@intel.com>
Mon, 27 Feb 2017 03:34:48 +0000 (19:34 -0800)
commit46125c3ef9fcbbfba72c09ca1f4a5eb7bca655ef
tree28b35ab59d2205adaa7dfb4bde4a885ce022e8de
parent177feabf43564afd28c7b4112ad4e384a3654bd8
heat: replace dict key checking with .get()

We init all the fields to None, so the default value
is None, which is what .get() returns when the key
is not present it the dictionary.

Replace

  if key in dict:
    self.val = dict[key]

with

  self.val = dict.get(key)

This also has the added beneifit of re-initializing
default values to None.

In idiomatic Python we do not check a dictionary twice
if we can avoid it.  Either use dict.get() with a default
value or catch the KeyError and do the correct thing.

Change-Id: If8d1caeb7288f888f02622d62e8db9f59f50717a
Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
yardstick/benchmark/contexts/heat.py