def _compare_action_configs()

in tools/migration/ctoolchain_comparator_lib.py [0:0]


def _compare_action_configs(action_configs_before, action_configs_after):
  """Compares two "CToolchain.ActionConfig" lists."""
  action_name_to_action_before = {}
  action_name_to_action_after = {}
  for action_config in action_configs_before:
    action_name_to_action_before[action_config.config_name] = action_config
  for action_config in action_configs_after:
    action_name_to_action_after[action_config.config_name] = action_config

  config_names_before = set(action_name_to_action_before.keys())
  config_names_after = set(action_name_to_action_after.keys())

  before_after_diff = config_names_before - config_names_after
  after_before_diff = config_names_after - config_names_before

  diff_string = "Difference in 'action_config' 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 "
           "action_configs 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 "
           "action_configs that the list before the change doesn't:\n%s") %
          _array_to_string(after_before_diff, ordered=True))

  names_before = [config.config_name for config in action_configs_before]
  names_after = [config.config_name for config in action_configs_after]
  if names_before != names_after:
    if not found_difference:
      print(diff_string)  # pylint: disable=superfluous-parens
      found_difference = True
    print(("Action configs not in right order:\n"
           "* List of action configs before change:\t%s"
           "* List of action_configs before change:\t%s") %
          (_array_to_string(names_before), _array_to_string(names_after)))
  for name in config_names_before:
    action_config_before = action_name_to_action_before[name]
    action_config_after = action_name_to_action_after.get(name, None)
    if action_config_after and not _check_action_config_equivalence(
        action_config_before, action_config_after):
      if not found_difference:
        print(diff_string)  # pylint: disable=superfluous-parens
        found_difference = True
      print(("* Action config '%s' differs before and after the change:\n"
             "Value before change:\n%s\n"
             "Value after change:\n%s") % (name, str(action_config_before),
                                           str(action_config_after)))
  if found_difference:
    print("")  # pylint: disable=superfluous-parens
  return found_difference