Fix lookup plugin for py3.5 support
in py3 basestring is no longer valid so we need to support basestring for as long as we support py2 but we also need to have a way to carry forward seemslessly. A try and except block has been added to allow us to support both. Py3 also will not allow us to "sort" a dict, while this was allowed in py2 it didn't do anything however in py3 it causes a stacktrace. To fix this issue a try/except block has been added to catch the type error and simply set the value without sorting it. Change-Id: I81c135c5bf0867f7faea248457494547cbcd87cd Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
parent
d7e23e1be8
commit
a769cf7b91
@ -32,6 +32,13 @@ else:
|
||||
BASECLASS = LookupBase
|
||||
LOOKUP_MODULE_CLASS = 'V2'
|
||||
|
||||
|
||||
try:
|
||||
basestring
|
||||
except NameError:
|
||||
basestring = str
|
||||
|
||||
|
||||
# Used to keep track of git package parts as various files are processed
|
||||
GIT_PACKAGE_DEFAULT_PARTS = dict()
|
||||
|
||||
@ -751,10 +758,13 @@ class LookupModule(BASECLASS):
|
||||
# Sort everything within the returned data
|
||||
for key, value in return_data.items():
|
||||
if isinstance(value, (list, set)):
|
||||
if all(isinstance(item, dict) for item in value):
|
||||
return_data[key] = sorted(value, key = lambda k: k['name'])
|
||||
else:
|
||||
return_data[key] = sorted(value)
|
||||
try:
|
||||
if all(isinstance(item, dict) for item in value):
|
||||
return_data[key] = sorted(value, key = lambda k: k['name'])
|
||||
else:
|
||||
return_data[key] = sorted(value)
|
||||
except TypeError:
|
||||
return_data[key] = value
|
||||
return_data['role_requirement_files'] = ROLE_REQUIREMENTS
|
||||
return_data['role_requirements'] = ROLE_BREAKOUT_REQUIREMENTS
|
||||
_dp = return_data['role_distro_packages'] = ROLE_DISTRO_BREAKOUT_PACKAGES
|
||||
|
Loading…
x
Reference in New Issue
Block a user