Returns {URL: (size, checksum)}s stored within file.
347165
def _get_sizes_checksums(checksums_path):
  """"""
  checksums = {}
  for line in _read_file(checksums_path).split('\n'):
    if not line:
      continue
    # URL might have spaces inside, but size and checksum will not.
    url, size, checksum = line.rsplit(' ', 2)
    checksums[url] = (int(size), checksum)
  return checksums
298612
def get_file_content(url, comes_from=None):
    """"""
    match = _scheme_re.search(url)
    if match:
        scheme = match.group(1).lower()
        if (scheme == 'file' and comes_from
            and comes_from.startswith('http')):
            raise InstallationError(
                'Requirements file %s references URL %s, which is local'
                % (comes_from, url))
        if scheme == 'file':
            path = url.split(':', 1)[1]
            path = path.replace('\\', '/')
            match = _url_slash_drive_re.match(path)
            if match:
                path = match.group(1) + ':' + path.split('|', 1)[1]
            path = urllib.unquote(path)
            if path.startswith('/'):
                path = '/' + path.lstrip('/')
            url = path
        else:
            ## FIXME: catch some errors
            resp = urlopen(url)
            return geturl(resp), resp.read()
    try:
        f = open(url)
        content = f.read()
    except IOError:
        e = sys.exc_info()[1]
        raise InstallationError('Could not open requirements file: %s' % str(e))
    else:
        f.close()
    return url, content
579203
def sha1sum_url(url):
    '''

    '''
    import hashlib
    import urllib
    from contextlib import closing

    sha1 = hashlib.sha1()
    chunk_size = sha1.block_size * 8192

    max_file_size = 10 * 1024 * 1024  # 10Mo limit in case of very large file

    total_read = 0
    with closing(urllib.urlopen(url)) as url_obj:
        for chunk in iter(lambda: url_obj.read(chunk_size), b''):
            sha1.update(chunk)
            total_read += chunk_size
            if total_read > max_file_size:
                break

    return sha1.hexdigest()
716417
function getStatusAndSize(host,path,callback) {

	if(stszCache.get(host,callback)) {
		console.log('getStatusAndSize: Resolved %s%s from stszCache...',host,path);
		return true;
	}

	console.log('getStatusAndSize: Looking up %s%s...',host,path);

	var options = {
		host: host,
		port: 80,
		path: path,
		method: 'GET'
	};

	var req = http.request(options, function(res) {
		var data = '';
		res.setEncoding('utf8');

		res.on('data', function (chunk) {
			data += chunk;
		});
		res.on('end', function () {
			stszCache.set(host,null,res.statusCode,data.length);
		});
		res.on('error', function (e) {
			stszCache.set(host,e);
		});
	});
	req.on('error',function(e) {
		stszCache.set(host,e);
	});
	req.end();
}
1195149
function getChecksum(fs, path, callback) {
  getAttr(fs, path, constants.attributes.checksum, callback);
}
444803
function getChecksum(fs, path, callback) {
  fs.readFile(path, function(err, data) {
    if(!err) {
      callback(null, md5sum(data));
    } else if(err.code === 'ENOENT') {
      // File does not exist so the checksum is an empty string
      callback(null, "");
    } else {
      callback(err);
    }
  });
}
27066
function httpGetChecksum (algorithm, url) {
  if (arguments.length === 1) {
    url = algorithm;
    algorithm = 'sha1';
  }
  var deferred = Q.defer();
  var http;
  if (url.slice(0, 5) === 'https') {
    http = require('https');
  } else if (url.slice(0, 4) === 'http')  {
    http = require('http');
  } else {
    deferred.resolve('[ERROR] Unknown protocol.');
    return deferred.promise;
  }
  var parts = Url.parse(url);
  http.get({
    host: parts.hostname,
    port: parts.port,
    path: parts.pathname,
    agent: false
  }, function(res) {
    var code = res.statusCode;
    if (code === 301 || code === 302) {
      return deferred.resolve(httpGetChecksum(algorithm, res.headers.location));
    } else if (code !== 200) {
      return deferred.resolve('[ERROR] Fail to get the page. Status: ' + code);
    }
    var sum = crypto.createHash(algorithm);
    res.on('data', function(data) {
      sum.update(data);
    });
    res.on('end', function() {
      deferred.resolve(sum.digest('hex'));
    });
  }).on('error', function (e) {
    deferred.resolve('[ERROR] ' + e.toString());
  });
  return deferred.promise;
}
870133
def get_urlhash(self, url, fmt):
        
        with self.open(os.path.basename(url)) as f:
            return {'url': fmt(url), 'sha256': filehash(f, 'sha256')}
178663
function getUrl (file) {

            if (!that.ignore(file)) {
                file = that.map(file);
                file = utils.normalize(file);
                return file;
            }
        }
1229473
def get_checksums(path, algorithms):
    
    if not algorithms:
        return {}

    compute_md5 = 'md5' in algorithms
    compute_sha256 = 'sha256' in algorithms

    if compute_md5:
        md5 = hashlib.md5()
    if compute_sha256:
        sha256 = hashlib.sha256()
    blocksize = 65536
    with open(path, mode='rb') as f:
        buf = f.read(blocksize)
        while len(buf) > 0:
            if compute_md5:
                md5.update(buf)
            if compute_sha256:
                sha256.update(buf)
            buf = f.read(blocksize)

    checksums = {}
    if compute_md5:
        checksums['md5sum'] = md5.hexdigest()
        logger.debug('md5sum: %s', checksums['md5sum'])
    if compute_sha256:
        checksums['sha256sum'] = sha256.hexdigest()
        logger.debug('sha256sum: %s', checksums['sha256sum'])
    return checksums
755037
function verifyChecksum(fileName, checksum) {
  return kew.resolve(hasha.fromFile(fileName, {algorithm: 'sha256'})).then(function (hash) {
    var result = checksum == hash
    if (result) {
      console.log('Verified checksum of previously downloaded file')
    } else {
      console.log('Checksum did not match')
    }
    return result
  }).fail(function (err) {
    console.error('Failed to verify checksum: ', err)
    return false
  })
}
1213465
function getSrc(file) {
  const encodedContents = new Buffer(file.contents).toString('base64')
  return `src:url(data:${mime.lookup(file.path)};charset=utf-8;base64,${encodedContents});`
}
658791
public static long getFileLengthFromBlockSize(long blockSize,
      int bytesPerChecksum, int checksumSize) {
    long numChunks; 
    if (blockSize % bytesPerChecksum == 0) {    
      numChunks = blockSize / bytesPerChecksum; 
    } else {    
      numChunks = blockSize / bytesPerChecksum + 1; 
    }   
    return blockSize + numChunks * checksumSize 
        + BlockInlineChecksumReader.getHeaderSize();  
  }
1138219
def get_metadata(self, filename):
        ''''''
        dest = self.path(filename)
        with open(dest, 'rb', buffering=0) as f:
            checksum = 'sha1:{0}'.format(sha1(f))
        return {
            'checksum': checksum,
            'size': os.path.getsize(dest),
            'mime': files.mime(filename),
            'modified': datetime.fromtimestamp(os.path.getmtime(dest)),
        }
762954
function getFilesizeInBytes(fileName) {
    try {
        var stats = fs.statSync(fileName);
        return stats.size || 0;
    } catch (ex) {
        console.log(ex);
        return 0;
    }
}
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 );

	}
244382
def get_checksum(file):
    
    with open(file, 'rb') as FH:
        contents = FH.read()
    return hashlib.sha256(contents).hexdigest()