reconstruct the complete file in the memory
971372
public function save(){
        $this->_contentArray =  array_merge($this->_codesBeforeEditArea, $this->_editArea, $this->_codesAfterEditArea);
        return $this;
    }
734314
def from_bytes(self, raw):
        ''''''
        if len(raw) < TCP._MINLEN:
            raise NotEnoughDataError("Not enough bytes ({}) to reconstruct an TCP object".format(len(raw)))
        fields = struct.unpack(TCP._PACKFMT, raw[:TCP._MINLEN])
        self._src = fields[0]
        self._dst = fields[1]
        self._seq = fields[2]        
        self._ack = fields[3]
        offset = fields[4] >> 12
        self._flags = fields[4] & 0x01ff
        self._window = fields[5]
        csum = fields[6]
        self._urg = fields[7]
        headerlen = offset * 4
        optlen = headerlen - TCP._MINLEN
        self._options.from_bytes(raw[TCP._MINLEN:headerlen])
        return raw[headerlen:]
414470
boolean reconstructFile(Path srcPath, Context context)
      throws IOException, InterruptedException {
    Progressable progress = context;
    if (progress == null) {
      progress = RaidUtils.NULL_PROGRESSABLE;
    }
    
    FileSystem fs = srcPath.getFileSystem(getConf());
    FileStatus srcStat = null;
    try {
      srcStat = fs.getFileStatus(srcPath);
    } catch (FileNotFoundException ex) {
      return false;
    }

    if (RaidNode.isParityHarPartFile(srcPath)) {
      return processParityHarPartFile(srcPath, progress);
    }

    // Reconstruct parity file
    for (Codec codec : Codec.getCodecs()) {
      if (isParityFile(srcPath, codec)) {
        Decoder decoder = new Decoder(getConf(), codec);
        decoder.connectToStore(srcPath);
        return processParityFile(srcPath, 
            decoder, context);
      }
    }

    // Reconstruct source file without connecting to stripe store 
    for (Codec codec : Codec.getCodecs()) {
      ParityFilePair ppair = ParityFilePair.getParityFile(
          codec, srcStat, getConf());
      if (ppair != null) {
        Decoder decoder = new Decoder(getConf(), codec);
        decoder.connectToStore(srcPath);
        return processFile(srcPath, ppair, decoder, false, context);
      }
    }
    // Reconstruct source file through stripe store
    for (Codec codec : Codec.getCodecs()) {
      if (!codec.isDirRaid) {
        continue;
      }
      try {
        // try to fix through the stripe store.
        Decoder decoder = new Decoder(getConf(), codec);
        decoder.connectToStore(srcPath);
        if (processFile(srcPath, null, decoder, true, context)) {
          return true;
        }
      } catch (Exception ex) {
        LogUtils.logRaidReconstructionMetrics(LOGRESULTS.FAILURE, 0,
            codec, srcPath, -1, LOGTYPES.OFFLINE_RECONSTRUCTION_USE_STRIPE,
            fs, ex, context);
      }
    }
    
    return false;    
  }
242711
def extract_archive(archive_path, destination_path):
    """"""
    tar = tarfile.open(archive_path)
    tar.errorlevel = 1
    tar.extractall(destination_path)
1322147
def iterstraight(self, raw):
        

        # length of row, in bytes
        rb = self.row_bytes
        a = array('B')
        # The previous (reconstructed) scanline.  None indicates first
        # line of image.
        recon = None
        for some in raw:
            a.extend(some)
            while len(a) >= rb + 1:
                filter_type = a[0]
                scanline = a[1:rb+1]
                del a[:rb+1]
                recon = self.undo_filter(filter_type, scanline, recon)
                yield recon
        if len(a) != 0:
            # :file:format We get here with a file format error:
            # when the available bytes (after decompressing) do not
            # pack into exact rows.
            raise FormatError(
              'Wrong size for decompressed IDAT chunk.')
        assert len(a) == 0
704212
private void loadDataFromInternetAndSave() throws IOException {
		InputStream is = null;
		FileOutputStream fos = null;
		try {
			URL url = new URL(DATA_RETRIVE_URL);
			is = url.openStream();
			fos = new FileOutputStream(getCacheFile());
			byte[] buff = new byte[1024 * 8];
			int len = 0;
			while ((len = is.read(buff)) != -1) {
				fos.write(buff, 0, len);
			}
		} finally {
			if (is != null) {
				is.close();
			}
			if (fos != null) {
				fos.close();
			}
		}

	}
961583
def recompile(filename):
    """"""
    # Most of the code here based on the compile.py module.
    import os
    import imp
    import marshal
    import struct

    f = open(filename, 'U')
    try:
        timestamp = long(os.fstat(f.fileno()).st_mtime)
    except AttributeError:
        timestamp = long(os.stat(filename).st_mtime)
    codestring = f.read()
    f.close()
    if codestring and codestring[-1] != '\n':
        codestring = codestring + '\n'
    try:
        codeobject = compile(codestring, filename, 'exec')
    except SyntaxError:
        print >> sys.stderr, "Skipping %s - syntax error." % filename
        return
    cod = Code.from_code(codeobject)
    message = "reassembled %r imported.\n" % filename
    cod.code[:0] = [ # __import__('sys').stderr.write(message)
        (LOAD_GLOBAL, '__import__'),
        (LOAD_CONST, 'sys'),
        (CALL_FUNCTION, 1),
        (LOAD_ATTR, 'stderr'),
        (LOAD_ATTR, 'write'),
        (LOAD_CONST, message),
        (CALL_FUNCTION, 1),
        (POP_TOP, None),
        ]
    codeobject2 = cod.to_code()
    fc = open(filename+'c', 'wb')
    fc.write('\0\0\0\0')
    fc.write(struct.pack('<l', timestamp))
    marshal.dump(codeobject2, fc)
    fc.flush()
    fc.seek(0, 0)
    fc.write(imp.get_magic())
    fc.close()
652735
def process_file(filename):
    """"""
    try:
        with codecs.open(filename, encoding='utf-8', mode='r') as f:
            file_contents = f.read()
    except IOError:
        log.info('Unable to read file: %s', filename)
        return None
    data = json.loads(file_contents)
    title = ''
    body_content = ''
    if 'current_page_name' in data:
        path = data['current_page_name']
    else:
        log.info('Unable to index file due to no name %s', filename)
        return None
    if 'body' in data and data['body']:
        body = PyQuery(data['body'])
        body_content = body.text().replace(u'¶', '')
    else:
        log.info('Unable to index content for: %s', filename)
    if 'title' in data:
        title = data['title']
        if title.startswith('<'):
            title = PyQuery(data['title']).text()
    else:
        log.info('Unable to index title for: %s', filename)

    return {'headers': process_headers(data, filename),
            'content': body_content, 'path': path, 'title': title}
939074
def xz_decompress_stream(src):
    
    dec = lzma.LZMADecompressor()
    for block in src:
        decoded = dec.decompress(block)
        if decoded:
            yield decoded

    if dec.unused_data:  # pragma: nocover; can't figure out how to test this
        raise IOError('Read unused data at end of compressed stream')
648600
function getData (allFiles = [], config) {
  const files = allFiles.reduce((memo, iteratee) => {
    const filePath = path.parse(iteratee)
    if (config.include.includes(filePath.ext) && !config.exclude.includes(filePath.base)) {
      const newFile = {
        file: iteratee.replace(config.content, ''),
        dir: filePath.dir.replace(config.content, ''),
        name: filePath.name,
        base: filePath.base,
        ext: filePath.ext,
      }
      if (filePath.ext === '.md') {
        const file = fs.readFileSync(iteratee, { encoding: 'utf8' })
        const frontMatter = fm(file)
        newFile.attr = frontMatter.attributes
        newFile.body = frontMatter.body
      } else if (filePath.ext === '.png') {
        const image = new PNG.load(iteratee)
        newFile.width = image.width
        newFile.height = image.height
      }
      memo.push(newFile)
    }
    return memo
  }, [])
  return files
}
934396
def _fromfile(self):
        """"""
        self._fd.seek(0)
        try:
            self.byte_order = {b'II': '<', b'MM': '>'}[self._fd.read(2)]
        except KeyError:
            raise ValueError("not a valid TIFF file")
        version = struct.unpack(self.byte_order+'H', self._fd.read(2))[0]
        if version == 43:  # BigTiff
            self.offset_size, zero = struct.unpack(self.byte_order+'HH',
                                                   self._fd.read(4))
            if zero or self.offset_size != 8:
                raise ValueError("not a valid BigTIFF file")
        elif version == 42:
            self.offset_size = 4
        else:
            raise ValueError("not a TIFF file")
        self.pages = []
        while True:
            try:
                page = TIFFpage(self)
                self.pages.append(page)
            except StopIteration:
                break
        if not self.pages:
            raise ValueError("empty TIFF file")
356470
def restore(self, state):
        """"""

        storage_data = state.get(u'storage_data', [])
        streaming_data = state.get(u'streaming_data', [])

        if len(storage_data) > self.storage_length or len(streaming_data) > self.streaming_length:
            raise ArgumentError("Cannot restore InMemoryStorageEngine, too many readings",
                                storage_size=len(storage_data), storage_max=self.storage_length,
                                streaming_size=len(streaming_data), streaming_max=self.streaming_length)

        self.storage_data = [IOTileReading.FromDict(x) for x in storage_data]
        self.streaming_data = [IOTileReading.FromDict(x) for x in streaming_data]
405473
def get_file(hash):
    """"""
    stmt = _get_sql('get-file.sql')
    args = dict(hash=hash)

    with db_connect() as db_conn:
        with db_conn.cursor() as cursor:
            cursor.execute(stmt, args)
            try:
                file, _ = cursor.fetchone()
            except TypeError:
                raise FileNotFound(hash)
    return memoryview(file[:])
1193956
def filechunk(f, chunksize):
    """"""
    while True:
        chunk = tuple(itertools.islice(f, chunksize))
        if not chunk:
            return
        yield np.loadtxt(iter(chunk), dtype=np.float64)
800502
async def transform(self, file):
		""""""
		path = get_path(self.dest, file)
		await self.loop.run_in_executor(self.exe, write_file, path, file.contents)
		return file
493370
def read_whole_file(self):
        
        chunk = None
        with open(self.path, 'rb') as infile:
            chunk = infile.read()
        return chunk
1264241
def _read(self, directory, filename, session, path, name, extension, spatial, spatialReferenceID, replaceParamFile):
        
        # Set file extension property
        self.fileExtension = extension

        # Open file and parse into a data structure
        with open(path, 'r') as f:
            for line in f:
                valLine = ReplaceValLine()
                valLine.contents = line
                valLine.replaceValFile = self