Read storage at a given url
429032
def read(self, url):
        """"""
        (store_name, path) = self._split_url(url)
        adapter = self._create_adapter(store_name)
        lines = []
        with adapter.open(path) as f:
            for line in f:
                lines.append(line.decode())
        return lines
309736
protected function getStorageIfLoaded($url)
    {
        $arrayKey = "$url";

        if ($this->hasStorage($arrayKey)) {
            return $this->storages[$arrayKey];
        }

        return null;
    }
47559
def get_content (self):
        """"""
        if self.data is None:
            log.debug(LOG_CHECK, "Get content of %r", self.url)
            t = time.time()
            self.data = self.read_content()
            self.size = len(self.data)
            self.dltime = time.time() - t
            if self.size == 0:
                self.add_warning(_("Content size is zero."),
                             tag=WARN_URL_CONTENT_SIZE_ZERO)
            else:
                self.aggregate.add_downloaded_bytes(self.size)
        return self.data
388036
public static String readContentAsString(URL url, String encoding) {
        try {
            return readContentAsString(url.openStream());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
703819
def read(path, savedir):
        "  "
        if path.startswith('http://'):
            name = op.basename(path)
            save_path = op.join(savedir, name)
            if not op.exists(save_path):
                src = urllib2.urlopen(path).read()
                try:
                    open(save_path, 'w').write(src)
                except IOError:
                    return src
            path = save_path
        return open(path, 'r').read()
832604
function( url, callback ) {

		// Node quick, not present on browser builds
		if (IS_NODE) {

			// Helper function
			var readChunk = function ( filename ) {
				// Read into buffer
				var file = fs.readFileSync(filename),
					u8 = new Uint8Array(file);
				// Return buffer
				return u8.buffer;
			}

			// Read by chunks
			if (url.substr(-5) === ".jbbp") {

				// Add by buffer
				var base = url.substr(0,url.length-5);
				this.addByBuffer( [
					readChunk(base + '.jbbp'),
					readChunk(base + '_b16.jbbp'),
					readChunk(base + '_b32.jbbp'),
					readChunk(base + '_b64.jbbp'),
				], callback );

			} else {

				// Add by buffer
				this.addByBuffer( readChunk(url), callback );

			}

			// Don't continue on browser builds
			return;

		}

		// Check for base dir
		var prefix = "";
		if (this.baseDir)
			prefix = this.baseDir + "/";

		// Check for sparse bundle
		var parts = url.split("?"), suffix = "", reqURL = [];
		if (parts.length > 1) suffix = "?"+parts[1];
		if (parts[0].substr(parts[0].length - 5).toLowerCase() === ".jbbp") {
			var base = prefix + parts[0].substr(0, parts[0].length - 5);
			reqURL = [
				base + '.jbbp' + suffix,
				base + '_b16.jbbp' + suffix,
				base + '_b32.jbbp' + suffix,
				base + '_b64.jbbp' + suffix
			];
		} else {
			// Assume .jbb if missing (TODO: not a good idea)
			var url = parts[0];
			if (url.substr(url.length-4) != ".jbb") url += ".jbb";
			reqURL = [ prefix + url + suffix ];
		}

		// Load bundle header and keep a callback
		// for the remainging loading operations
		var pendingBundle = {
			'callback': callback,
			'status': PBUND_REQUESTED,
			'buffer': undefined,
			'url': reqURL
		};

		// Keep this pending action
		this.queuedRequests.push( pendingBundle );

	}
697468
def get_stored_files(self):
        """"""
        method = 'GET'
        endpoint = '/rest/v1/storage/{}'.format(self.client.sauce_username)
        return self.client.request(method, endpoint)
195370
def getfile2(url, auth=None, outdir=None):
    
    import requests
    print("Retrieving: %s" % url)
    fn = os.path.split(url)[-1]
    if outdir is not None:
        fn = os.path.join(outdir, fn)
    if auth is not None:
        r = requests.get(url, stream=True, auth=auth)
    else:
        r = requests.get(url, stream=True)
    chunk_size = 1000000
    with open(fn, 'wb') as fd:
        for chunk in r.iter_content(chunk_size):
            fd.write(chunk)
407153
def read_gzipped_text_url(url):
    """"""
    import urllib2
    import zlib
    from StringIO import StringIO

    opener = urllib2.build_opener() 
    request = urllib2.Request(url)
    request.add_header('Accept-encoding', 'gzip')
    respond = opener.open(request)
    compressedData = respond.read()
    respond.close()
    opener.close()
    compressedDataBuf = StringIO(compressedData)
    d = zlib.decompressobj(16+zlib.MAX_WBITS)
    buffer = compressedDataBuf.read(1024)
    #saveFile = open('/tmp/test.txt', "wb")
    s = []
    while buffer:
        s.append(d.decompress(buffer))
        buffer = compressedDataBuf.read(1024)
    s = ''.join(s)
    return s
356216
def read_bytes(self, path):
        """"""
        file = staticfiles_storage.open(path)
        content = file.read()
        file.close()
        return content
1040337
def uri_read(*args, **kwargs):
    

    with uri_open(*args, **kwargs) as f:
        content = f.read()
    return content
228830
def read_content (self):
        """"""
        if self.is_directory():
            self.url_connection.cwd(self.filename)
            self.files = self.get_files()
            # XXX limit number of files?
            data = get_index_html(self.files)
        else:
            # download file in BINARY mode
            ftpcmd = "RETR %s" % self.filename
            buf = StringIO()
            def stor_data (s):
                """Helper method storing given data"""
                # limit the download size
                if (buf.tell() + len(s)) > self.max_size:
                    raise LinkCheckerError(_("FTP file size too large"))
                buf.write(s)
            self.url_connection.retrbinary(ftpcmd, stor_data)
            data = buf.getvalue()
            buf.close()
        return data
256648
def read
      files = Dir.glob(File.join(path, "**/*"))
      
      regex = Regexp.new("(?<=#{path}).*")

      files.map do |file|
        unless ((File.directory? file) || (File.extname(file).upcase != ".URL"))
          url = File.read(file).scan(/(?<=\nURL=)(.*)$/).flatten.first.chomp
          name = url_name(File.basename(file, ".*"))
          description = ""
          tag         = extract_tags(File.dirname(file).scan(regex))
          [url, name, description, tag]
        end
      end.compact
    end
46884
def open_stored_file(value, url):
    
    upload = None
    result = deserialize_upload(value, url)
    filename = result['name']
    storage_class = result['storage']
    if storage_class and filename:
        storage = storage_class()
        if storage.exists(filename):
            upload = storage.open(filename)
            upload.name = os.path.basename(filename)
    return upload
618373
def _read(obj):
    
    if _is_url(obj):
        with urlopen(obj) as url:
            text = url.read()
    elif hasattr(obj, 'read'):
        text = obj.read()
    elif isinstance(obj, (str, bytes)):
        text = obj
        try:
            if os.path.isfile(text):
                with open(text, 'rb') as f:
                    return f.read()
        except (TypeError, ValueError):
            pass
    else:
        raise TypeError("Cannot read object of type %r" % type(obj).__name__)
    return text
1147451
def get_storage(key, username):
    """"""
    if IS_APPENGINE and appengine:
        return appengine.StorageByKeyName(
            appengine.CredentialsModel, username, 'credentials')
    file_name = os.path.expanduser('~/.config/webreview/{}_{}'.format(key, username))
    dir_name = os.path.dirname(file_name)
    if not os.path.exists(dir_name):
        os.makedirs(dir_name)
    return oauth_file.Storage(file_name)
800431
def _readFromUrl(cls, url, writable):
        
        # we use a ~10Mb buffer to improve speed
        with open(cls._extractPathFromUrl(url), 'rb') as readable:
            shutil.copyfileobj(readable, writable, length=cls.BUFFER_SIZE)