Internal: Is the blob a C++, Java or Python source file generated by the
 Protocol Buffer compiler?

 Returns true or false.
343346
def generated_protocol_buffer?
      return false unless PROTOBUF_EXTENSIONS.include?(extname)
      return false unless lines.count > 1

      return lines[0].include?("Generated by the protocol buffer compiler.  DO NOT EDIT!")
    end
259481
def _read_bytes(self, b):
        
        _LOGGER.debug("%d bytes requested from stream with content type: %s", b, self.content_type)
        if 0 <= b <= len(self.output_buffer) or self.__message_complete:
            _LOGGER.debug("No need to read from source stream or source stream closed")
            return

        if self.content_type == ContentType.FRAMED_DATA:
            _LOGGER.debug("Reading to framed body")
            self.output_buffer += self._read_bytes_to_framed_body(b)
        elif self.content_type == ContentType.NO_FRAMING:
            _LOGGER.debug("Reading to non-framed body")
            self.output_buffer += self._read_bytes_to_non_framed_body(b)
        else:
            raise NotSupportedError("Unsupported content type")

        # To maintain backwards compatibility, only enforce this if a CMM is provided by the caller.
        if self.config.key_provider is None and self.config.source_length is not None:
            # Enforce that if the caller provided a source length value, the total bytes encrypted
            # must not exceed that value.
            if self._bytes_encrypted > self.config.source_length:
                raise CustomMaximumValueExceeded(
                    "Bytes encrypted has exceeded stated source length estimate:\n{actual:d} > {estimated:d}".format(
                        actual=self._bytes_encrypted, estimated=self.config.source_length
                    )
                )
1173133
function parse_PtgAreaErr(blob, length, opts) {
	var type = (blob[blob.l++] & 0x60) >> 5;
	blob.l += opts && (opts.biff > 8) ? 12 : (opts.biff < 8 ? 6 : 8);
	return [type];
}
519703
function blobToBase64(blob) {
        var reader = new FileReader();
        var p = new Promise(function (success, fail) {
            reader.onloadend = function () {
                var base64 = reader.result;
                success(base64);
            };
            reader.onerror = function (e) {
                fail(e);
            };
        });

        reader.readAsDataURL(blob);

        return p;
    }
764836
async def blob_dump(self, elem, elem_type, params=None):
        
        elem_is_blob = isinstance(elem, x.BlobType)
        elem_params = elem if elem_is_blob or elem_type is None else elem_type
        data = getattr(elem, x.BlobType.DATA_ATTR) if elem_is_blob else elem

        if len(data) != elem_params.SIZE:
            raise ValueError('Fixed size blob has not defined size: %s, path %s' % (elem_params.SIZE, self.tracker))

        await dump_uvarint(self.iobj, len(elem))
        await self.iobj.awrite(data)
1322668
async def dump_blob(elem, elem_type=None):
    
    elem_is_blob = isinstance(elem, x.BlobType)
    data = getattr(elem, x.BlobType.DATA_ATTR) if elem_is_blob else elem
    if data is None or len(data) == 0:
        return b''
    if isinstance(data, (bytes, bytearray, list)):
        return base64.b16encode(bytes(data))
    else:
        raise ValueError('Unknown blob type')
1089543
def is_binary_file(file_obj):
    
    start = file_obj.tell()
    fbytes = file_obj.read(1024)
    file_obj.seek(start)
    is_str = isinstance(fbytes, str)
    for fbyte in fbytes:
        if is_str:
            code = ord(fbyte)
        else:
            code = fbyte
        if code > 127:
            return True
    return False
916431
async def blob(self, elem=None, elem_type=None, params=None):
        
        elem_type = elem_type if elem_type else elem.__class__
        if hasattr(elem_type, 'blob_serialize'):
            elem = elem_type() if elem is None else elem
            return await elem.blob_serialize(self, elem=elem, elem_type=elem_type, params=params)

        if self.writing:
            return await x.dump_blob(self.iobj, elem=elem, elem_type=elem_type, params=params)
        else:
            return await x.load_blob(self.iobj, elem_type=elem_type, params=params, elem=elem)
684947
function BinaryCMapStream(data) {
    this.buffer = data;
    this.pos = 0;
    this.end = data.length;
    this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  }
584675
def _blob_end_handler_factory():
    """"""
    def expand_res(res):
        if res is None:
            return 0, 0
        return res

    def action(c, ctx, prev, res, is_first):
        num_digits, num_pads = expand_res(res)
        if c in _BASE64_DIGITS:
            if prev == _CLOSE_BRACE or prev == _BASE64_PAD:
                _illegal_character(c, ctx.set_ion_type(IonType.BLOB))
            num_digits += 1
        elif c == _BASE64_PAD:
            if prev == _CLOSE_BRACE:
                _illegal_character(c, ctx.set_ion_type(IonType.BLOB))
            num_pads += 1
        else:
            _illegal_character(c, ctx.set_ion_type(IonType.BLOB))
        ctx.value.append(c)
        return num_digits, num_pads

    def validate(c, ctx, res):
        num_digits, num_pads = expand_res(res)
        if num_pads > 3 or (num_digits + num_pads) % 4 != 0:
            _illegal_character(c, ctx, 'Incorrect number of pad characters (%d) for a blob of %d base-64 digits.'
                               % (num_pads, num_digits))

    return _lob_end_handler_factory(IonType.BLOB, action, validate)
686192
def StreamSignedBinaryContents(blob_iterator,
                               chunk_size = 1024
                              ):
  
  all_blobs_read = False
  byte_buffer = io.BytesIO()
  while not all_blobs_read or byte_buffer.getvalue():
    while not all_blobs_read and byte_buffer.tell() < chunk_size:
      try:
        blob = next(blob_iterator)
      except StopIteration:
        all_blobs_read = True
        break
      byte_buffer.write(blob.data)
    if byte_buffer.tell() > 0:
      # Yield a chunk of the signed binary and reset the buffer to contain
      # only data that hasn't been sent yet.
      byte_buffer.seek(0)
      yield byte_buffer.read(chunk_size)
      byte_buffer = io.BytesIO(byte_buffer.read())
      byte_buffer.seek(0, io.SEEK_END)
809989
def generated?
      xcode_file? ||
      cocoapods? ||
      carthage_build? ||
      generated_graphql_relay? ||
      generated_net_designer_file? ||
      generated_net_specflow_feature_file? ||
      composer_lock? ||
      cargo_lock? ||
      node_modules? ||
      go_vendor? ||
      go_lock? ||
      npm_shrinkwrap_or_package_lock? ||
      godeps? ||
      generated_by_zephir? ||
      minified_files? ||
      has_source_map? ||
      source_map? ||
      compiled_coffeescript? ||
      generated_parser? ||
      generated_net_docfile? ||
      generated_postscript? ||
      compiled_cython_file? ||
      generated_go? ||
      generated_protocol_buffer? ||
      generated_javascript_protocol_buffer? ||
      generated_apache_thrift? ||
      generated_jni_header? ||
      vcr_cassette? ||
      generated_module? ||
      generated_unity3d_meta? ||
      generated_racc? ||
      generated_jflex? ||
      generated_grammarkit? ||
      generated_roxygen2? ||
      generated_pkgdown? ||
      generated_jison? ||
      generated_grpc_cpp? ||
      generated_dart? ||
      generated_perl_ppport_header? ||
      generated_gamemakerstudio?
    end
1149819
def is_bgzf(filename):
  
  with open(filename,'rb') as inf:
   bytes1 = inf.read(12)
   if len(bytes1) != 12:
     sys.stderr.write("File length ERROR\n")
     return False
   try:
     gzip_id1,gzip_id2,compression_method,flag,mtime,xfl,osval,xlen=struct.unpack('<BBBBIBBH',bytes1)
   except:
     sys.stderr.write("Unpack ERROR\n")
     return False
   if gzip_id1 != 31:
     sys.stderr.write("ID1 ERROR\n")
     return False
   if gzip_id2 != 139:
     sys.stderr.write("ID2 ERROR\n")
     return False
   if compression_method != 8:
     sys.stderr.write("Compression Method ERROR\n")
     return False
   if flag != 4:
     sys.stderr.write("flg ERROR\n")
     return False
   if xlen < 6:
     sys.stderr.write("no extra fields ERROR\n")
   # ready to look in extra field
   bytes2 = inf.read(xlen) # all the extra field stuff 
   if len(bytes2) != xlen: 
     sys.stderr.write("file length ERROR\n")
     return False
   s = StringIO.StringIO(bytes2)
   has_id = False
   obsslen = 0
   while True:
     v1 = s.read(4)
     if len(v1) == 0: break
     if len(v1) < 4:
       sys.stderr.write("lack header values ERROR\n")
       return False
     s1,s2,slen = struct.unpack('<BBH',v1)
     if s1 == 66 and s2 == 67:
       has_id = True
       obsslen = slen
     v = s.read(slen)
     if len(v) != slen:
       sys.stderr.write("extra field read ERROR\n")
       return False
   if not has_id or not obsslen == 2:
     sys.stderr.write("no proper extra header ERROR\n")
     return False
  return True
1118192
function() {
				var file = this.getSource().getSource();
				return o.inArray(o.typeOf(file), ['blob', 'file']) !== -1 ? file : null;
			}
697221
def identify_pycbc_live(origin, filepath, fileobj, *args, **kwargs):
    
    if identify_hdf5(origin, filepath, fileobj, *args, **kwargs) and (
            filepath is not None and PYCBC_FILENAME.match(basename(filepath))):
        return True
    return False
322863
function decodeBuffer( bundle, len, buf_type ) {
	var length=0, ans="";
	switch (len) {
		case 0: length = bundle.u8[bundle.i8++]; break;
		case 1: length = bundle.u16[bundle.i16++]; break;
		case 2: length = bundle.u32[bundle.i32++]; break;
		case 3: length = bundle.f64[bundle.i64++]; break;
	}

	// Process buffer according to type
	if (buf_type === 0) { // STRING_LATIN
		ans = String.fromCharCode.apply(null, bundle.readTypedArray( NUMTYPE.UINT8 , length ) );
		return DEBUG
			? __debugMeta( ans, 'string.latin', {} )
			: ans;

	} else if (buf_type === 1) { // STRING_UTF8
		ans = String.fromCharCode.apply(null, bundle.readTypedArray( NUMTYPE.UINT16 , length ) );
		return DEBUG
			? __debugMeta( ans, 'string.utf8', {} )
			: ans;

	} else if (buf_type === 2) { // IMAGE
		var img = document.createElement('img');
		img.src = decodeBlobURL( bundle, length );
		return img;

	} else if (buf_type === 4) { // SCRIPT
		var img = document.createElement('script');
		img.src = decodeBlobURL( bundle, length );
		return img;

	} else if (buf_type === 7) { // RESOURCE
		return decodeBlobURL( bundle, length );

	} else {
		throw new Errors.AssertError('Unknown buffer type #'+buf_type+'!');
	}

}
332393
def binary?
      # Large blobs aren't even loaded into memory
      if data.nil?
        true

      # Treat blank files as text
      elsif data == ""
        false

      # Charlock doesn't know what to think
      elsif encoding.nil?
        true

      # If Charlock says its binary
      else
        detect_encoding[:type] == :binary
      end
    end