Use dict comprehension

As python 2.6 is not supported any more, we should use 
dict comprehension for concise code.

Change-Id: Ic06fa7acd9f60674ea4627581cdc878319e23412
This commit is contained in:
wangxiyuan 2015-10-16 17:12:56 +08:00
parent 5a320637ec
commit fc2acd92d8
1 changed files with 2 additions and 6 deletions

View File

@ -760,12 +760,8 @@ def _image_update(context, values, image_id, purge_props=False,
# Validate fields for Images table. This is similar to what is done
# for the query result update except that we need to do it prior
# in this case.
# TODO(dosaboy): replace this with a dict comprehension once py26
# support is deprecated.
keys = values.keys()
for k in keys:
if k not in image_ref.to_dict():
del values[k]
values = {key: values[key] for key in values
if key in image_ref.to_dict()}
updated = query.update(values, synchronize_session='fetch')
if not updated: