Exemple #1
0
def print_difference(k, base_tuple, target_tuple, other_difference):
    b_path, b_version, b_name, b_size, b_numglyphs, b_numchars, b_cmap, b_tableinfo = base_tuple
    t_path, t_version, t_name, t_size, t_numglyphs, t_numchars, t_cmap, t_tableinfo = target_tuple
    print('  ' + k)
    versions_differ = b_version != t_version
    diff_list = []
    if versions_differ:
        if float(b_version) > float(t_version):
            msg = '(base is newer!)'
        else:
            msg = ''
        print('    version: %s vs %s %s' % (b_version, t_version, msg))
    if b_name != t_name:
        diff_list.append('name')
        print("    name: '%s' vs '%s'" % (b_name, t_name))
    if b_size != t_size:
        diff_list.append('size')
        delta = int(t_size) - int(b_size)
        if delta < 0:
            msg = '%d byte%s smaller' % (-delta, '' if delta == -1 else 's')
        else:
            msg = '%d byte%s bigger' % (delta, '' if delta == 1 else 's')
        print('    size: %s vs %s (%s)' % (b_size, t_size, msg))
    table_diffs = compare_table_info(b_tableinfo, t_tableinfo)
    if table_diffs:
        diff_list.append('table')
        print('    tables: %s' % table_diffs)
    if b_numglyphs != t_numglyphs:
        diff_list.append('glyph count')
        delta = int(t_numglyphs) - int(b_numglyphs)
        if delta < 0:
            msg = '%d fewer glyph%s' % (-delta, '' if delta == -1 else 's')
        else:
            msg = '%d more glyph%s' % (delta, '' if delta == 1 else 's')
        print('    glyphs: %s vs %s (%s)' % (b_numglyphs, t_numglyphs, msg))
    if b_numchars != t_numchars:
        diff_list.append('char count')
        delta = int(t_numchars) - int(b_numchars)
        if delta < 0:
            msg = '%d fewer char%s' % (-delta, '' if delta == -1 else 's')
        else:
            msg = '%d more char%s' % (delta, '' if delta == 1 else 's')
        print('    chars: %s vs %s (%s)' % (b_numchars, t_numchars, msg))
    if b_cmap != t_cmap:
        removed_from_base = b_cmap - t_cmap
        if removed_from_base:
            print('    cmap removed: ' +
                  noto_lint.printable_unicode_range(removed_from_base))
        added_in_target = t_cmap - b_cmap
        if added_in_target:
            print('    cmap added: ' +
                  noto_lint.printable_unicode_range(added_in_target))
    if diff_list and not versions_differ:
        print('    %s differs but revision number is the same' %
              ', '.join(diff_list))
    if not diff_list and other_difference:
        print('    other difference')
def print_difference(k, base_tuple, target_tuple, other_difference):
  b_path, b_version, b_name, b_size, b_numglyphs, b_numchars, b_cmap, b_tableinfo = base_tuple
  t_path, t_version, t_name, t_size, t_numglyphs, t_numchars, t_cmap, t_tableinfo = target_tuple
  print '  ' + k
  versions_differ = b_version != t_version
  diff_list = []
  if versions_differ:
    if float(b_version) > float(t_version):
      msg = '(base is newer!)'
    else:
      msg = ''
    print '    version: %s vs %s %s' % (b_version, t_version, msg)
  if b_name != t_name:
    diff_list.append('name')
    print "    name: '%s' vs '%s'" % (b_name, t_name)
  if b_size != t_size:
    diff_list.append('size')
    delta = int(t_size) - int(b_size)
    if delta < 0:
      msg = '%d byte%s smaller' % (-delta, '' if delta == -1 else 's')
    else:
      msg = '%d byte%s bigger' % (delta, '' if delta == 1 else 's')
    print '    size: %s vs %s (%s)' % (b_size, t_size, msg)
  table_diffs = compare_table_info(b_tableinfo, t_tableinfo)
  if table_diffs:
    diff_list.append('table')
    print '    tables: %s' % table_diffs
  if b_numglyphs != t_numglyphs:
    diff_list.append('glyph count')
    delta = int(t_numglyphs) - int(b_numglyphs)
    if delta < 0:
      msg = '%d fewer glyph%s' % (-delta, '' if delta == -1 else 's')
    else:
      msg = '%d more glyph%s' % (delta, '' if delta == 1 else 's')
    print '    glyphs: %s vs %s (%s)' % (b_numglyphs, t_numglyphs, msg)
  if b_numchars != t_numchars:
    diff_list.append('char count')
    delta = int(t_numchars) - int(b_numchars)
    if delta < 0:
      msg = '%d fewer char%s' % (-delta, '' if delta == -1 else 's')
    else:
      msg = '%d more char%s' % (delta, '' if delta == 1 else 's')
    print '    chars: %s vs %s (%s)' % (b_numchars, t_numchars, msg)
  if b_cmap != t_cmap:
    removed_from_base = b_cmap - t_cmap
    if removed_from_base:
      print '    cmap removed: ' + noto_lint.printable_unicode_range(
        removed_from_base)
    added_in_target = t_cmap - b_cmap
    if added_in_target:
      print '    cmap added: ' + noto_lint.printable_unicode_range(
          added_in_target)
  if diff_list and not versions_differ:
    print '    %s differs but revision number is the same' % ', '.join(diff_list)
  if not diff_list and other_difference:
    print '    other difference'
Exemple #3
0
def print_difference(k, base_tuple, target_tuple, other_difference):
    b_path, b_version, b_name, b_size, b_numglyphs, b_numchars, b_cmap, b_tableinfo = base_tuple
    t_path, t_version, t_name, t_size, t_numglyphs, t_numchars, t_cmap, t_tableinfo = target_tuple
    print "  " + k
    versions_differ = b_version != t_version
    diff_list = []
    if versions_differ:
        if float(b_version) > float(t_version):
            msg = "(base is newer!)"
        else:
            msg = ""
        print "    version: %s vs %s %s" % (b_version, t_version, msg)
    if b_name != t_name:
        diff_list.append("name")
        print "    name: '%s' vs '%s'" % (b_name, t_name)
    if b_size != t_size:
        diff_list.append("size")
        delta = int(t_size) - int(b_size)
        if delta < 0:
            msg = "%d byte%s smaller" % (-delta, "" if delta == -1 else "s")
        else:
            msg = "%d byte%s bigger" % (delta, "" if delta == 1 else "s")
        print "    size: %s vs %s (%s)" % (b_size, t_size, msg)
    table_diffs = compare_table_info(b_tableinfo, t_tableinfo)
    if table_diffs:
        diff_list.append("table")
        print "    tables: %s" % table_diffs
    if b_numglyphs != t_numglyphs:
        diff_list.append("glyph count")
        delta = int(t_numglyphs) - int(b_numglyphs)
        if delta < 0:
            msg = "%d fewer glyph%s" % (-delta, "" if delta == -1 else "s")
        else:
            msg = "%d more glyph%s" % (delta, "" if delta == 1 else "s")
        print "    glyphs: %s vs %s (%s)" % (b_numglyphs, t_numglyphs, msg)
    if b_numchars != t_numchars:
        diff_list.append("char count")
        delta = int(t_numchars) - int(b_numchars)
        if delta < 0:
            msg = "%d fewer char%s" % (-delta, "" if delta == -1 else "s")
        else:
            msg = "%d more char%s" % (delta, "" if delta == 1 else "s")
        print "    chars: %s vs %s (%s)" % (b_numchars, t_numchars, msg)
    if b_cmap != t_cmap:
        removed_from_base = b_cmap - t_cmap
        if removed_from_base:
            print "    cmap removed: " + noto_lint.printable_unicode_range(removed_from_base)
        added_in_target = t_cmap - b_cmap
        if added_in_target:
            print "    cmap added: " + noto_lint.printable_unicode_range(added_in_target)
    if diff_list and not versions_differ:
        print "    %s differs but revision number is the same" % ", ".join(diff_list)
    if not diff_list and other_difference:
        print "    other difference"
Exemple #4
0
 def to_str(idx, val):
     if idx == 7 and type(val) == type({}):
         parts = []
         for tag in sorted(val):
             parts.append('%s=%s' % (tag, val[tag][0]))
         result = ', '.join(parts)
     else:
         if idx == 6 and type(val) == type(set()):
             result = noto_lint.printable_unicode_range(val)
         else:
             result = str(val)
     if ' ' in result:
         result = '"%s"' % result
     return result
Exemple #5
0
def print_difference(k, base_tuple, target_tuple, other_difference):
    (
        b_path,
        b_version,
        b_name,
        b_size,
        b_numglyphs,
        b_numchars,
        b_cmap,
        b_tableinfo,
    ) = base_tuple
    (
        t_path,
        t_version,
        t_name,
        t_size,
        t_numglyphs,
        t_numchars,
        t_cmap,
        t_tableinfo,
    ) = target_tuple
    print("  " + k)
    versions_differ = b_version != t_version
    diff_list = []
    if versions_differ:
        if float(b_version) > float(t_version):
            msg = "(base is newer!)"
        else:
            msg = ""
        print("    version: %s vs %s %s" % (b_version, t_version, msg))
    if b_name != t_name:
        diff_list.append("name")
        print("    name: '%s' vs '%s'" % (b_name, t_name))
    if b_size != t_size:
        diff_list.append("size")
        delta = int(t_size) - int(b_size)
        if delta < 0:
            msg = "%d byte%s smaller" % (-delta, "" if delta == -1 else "s")
        else:
            msg = "%d byte%s bigger" % (delta, "" if delta == 1 else "s")
        print("    size: %s vs %s (%s)" % (b_size, t_size, msg))
    table_diffs = compare_table_info(b_tableinfo, t_tableinfo)
    if table_diffs:
        diff_list.append("table")
        print("    tables: %s" % table_diffs)
    if b_numglyphs != t_numglyphs:
        diff_list.append("glyph count")
        delta = int(t_numglyphs) - int(b_numglyphs)
        if delta < 0:
            msg = "%d fewer glyph%s" % (-delta, "" if delta == -1 else "s")
        else:
            msg = "%d more glyph%s" % (delta, "" if delta == 1 else "s")
        print("    glyphs: %s vs %s (%s)" % (b_numglyphs, t_numglyphs, msg))
    if b_numchars != t_numchars:
        diff_list.append("char count")
        delta = int(t_numchars) - int(b_numchars)
        if delta < 0:
            msg = "%d fewer char%s" % (-delta, "" if delta == -1 else "s")
        else:
            msg = "%d more char%s" % (delta, "" if delta == 1 else "s")
        print("    chars: %s vs %s (%s)" % (b_numchars, t_numchars, msg))
    if b_cmap != t_cmap:
        removed_from_base = b_cmap - t_cmap
        if removed_from_base:
            print("    cmap removed: " +
                  noto_lint.printable_unicode_range(removed_from_base))
        added_in_target = t_cmap - b_cmap
        if added_in_target:
            print("    cmap added: " +
                  noto_lint.printable_unicode_range(added_in_target))
    if diff_list and not versions_differ:
        print("    %s differs but revision number is the same" %
              ", ".join(diff_list))
    if not diff_list and other_difference:
        print("    other difference")