Slurp the whole file into memory.
        Should only be used with relatively small files.
        :return: str: file contents
493370
def read_whole_file(self):
        
        chunk = None
        with open(self.path, 'rb') as infile:
            chunk = infile.read()
        return chunk
1065294
def _perform_chunking(func_, *args, **kwargs):
    
    obj_dict = args[0]
    start_point = 0
    file_count = 0
    new_dict = {}
    resp_dict = Counter({})
    file_list = []
    while start_point < len(obj_dict[CONTENT_FIELD]):
        file_count += 1
        chunk_fn = CHUNK_POSTFIX.format(obj_dict[PRIMARY_FIELD],
                                        str(file_count).zfill(CHUNK_ZPAD))
        new_dict[PRIMARY_FIELD] = chunk_fn
        file_list.append(new_dict[PRIMARY_FIELD])
        new_dict[CONTENTTYPE_FIELD] = obj_dict[CONTENTTYPE_FIELD]
        new_dict[TIMESTAMP_FIELD] = obj_dict[TIMESTAMP_FIELD]
        end_point = file_count * MAX_PUT
        sliced = obj_dict[CONTENT_FIELD][start_point: end_point]
        new_dict[CONTENT_FIELD] = sliced
        new_dict[PART_FIELD] = True
        new_dict[PARENT_FIELD] = obj_dict[PRIMARY_FIELD]
        start_point = end_point
        new_args = (new_dict, args[1])
        resp_dict += Counter(func_(*new_args, **kwargs))

    obj_dict[CONTENT_FIELD] = b""
    obj_dict[PARTS_FIELD] = file_list
    obj_dict[PART_FIELD] = False
    new_args = (obj_dict, args[1])
    resp_dict += Counter(func_(*new_args, **kwargs))
    return resp_dict
786303
def flush(self):
        """"""
        self._check_open_file()
        if self.allow_update and not self.is_stream:
            contents = self._io.getvalue()
            if self._append:
                self._sync_io()
                old_contents = (self.file_object.byte_contents
                                if is_byte_string(contents) else
                                self.file_object.contents)
                contents = old_contents + contents[self._flush_pos:]
                self._set_stream_contents(contents)
                self.update_flush_pos()
            else:
                self._io.flush()
            if self.file_object.set_contents(contents, self._encoding):
                if self._filesystem.is_windows_fs:
                    self._changed = True
                else:
                    current_time = time.time()
                    self.file_object.st_ctime = current_time
                    self.file_object.st_mtime = current_time
            self._file_epoch = self.file_object.epoch

            if not self.is_stream:
                self._flush_related_files()
1036001
def _read(self):
        
        filepos = self._fp.tell()
        if filepos < 1:
            return ""
        destpos = max(filepos - self._chunk_size, 0)
        self._fp.seek(destpos)
        buf = self._fp.read(filepos - destpos)
        self._fp.seek(destpos)
        return buf
776085
def memory_dump():
    
    import cPickle
    dump = open("memory.pickle", 'w')
    for obj in gc.get_objects():
        i = id(obj)
        size = sys.getsizeof(obj, 0)
        #    referrers = [id(o) for o in gc.get_referrers(obj) if hasattr(o, '__class__')]
        referents = [id(o) for o in gc.get_referents(obj) if hasattr(o, '__class__')]
        if hasattr(obj, '__class__'):
            cls = str(obj.__class__)
            cPickle.dump({'id': i, 'class': cls, 'size': size, 'referents': referents}, dump)
417259
function slurp(R, blob, length, opts) {
	var l = length;
	var bufs = [];
	var d = blob.slice(blob.l,blob.l+l);
	if(opts && opts.enc && opts.enc.insitu_decrypt) switch(R.n) {
	case 'BOF': case 'FilePass': case 'FileLock': case 'InterfaceHdr': case 'RRDInfo': case 'RRDHead': case 'UsrExcl': break;
	default:
		if(d.length === 0) break;
		opts.enc.insitu_decrypt(d);
	}
	bufs.push(d);
	blob.l += l;
	var next = (XLSRecordEnum[__readUInt16LE(blob,blob.l)]);
	while(next != null && next.n === 'Continue') {
		l = __readUInt16LE(blob,blob.l+2);
		bufs.push(blob.slice(blob.l+4,blob.l+4+l));
		blob.l += 4+l;
		next = (XLSRecordEnum[__readUInt16LE(blob, blob.l)]);
	}
	var b = (bconcat(bufs));
	prep_blob(b, 0);
	var ll = 0; b.lens = [];
	for(var j = 0; j < bufs.length; ++j) { b.lens.push(ll); ll += bufs[j].length; }
	return R.f(b, b.length, opts);
}
1076769
def flush(self):
        
        if self._writable:
            with self._seek_lock:
                buffer = self._get_buffer()

                # Flush that part of the file
                end = self._seek
                start = end - len(buffer)

                # Clear buffer
                self._write_buffer = bytearray()

            # Flush content
            with handle_os_exceptions():
                self._flush(buffer, start, end)
955640
def _flush_content(self):
        '''
        
        '''
        if self.__current_section is not None:
            buff = BytesIO()
            buff._dirty = False
            for action_return in self.__current_section:
                for title, ret_data in action_return.items():
                    if isinstance(ret_data, file):
                        self.out.put(ret_data.name, indent=4)
                        self.__arch.add(ret_data.name, arcname=ret_data.name)
                    else:
                        buff.write(salt.utils.stringutils.to_bytes(title + '\n'))
                        buff.write(salt.utils.stringutils.to_bytes(('-' * len(title)) + '\n\n'))
                        buff.write(salt.utils.stringutils.to_bytes(ret_data))
                        buff.write(salt.utils.stringutils.to_bytes('\n\n\n'))
                        buff._dirty = True
            if buff._dirty:
                buff.seek(0)
                tar_info = tarfile.TarInfo(name="{}/{}".format(self.__default_root, self.__current_section_name))
                if not hasattr(buff, 'getbuffer'):  # Py2's BytesIO is older
                    buff.getbuffer = buff.getvalue
                tar_info.size = len(buff.getbuffer())
                self.__arch.addfile(tarinfo=tar_info, fileobj=buff)
693566
def _file_md5(file_):
    
    md5 = hashlib.md5()
    chunk_size = 128 * md5.block_size
    for chunk in iter(lambda: file_.read(chunk_size), b''):
        md5.update(chunk)
    file_.seek(0)
    byte_digest = md5.digest()
    return base64.b64encode(byte_digest).decode()
926100
def load_file_to_string(self):
        
        try:
            with open(self.fullname, 'r') as f:
                txt = f.read()
            return txt
        except IOError:
            return ''
1140065
def load(self):
        
        if self._dict is None:
            if self.dirty:
                self._dict = self._loader(self.filename)
                self.cache()
            else:
                with open(self.cachename, 'rb') as stream:
                    self._dict = cPickle.load(stream)

        return self._dict
678380
def slurpChompedLines(file, expand=False):
    """
    f=_normalizeToFile(file, "r", expand)
    try: return list(chompLines(f))
    finally: f.close()
99072
def batch_string(self, content):
        
        pipe_send, pipe_recv = multiprocessing.Pipe()
        self._pipe_end = pipe_recv
        proc = multiprocessing.Process(target = self.cmdloop)
        for line in content.split('\n'):
            pipe_send.send(line)
        pipe_send.close()
        proc.start()
        proc.join()
524263
def copy(self):
		
		out = self._from_iterable(None)
		out._dict = self._dict.copy()
		out._size = self._size
		return out
1225254
def _init_append(self):
        
        # Require to load the full file content in buffer
        self._write_buffer[:] = self._readall()

        # Make initial seek position to current end of file
        self._seek = self._size
820623
def flush(self):
        """"""

        (slice_, self.__buffer) = (self.__buffer, '')
        self.__size = 0

        return slice_
1034522
def dump(self, dump_filename, pickle_protocol=pickle.HIGHEST_PROTOCOL):
        
        result = self.result()

        with open(dump_filename, 'wb') as f:
            pickle.dump((self.__class__, result), f, pickle_protocol)