def DiffPrint(filename):
  """Return file content in unified diff format as though it's been added"""
  # The file is "new" in the patch sense. Generate a homebrew diff.
  # We can't use ReadFile() since it's not using binary mode.
  file_handle = open(filename, 'rb')
  file_content = file_handle.read()
  file_handle.close()
  # Prepend '+ ' to every lines.
  file_content = ['+ ' + i for i in file_content.splitlines(True)]
  nb_lines = len(file_content)
  # We need to use / since patch on unix will fail otherwise.
  filename = filename.replace('\\', '/')
  data = "Index: %s\n" % filename
  data += ("============================================================="
           "======\n")
  # Note: Should we use /dev/null instead?
  data += "--- %s\n" % filename
  data += "+++ %s\n" % filename
  data += "@@ -0,0 +1,%d @@\n" % nb_lines
  data += ''.join(file_content)
  return data
dataset/ETHPy150Open CollabQ/CollabQ/bin/gcl.py/DiffPrint/original