py34: fix convert_dicts_to_lists

keys() is an iterator in python3 and doesn't support indexing
values() is an iterator too and cannot be sorted

Change-Id: I02fcf72efbf1a30135873572ee4b78dff85b7b87
This commit is contained in:
Andrey Pavlov 2015-09-09 17:46:05 +03:00
parent 5ba78c4ec9
commit 23a94de725
1 changed files with 7 additions and 5 deletions

View File

@ -19,6 +19,7 @@ APIRequest class
from lxml import etree
from oslo_config import cfg
from oslo_log import log as logging
import six
from ec2api.api import cloud
from ec2api.api import ec2utils
@ -69,11 +70,12 @@ class APIRequest(object):
if isinstance(args[key], dict):
if args[key] == {}:
continue
if args[key].keys()[0].isdigit():
s = args[key].items()
s.sort()
args[key] = [convert_dicts_to_lists(v) for k, v in s]
elif (args[key].keys()[0] == 'value' and
first_subkey = next(six.iterkeys(args[key]))
if first_subkey.isdigit():
s = args[key]
args[key] = [convert_dicts_to_lists(s[k])
for k in sorted(s)]
elif (first_subkey == 'value' and
len(args[key]) == 1):
args[key] = args[key]['value']
return args