def compare_table_info(base_info, target_info):
  biggest_deltas = []
  others = [] # checksum changes
  added = []
  removed = []

  for k in target_info:
    b_tup = base_info.get(k)
    t_tup = target_info.get(k)
    if not b_tup:
      added.append((k, t_tup[0]))
    else:
      b_len = b_tup[0]
      t_len = t_tup[0]
      delta = t_len - b_len
      if delta == 0:
        if b_tup[1] != t_tup[1]:
          others.append(k)
        continue
      biggest_deltas.append((k, delta))

  for k in base_info:
    if not target_info.get(k):
      removed.append(k)

  biggest_deltas.sort(lambda lhs,rhs: -cmp(abs(lhs[1]), abs(rhs[1])) or
                      cmp(lhs[0], rhs[0]))
  del biggest_deltas[5:]

  result = []
  if biggest_deltas:
    def print_delta(t):
      if t[1] == 0:
        return t[0]
      return '%s(%+d)' % t
    biggest_delta_strings = [print_delta(t) for t in biggest_deltas]
    # if a table changed size, the head table will change the checksum, don't
    # report this.
    others = [k for k in others if k != 'head']
    if len(others) > 0 and len(biggest_deltas) < 5:
      other_count = len(others)
      biggest_delta_strings.append('%s other%s' %
                                   (other_count, 's' if other_count != 1 else ''))
    result.append('changed ' + ', '.join(biggest_delta_strings))
  if added:
    result.append('added ' + ', '.join('%s(%s)' % t for t in sorted(added)))
  if removed:
    result.append('removed ' + ', '.join(sorted(removed)))
  return '; '.join(result)
dataset/ETHPy150Open googlei18n/nototools/nototools/compare_summary.py/compare_table_info/original