Returns a file object of the cached response.
184256
def _get_cached_response(self):
        """"""

        if not self._is_cached():
            response = self._download_response()
            self.cache.set_xml(self._get_cache_key(), response)

        return self.cache.get_xml(self._get_cache_key())
1162888
private String getFileFromCache(String filename) {
        LRUCache.CacheEntry<String, T> cachedTemplate = cache.get(filename);

        if (cachedTemplate == null) {
            return null;
        }

        return cache.get(filename).raw;
    }
743494
def get_file_contents(self, file_key):
		'''
		'''
		#does not work
		self._raise_unimplemented_error()
		
		uri = '/'.join([self.api_uri,
						self.files_suffix,
						file_key,
						self.file_contents_suffix,
						])
		return self._req('get', uri)
1124026
function getJsonResource(url) {

    var protocol = url.match(/^(.*?):/)
    protocol = (protocol && protocol[1]) || 'file'

    const defaultLoader = defaultOptions.loaders[protocol]
    const loader = options.loaders[protocol]

    return Promise.resolve(cache[url])
    .then(cached => {
      if(cached) {
        return cached
      } else {
        return loader(url, defaultOptions.loaders)
          .then(json => cache[url] = {raw: json, parsed: Array.isArray(json) ? [] : {} })
      }
    })
  }
915679
def cache_file(self, template):
        '''
        
        '''
        saltpath = salt.utils.url.create(template)
        self.file_client().get_file(saltpath, '', True, self.saltenv)
853606
def _read_cache_from_file(self):
        """"""
        cache = {}
        try:
            with(open(self._cache_file_name, 'r')) as fp:
                contents = fp.read()
                cache = simplejson.loads(contents)
        except (IOError, JSONDecodeError):
            # The file could not be read. This is not a problem if the file does not exist.
            pass

        return cache
1350458
private String getMessage(String pContentType) {
        String fileName = responseMessageNames.get(pContentType);

        // Get cached value
        CacheEntry entry = responseCache.get(fileName);

        if ((entry == null) || entry.isExpired()) {

            // Create and add or replace cached value
            entry = new CacheEntry(readMessage(fileName));
            responseCache.put(fileName, entry);
        }

        // Return value
        return (entry.getValue() != null)
                ? (String) entry.getValue()
                : DEFUALT_RESPONSE_MESSAGE;
    }
1372339
def cache_json(filename):
    
    def cache_decorator(cacheable_function):
        @wraps(cacheable_function)
        def cache_wrapper(*args, **kwargs):
            path = CACHE_DIRECTORY + filename
            check_create_folder(path)
            if os.path.exists(path):
                with open(path) as infile:
                    return json.load(infile)
            else:
                function_output = cacheable_function(*args, **kwargs)
                with open(path, 'w') as outfile:
                    json.dump(function_output, outfile)
                return function_output
        return cache_wrapper
    return cache_decorator
504254
def get_file(self, cache_id_obj, section=None):
        """"""
        section = "default" if section is None else section
        if "/" in section:
            raise ValueError("invalid section '{0}'".format(section))
        cache_id = "{:08x}".format(
            zlib.crc32(b"&".join(sorted([
                str(k).encode('utf8') + b"=" + str(v).encode('utf8')
                for k, v in cache_id_obj.items()
            ]))) & 0xffffffff)
        return os.path.join(self._full_base,
                            os.path.join(section,
                                         os.path.join(
                                             "{0}".format(cache_id[:2]),
                                             "{0}.tmp".format(cache_id[2:]))))
180913
def deserialize(self, response, response_type):
        
        # handle file downloading
        # save response body into a tmp file and return the instance
        if "file" == response_type:
            return self.__deserialize_file(response)

        # fetch data from response object
        try:
            data = json.loads(response.data)
        except ValueError:
            data = response.data

        return self.__deserialize(data, response_type)
48472
def get(self, attach, *args, **kwargs):
        
        response = self.make_response(*args, **kwargs)  # type: Response
        response.content_type = self.get_content_type(*args, **kwargs)

        if attach:
            filename = self.get_filename(*args, **kwargs)
            if not filename:
                filename = "file.bin"
            headers = response.headers
            headers.add("Content-Disposition", "attachment", filename=filename)

        self.set_cache_headers(response)
        return response
878242
def _process_response(self, resp, out_folder=None):
        
        CHUNK = 4056
        maintype = self._mainType(resp)
        contentDisposition = resp.headers.get('content-disposition')
        contentEncoding = resp.headers.get('content-encoding')
        contentType = resp.headers.get('content-type')
        contentLength = resp.headers.get('content-length')
        if maintype.lower() in ('image',
                                'application/x-zip-compressed') or \
           contentType == 'application/x-zip-compressed' or \
           (contentDisposition is not None and \
            contentDisposition.lower().find('attachment;') > -1):
            fname = self._get_file_name(
                contentDisposition=contentDisposition,
                url=resp.geturl())
            if out_folder is None:
                out_folder = tempfile.gettempdir()
            if contentLength is not None:
                max_length = int(contentLength)
                if max_length < CHUNK:
                    CHUNK = max_length
            file_name = os.path.join(out_folder, fname)
            with open(file_name, 'wb') as writer:
                for data in self._chunk(response=resp):
                    writer.write(data)
                    del data
                del writer
            return file_name
        else:
            read = ""
            for data in self._chunk(response=resp, size=4096):
                if self.PY3 == True:
                    read += data.decode('utf-8')
                else:
                    read += data
                del data
            try:
                return json.loads(read.strip())
            except:
                return read
        return None
1050395
def render_file(self, context, result):
		""""""
		if __debug__:
			log.debug("Processing file-like object.", extra=dict(request=id(context), result=repr(result)))
		
		response = context.response
		response.conditional_response = True
		
		modified = mktime(gmtime(getmtime(result.name)))
		
		response.last_modified = datetime.fromtimestamp(modified)
		ct, ce = guess_type(result.name)
		if not ct: ct = 'application/octet-stream'
		response.content_type, response.content_encoding = ct, ce
		response.etag = unicode(modified)
		
		result.seek(0, 2)  # Seek to the end of the file.
		response.content_length = result.tell()
		
		result.seek(0)  # Seek back to the start of the file.
		response.body_file = result
		
		return True
576738
public InputStream getAsStream() throws CacheException {
		try {
			if(file.exists() && file.isFile()) {
				logger.debug("retrieving file as a stream");
				return new FileInputStream(file);			
			}
		} catch(IOException e) {
			logger.error("file '{}' does not exist or is not a file", file.getAbsolutePath());
			throw new CacheException("File " + file.getAbsolutePath() + " does not exist or is not a regular file", e);
		}		
		return null;
	}
453909
@Nullable
  private File getCachedFile(String url) throws FileNotFoundException {
    File jsonFile = new File(appContext.getCacheDir(), filenameForUrl(url, FileExtension.JSON, false));
    if (jsonFile.exists()) {
      return jsonFile;
    }
    File zipFile = new File(appContext.getCacheDir(), filenameForUrl(url, FileExtension.ZIP, false));
    if (zipFile.exists()) {
      return zipFile;
    }
    return null;
  }
798310
def get_file_contents(self, pointer=False):
        '''
        
        '''
        if self.pointer:
            if pointer:
                return self.old_pointed
            else:
                return self.old_data
        else:
            return self.old_data
228975
def get_file_report(self, this_hash):
        
        params = {'api_key': self.api_key, 'hash': this_hash}

        try:
            response_info = requests.get(self.base + 'file/mwsinfo', params=params)
            response_additional = requests.get(self.base + 'file/addinfo', params=params)
        except requests.RequestException as e:
            return dict(error=e.message)

        ri = _return_response_and_status_code(response_info)
        ra = _return_response_and_status_code(response_additional)

        if ri['response_code'] == '1' and ra['response_code'] == '1':  # both ok
            both = ri['results'].copy()
            both.update(ra['results'])
            response = dict(results=both, response_code=1)
        elif ri['response_code'] == '1' and ra['response_code'] == '0':  # advance non exists but standard ok
            response = ri
        elif ri['response_code'] == '2':  # main is still loading
            response = dict(results={}, response_code=2)
        else:  # error generic
            response = ri
        return response