def get_correct_indentation_diff(code, filename):
 code_buffer = StringIO(code)
 output_buffer = StringIO()
 reindenter = reindent.Reindenter(code_buffer)
 reindenter.run()
 reindenter.write(output_buffer)
 reindent_output = output_buffer.getvalue()
 output_buffer.close()
 if (code != reindent_output):
  diff_generator = difflib.unified_diff(code.splitlines(True), reindent_output.splitlines(True), fromfile=filename, tofile=(filename + ' (reindented)'))
  diff_tuple = map(clean_diff_line_for_python_bug_2142, diff_generator)
  diff = ''.join(diff_tuple)
  return diff
 else:
  return None

def get_correct_indentation_diff ( code , filename ) : code_buffer = StringIO ( code ) output_buffer = StringIO ( ) reindenter = reindent . Reindenter ( code_buffer ) reindenter . run ( ) reindenter . write ( output_buffer ) reindent_output = output_buffer . getvalue ( ) output_buffer . close ( ) if ( code != reindent_output ) : diff_generator = difflib . unified_diff ( code . splitlines ( True ) , reindent_output . splitlines ( True ) , fromfile = filename , tofile = ( filename + ' (reindented)' ) ) diff_tuple = map ( clean_diff_line_for_python_bug_2142 , diff_generator ) diff = '' . join ( diff_tuple ) return diff else : return None
generate a diff to make code correctly indented .