def _mkstemp_copy(path, preserve_inode=True):
 temp_file = None
 try:
  temp_file = salt.utils.files.mkstemp(prefix=salt.utils.files.TEMPFILE_PREFIX)
 except (OSError, IOError) as exc:
  raise CommandExecutionError('Unable to create temp file. Exception: {0}'.format(exc))
 if preserve_inode:
  try:
   shutil.copy2(path, temp_file)
  except (OSError, IOError) as exc:
   raise CommandExecutionError("Unable to copy file '{0}' to the temp file '{1}'. Exception: {2}".format(path, temp_file, exc))
 else:
  try:
   shutil.move(path, temp_file)
  except (OSError, IOError) as exc:
   raise CommandExecutionError("Unable to move file '{0}' to the temp file '{1}'. Exception: {2}".format(path, temp_file, exc))
 return temp_file

def _mkstemp_copy ( path , preserve_inode = True ) : temp_file = None try : temp_file = salt . utils . files . mkstemp ( prefix = salt . utils . files . TEMPFILE_PREFIX ) except ( OSError , IOError ) as exc : raise CommandExecutionError ( 'Unable to create temp file. Exception: {0}' . format ( exc ) ) if preserve_inode : try : shutil . copy2 ( path , temp_file ) except ( OSError , IOError ) as exc : raise CommandExecutionError ( "Unable to copy file '{0}' to the temp file '{1}'. Exception: {2}" . format ( path , temp_file , exc ) ) else : try : shutil . move ( path , temp_file ) except ( OSError , IOError ) as exc : raise CommandExecutionError ( "Unable to move file '{0}' to the temp file '{1}'. Exception: {2}" . format ( path , temp_file , exc ) ) return temp_file
create a temp file and move/copy the contents of path to the temp file .