in tools/migration/ctoolchain_comparator_lib.py [0:0]
def _compare_tool_paths(tool_paths_before, tool_paths_after):
"""Compares two "CToolchain.ToolPath" lists."""
tool_to_path_before = {}
tool_to_path_after = {}
for tool_path in tool_paths_before:
tool_to_path_before[tool_path.name] = (
tool_path.path if tool_path.path != "NOT_USED" else "")
for tool_path in tool_paths_after:
tool_to_path_after[tool_path.name] = (
tool_path.path if tool_path.path != "NOT_USED" else "")
tool_names_before = set(tool_to_path_before.keys())
tool_names_after = set(tool_to_path_after.keys())
before_after_diff = tool_names_before - tool_names_after
after_before_diff = tool_names_after - tool_names_before
diff_string = "Difference in 'tool_path' field:"
found_difference = False
if before_after_diff:
if not found_difference:
print(diff_string) # pylint: disable=superfluous-parens
found_difference = True
print(("* List before change contains entries for the following tools "
"that the list after the change doesn't:\n%s") % _array_to_string(
before_after_diff, ordered=True))
if after_before_diff:
if not found_difference:
print(diff_string) # pylint: disable=superfluous-parens
found_difference = True
print(("* List after change contains entries for the following tools that "
"the list before the change doesn't:\n%s") % _array_to_string(
after_before_diff, ordered=True))
for tool in tool_to_path_before:
path_before = tool_to_path_before[tool]
path_after = tool_to_path_after.get(tool, None)
if path_after and path_after != path_before:
if not found_difference:
print(diff_string) # pylint: disable=superfluous-parens
found_difference = True
print(("* Path for tool '%s' differs before and after the change:\n"
"Value before change:\t'%s'\n"
"Value after change:\t'%s'") % (tool, path_before, path_after))
if found_difference:
print("") # pylint: disable=superfluous-parens
return found_difference