python3: Refactor dict for python2/python3 compat

Python3 changed the behavior of dict.keys such that it is now
returns a dict_keys object, which is iterable but not indexable.
You can get the python2 result back with an explicit call to list.

Change-Id: Ic504d3929398aa82ac87d1735cf4cedea2dfc5d1
Signed-off-by: Chuck Short <chuck.short@canonical.com>
Merge "python3: Refactor dict for python2/python3 compat"