Write file to disk

        :param filename:
        :param chunk_size:
178591
def save(self, filename, chunk_size=CHUNK_SIZE):
        
        with open(filename, 'wb') as fp:
            while True:
                # Chunk writer
                data = self.file.read(chunk_size)
                if not data:
                    break
                fp.write(data)
            # Flush all data
            fp.flush()

        # Go to start of file.
        if self.file.seekable():
            self.file.seek(0)
42992
def write(self, b):
        
        if not self._writable:
            raise UnsupportedOperation('write')

        # This function write data in a buffer
        # "flush()" need to be called to really write content on
        # Cloud Storage
        size = len(b)
        with self._seek_lock:
            start = self._seek
            end = start + size
            self._seek = end

        buffer = self._write_buffer
        if end <= len(buffer):
            buffer = memoryview(buffer)
        buffer[start:end] = b
        return size
1212
def write(self, chunk):
        """"""
        if self.chunked_write and chunk:
            chunk_size_hex = hex(len(chunk))[2:].encode('ascii')
            buf = [chunk_size_hex, CRLF, chunk, CRLF]
            self.conn.wfile.write(EMPTY.join(buf))
        else:
            self.conn.wfile.write(chunk)
733346
def _WriteFileChunk(self, chunk):
    
    if chunk.chunk_index == 0:
      # Make sure size of the original file is passed. It's required
      # when output_writer is StreamingTarWriter.
      st = os.stat_result((0o644, 0, 0, 0, 0, 0, chunk.total_size, 0, 0, 0))
      target_path = _ClientPathToString(chunk.client_path, prefix=self.prefix)
      yield self.archive_generator.WriteFileHeader(target_path, st=st)

    yield self.archive_generator.WriteFileChunk(chunk.data)

    if chunk.chunk_index == chunk.total_chunks - 1:
      yield self.archive_generator.WriteFileFooter()
      self.archived_files.add(chunk.client_path)
67855
def chunks(self, chunk_size=None):
        
        if not chunk_size:
            chunk_size = self.DEFAULT_CHUNK_SIZE

        try:
            self.seek(0)
        except (AttributeError, UnsupportedOperation):
            pass

        while True:
            data = self.read(chunk_size)
            if not data:
                break
            yield data
1181593
def write_to_file(self, filename):
        
        fid = open(filename, 'w')

        for key in self.key_order:
            if(key == -1):
                fid.write('\n')
            else:
                fid.write('{0}\n'.format(self[key]))

        fid.close()
1120433
def save_to_file(self, fname):
        
        with open(fname, 'w') as f:
            f.write(str(self))
710230
function MongolianGridFileWriteStream(file) {
    if (file.chunkSize instanceof Long) throw new Error("Long (64bit) chunkSize unsupported")
    if (file.chunkSize <= 0) throw new Error("File has invalid chunkSize: "+file.chunkSize)
    stream.Stream.call(this)
    this.file = file
    this.writable = true
    this.encoding = 'binary'
    this._hash = crypto.createHash('md5')
    this._chunkIndex = 0
    file.length = 0
    this._chunkSize = file.chunkSize
}
170732
def write_image(r, filename):
    
    with open(filename, 'wb') as fd:
        for chunk in r.iter_content(1024):
            fd.write(chunk)
582927
def write_to_csv(file_name, mode = "w")
      File.open(file_name, mode) do |file|
        all.copy_csv(file)
      end
    end
133716
def determine_num_chunks(chunk_size, file_size):
        
        if file_size == 0:
            return 1
        return int(math.ceil(float(file_size) / float(chunk_size)))
1043818
def WriteFileChunk(self, chunk):
    """"""
    precondition.AssertType(chunk, bytes)

    if not self._stream:
      raise ArchiveAlreadyClosedError(
          "Attempting to write to a ZIP archive that was already closed.")

    self.cur_file_size += len(chunk)
    # TODO(user):pytype: crc32 is not visible outside of zipfile.
    # pytype: disable=module-attr
    self.cur_crc = zipfile.crc32(chunk, self.cur_crc) & 0xffffffff
    # pytype: enable=module-attr

    if self.cur_cmpr:
      chunk = self.cur_cmpr.compress(chunk)
      self.cur_compress_size += len(chunk)

    self._stream.write(chunk)
    return self._stream.GetValueAndReset()
1150932
def get_starting_chunk(filename, length=1024):
    
    # Ensure we open the file in binary mode
    with open(filename, 'rb') as f:
        chunk = f.read(length)
        return chunk
1001472
def big_file(filename):
        
        
        md5 = hashlib.md5()
        with open(filename, 'rb') as f:
            for chunk in iter(lambda: f.read(8192), b''):
                md5.update(chunk)
        
        result = md5.hexdigest()
        return result
314602
def write_file(file_name, file_contents)
      contents =  file_contents
                  .flatten
                  .select { |line| line }
                  .join("\n")
      File.open(file_name, "w") do |fh|
        fh.write(contents)
        fh.write("\n")
      end
    end
3202
def chunk(self, size=0):
        

        if size == 0:
            raise ValueError('Invalid chunk size')

        self.__prepare()
        _new_content = []

        while(len(self._json_data) > 0):
            _new_content.append(self._json_data[0:size])
            self._json_data = self._json_data[size:]

        self._json_data = _new_content

        return self._json_data
1032457
def save(self, name, file):
        
        # Get the proper name for the file, as it will actually be saved.
        if name is None:
            name = file.name

        if not hasattr(file, 'chunks'):
            file = File(file, name=name)

        name = self.get_available_name(name)
        name = self._save(name, file)

        # Store filenames with forward slashes, even on Windows
        return name.replace('\\', '/')