def _reindent_stats(tokens):
 find_stmt = 1
 level = 0
 stats = []
 for t in tokens:
  token_type = t[0]
  sline = t[2][0]
  line = t[4]
  if (token_type == tokenize.NEWLINE):
   find_stmt = 1
  elif (token_type == tokenize.INDENT):
   find_stmt = 1
   level += 1
  elif (token_type == tokenize.DEDENT):
   find_stmt = 1
   level -= 1
  elif (token_type == tokenize.COMMENT):
   if find_stmt:
    stats.append((sline, (-1)))
  elif (token_type == tokenize.NL):
   pass
  elif find_stmt:
   find_stmt = 0
   if line:
    stats.append((sline, level))
 return stats

def _reindent_stats ( tokens ) : find_stmt = 1 level = 0 stats = [ ] for t in tokens : token_type = t [ 0 ] sline = t [ 2 ] [ 0 ] line = t [ 4 ] if ( token_type == tokenize . NEWLINE ) : find_stmt = 1 elif ( token_type == tokenize . INDENT ) : find_stmt = 1 level += 1 elif ( token_type == tokenize . DEDENT ) : find_stmt = 1 level -= 1 elif ( token_type == tokenize . COMMENT ) : if find_stmt : stats . append ( ( sline , ( - 1 ) ) ) elif ( token_type == tokenize . NL ) : pass elif find_stmt : find_stmt = 0 if line : stats . append ( ( sline , level ) ) return stats
return list of pairs .