Resolve unorderable types errors

Python 3 raises errors when attempting to compare types that don't have
a meaningful natural ordering.

If a processed file does not belong to a role it's not neccessary to
create a mapping of a project_group for a `None` role, to prevent
'None' from being compared to other string role names within the
'role_project_groups' dict.

For variables containing lists of dictionaries, like
'remote_package_parts', sort using the 'name' property of each
dictionary.

Change-Id: I9ec4b0b3b7236450f19c1d6186eb310fb7f1e083
Implements: blueprint goal-python35
This commit is contained in:
Jimmy McCrory 2017-06-27 13:23:59 -07:00
parent 60363db63b
commit 8685a0ba38

View File

@ -552,7 +552,8 @@ class DependencyFileProcessor(object):
else:
project_group = 'all'
PACKAGE_MAPPING['role_project_groups'][role_name] = project_group
if role_name is not None:
PACKAGE_MAPPING['role_project_groups'][role_name] = project_group
for key, values in loaded_config.items():
key = key.lower()
if key.endswith('git_repo'):
@ -750,7 +751,10 @@ class LookupModule(BASECLASS):
# Sort everything within the returned data
for key, value in return_data.items():
if isinstance(value, (list, set)):
return_data[key] = sorted(value)
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)
return_data['role_requirement_files'] = ROLE_REQUIREMENTS
return_data['role_requirements'] = ROLE_BREAKOUT_REQUIREMENTS
_dp = return_data['role_distro_packages'] = ROLE_DISTRO_BREAKOUT_PACKAGES