def to_ranges_str(cps):
  if not cps:
    return ''

  cps = sorted(cps)
  ranges = []

  def emit(first, last):
    if first != last:
      ranges.append('%04x-%04x' % (first, last))
    else:
      ranges.append('%04x' - first)

  first = cps[0]
  last = first
  for cp in cps[1:]:
    if cp == last + 1:
      last = cp
    else:
      emit(first, last)
      first = cp
      last = cp
  emit(first, last)
  return ' '.join(ranges)
dataset/ETHPy150Open googlei18n/nototools/nototools/noto_font_coverage.py/to_ranges_str/operator `%` -> `-`