Copies the contents of the file-like object to a temporary file.

    Args:
      file_object (dfvfs.FileIO): file-like object.
      temporary_file (file): temporary file.
508133
def _CopyFileObjectToTemporaryFile(self, file_object, temporary_file):
    
    file_object.seek(0, os.SEEK_SET)
    data = file_object.read(self._READ_BUFFER_SIZE)
    while data:
      temporary_file.write(data)
      data = file_object.read(self._READ_BUFFER_SIZE)
1277840
def savetofile(self, filelike, sortkey = True):
        
        filelike.writelines(k + '=' + repr(v) + '\n' for k,v in self.config_items(sortkey))
1261924
def tempfile(self, mode='wb', **args):
        ""
        tf = tempfile.NamedTemporaryFile(mode=mode)
        self.write(tf.name, mode=mode, **args)
        return tfn
840215
def put_buffer(filename, content, conn=None):
    
    obj_dict = {PRIMARY_FIELD: filename,
                CONTENT_FIELD: content,
                TIMESTAMP_FIELD: time()}
    return put(obj_dict, conn=conn)
330786
def copy(self, value):
        ''

        with tempfile.NamedTemporaryFile() as temp:
            with open(temp.name, 'w', encoding=options.encoding) as fp:
                fp.write(str(value))

            p = subprocess.Popen(
                self.command,
                stdin=open(temp.name, 'r', encoding=options.encoding),
                stdout=subprocess.DEVNULL)
            p.communicate()
1307710
public static void copyInstanceResources( Instance instance, Map<String,byte[]> fileNameToFileContent )
	throws IOException {

		File dir = InstanceHelpers.findInstanceDirectoryOnAgent( instance );
		Utils.createDirectory( dir );

		if( fileNameToFileContent != null ) {
			for( Map.Entry<String,byte[]> entry : fileNameToFileContent.entrySet()) {

				File f = new File( dir, entry.getKey());
				Utils.createDirectory( f.getParentFile());

				ByteArrayInputStream in = new ByteArrayInputStream( entry.getValue());
				Utils.copyStream( in, f );
			}
		}
	}
494918
def write(temp_object, opts={})
      temp_object.file do |fd|
        File.new.tap do |file|
          file.metadata = temp_object.meta
          file.data     = fd
          file.save!
          return file.id.to_s
        end
      end
    end
287659
def save_file(self, srcfile):
        
        filehash = digest_file(srcfile)
        if not os.path.exists(self.object_path(filehash)):
            # Copy the file to a temporary location first, then move, to make sure we don't end up with
            # truncated contents if the build gets interrupted.
            tmppath = self.temporary_object_path(filehash)
            copyfile(srcfile, tmppath)
            self._move_to_store(tmppath, filehash)

        return filehash
742004
public static File copyToTempFile(InputStream serialization)
            throws IOException, FileNotFoundException {
        File tempFile = createTempFile();
        StreamUtility.pipeStream(serialization,
                                 new FileOutputStream(tempFile),
                                 4096);
        return tempFile;
    }
103550
def temporary_file(mode):
    
    tempdir = tempfile.gettempdir()
    basename = 'tmpfile-%s' % (uuid.uuid4())
    full_filename = os.path.join(tempdir, basename)
    if 'w' not in mode:
        # We need to create the file before we can open
        # it in 'r' mode.
        open(full_filename, 'w').close()
    try:
        with open(full_filename, mode) as f:
            yield f
    finally:
        os.remove(f.name)
43434
def to_file(self, output_filename):
        ''''''
        temp_file = NamedTemporaryFile(mode="w", suffix=".md", delete=False)
        temp_file.write(self._content)
        temp_file.close()

        subprocess_arguments = [PANDOC_PATH, temp_file.name, '-o %s' % output_filename]
        subprocess_arguments.extend(self.arguments)
        cmd = " ".join(subprocess_arguments)

        fin = os.popen(cmd)
        msg = fin.read()
        fin.close()
        if msg:
            print("Pandoc message: {}",format(msg))

        os.remove(temp_file.name)

        if exists(output_filename):
            return output_filename
        else:
            raise IOError("Failed creating file: %s" % output_filename)
429308
function copyFile(src, dest) {
      var content = fs.readFileSync(src, 'binary');
      fs.writeFileSync(dest, content, 'binary');
    }
785905
def copy(self, filename=None):
        
        dst = os.path.join(self.dst_path, filename)
        src = os.path.join(self.src_path, filename)
        dst_tmp = os.path.join(self.dst_tmp, filename)
        self.put(src=src, dst=dst_tmp, callback=self.update_progress, confirm=True)
        self.rename(src=dst_tmp, dst=dst)
655422
def copy_file_or_flo(input_, output, buffer_size=64 * 1024, cb=None):
    

    assert bool(input_)
    assert bool(output)

    input_opened = False
    output_opened = False

    try:
        if isinstance(input_, string_types):

            if not os.path.isdir(os.path.dirname(input_)):
                os.makedirs(os.path.dirname(input_))

            input_ = open(input_, 'r')
            input_opened = True

        if isinstance(output, string_types):

            if not os.path.isdir(os.path.dirname(output)):
                os.makedirs(os.path.dirname(output))

            output = open(output, 'wb')
            output_opened = True

        # shutil.copyfileobj(input_,  output, buffer_size)

        def copyfileobj(fsrc, fdst, length=buffer_size):
            cumulative = 0
            while True:
                buf = fsrc.read(length)
                if not buf:
                    break
                fdst.write(buf)
                if cb:
                    cumulative += len(buf)
                    cb(len(buf), cumulative)

        copyfileobj(input_, output)

    finally:
        if input_opened:
            input_.close()

        if output_opened:
            output.close()
34048
def put_file(client, source_file, destination_file):
    
    try:
        sftp_client = client.open_sftp()
        sftp_client.put(source_file, destination_file)
    except Exception as error:
        raise IpaUtilsException(
            'Error copying file to instance: {0}.'.format(error)
        )
    finally:
        with ignored(Exception):
            sftp_client.close()
361052
def copy(copy_entry: FILE_COPY_ENTRY):
    
    source_path = environ.paths.clean(copy_entry.source)
    output_path = environ.paths.clean(copy_entry.destination)
    copier = shutil.copy2 if os.path.isfile(source_path) else shutil.copytree
    make_output_directory(output_path)

    for i in range(3):
        try:
            copier(source_path, output_path)
            return
        except Exception:
            time.sleep(0.5)

    raise IOError('Unable to copy "{source}" to "{destination}"'.format(
        source=source_path,
        destination=output_path
    ))
999314
def with_temporary_files(file_contents='', dest_extension = '', source_extension = '', message=nil)

      #File mode for all of the created temporary files.
      #Create the files, and allow read/write, but do not lock for exclusive access.
      file_mode = File::CREAT | File::RDWR

      #Create a new file which contains the provided file content.
      #Used to pass arbitrary data into an external tool.
      Tempfile.open(['core_prev', source_extension], :mode => file_mode) do |source_file|

        #Fill the source file with the provided file contents...
        source_file.write(file_contents)
        source_file.flush

        #Create a new file which will store the resultant file content.
        Tempfile.open(['core_next', dest_extension], :mode => file_mode) do |destination_file|

          #Yield the file's paths the provided block.
          raise CommandFailedError, message unless yield [destination_file.path, source_file.path]

          #And return the content of the destination file.
          return File::read(destination_file)

        end

      end
    end