Detects if the file is a binary, returns bool. Returns True if the file is
    a bin, False if the file is not and None if the file is not available.
176779
def is_binary(path):
    '''
    
    '''
    if not os.path.isfile(path):
        return False
    try:
        with fopen(path, 'rb') as fp_:
            try:
                data = fp_.read(2048)
                if six.PY3:
                    data = data.decode(__salt_system_encoding__)
                return salt.utils.stringutils.is_binary(data)
            except UnicodeDecodeError:
                return True
    except os.error:
        return False
107891
def isbinary(*args):
    """"""
    return all(map(lambda c: isnumber(c) or isbool(c), args))
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
1329996
def is_associated_file(self):
        # type: () -> bool
        '''
        
        '''
        if not self._initialized:
            raise pycdlibexception.PyCdlibInternalError('Directory Record not yet initialized')

        return self.file_flags & (1 << self.FILE_FLAG_ASSOCIATED_FILE_BIT)
1018865
def find_binary_in_path(filename):
    
    if 'PATH' not in os.environ:
        return None
    for directory in os.environ['PATH'].split(get_variable_separator()):
        binary = os.path.abspath(os.path.join(directory, filename))
        if os.path.isfile(binary) and os.access(binary, os.X_OK):
            return binary
    return None
1368684
def inform_of_short_bin_name(cls, binary):
        
        binary = os.path.splitext(os.path.basename(binary))[0]
        if binary != 'da':
            msg = '"da" is the preffered way of running "{binary}".'.format(binary=binary)
            logger.logger.info('*' * len(msg))
            logger.logger.info(msg)
            logger.logger.info('*' * len(msg))
398682
function isBinary (file) {
  return new Promise((resolve, reject) => {
    isTextOrBinary.isText(Path.basename(file.path), file.contents, (err, isText) => {
      if (err) return reject(err);
      if (isText) file.isText = true;
      resolve(file);
    });
  });
}
369804
func isBinaryFile(path string) bool {
	parts := strings.Split(path, string(os.PathSeparator))
	if len(parts) != 3 {
		return false
	}
	if parts[1] != "bin" {
		return false
	}
	return true
}
737317
def binary2base64(binary_file: str) -> str:
    
    # Use mode = "rb" to read binary file
    with open(binary_file, "rb") as bin_file:
        encoded_string = base64.b64encode(bin_file.read())
    return encoded_string.decode()
744006
def IsFile(self):
    
    if self._stat_object is None:
      self._stat_object = self._GetStat()
    if self._stat_object is not None:
      self.entry_type = self._stat_object.type
    return self.entry_type == definitions.FILE_ENTRY_TYPE_FILE
432641
def binary(self):
        
        if isinstance(self.value, bytes):
            length = len(self.value)
            if length > 4294967295:
                raise OutputException('uint32 overflow')
            elif self.bits != 8:
                return (
                    b_chr(_TAG_BIT_BINARY_EXT) +
                    struct.pack(b'>I', length) +
                    b_chr(self.bits) + self.value
                )
            else:
                return (
                    b_chr(_TAG_BINARY_EXT) +
                    struct.pack(b'>I', length) +
                    self.value
                )
        else:
            raise OutputException('unknown binary type')
276968
def binary_value_or_stdin(value):
    
    if value is None:
        reader = io.open(sys.stdin.fileno(), mode='rb', closefd=False)
        return reader.read()
    elif six.PY3:
        return os.fsencode(value)
    else:
        return value
334675
def is_binary_address(value: Any) -> bool:
    
    if not is_bytes(value):
        return False
    elif len(value) != 20:
        return False
    else:
        return True
784497
def is_file(self):
        
        try:
            return S_ISREG(self.stat().st_mode)
        except OSError as e:
            if e.errno not in (ENOENT, ENOTDIR):
                raise
            # Path doesn't exist or is a broken symlink
            # (see https://bitbucket.org/pitrou/pathlib/issue/12/)
            return False
681783
def is_gzip_file(abspath):
    
    abspath = abspath.lower()
    _, ext = os.path.splitext(abspath)
    if ext in [".gz", ".zip"]:
        is_gzip = True
    else:
        is_gzip = False
    return is_gzip
1040005
def _is_packed_binary(self, data):
        '''
        
        '''
        packed = False
        if isinstance(data, bytes) and len(data) == 16 and b':' not in data:
            try:
                packed = bool(int(binascii.hexlify(data), 16))
            except (ValueError, TypeError):
                pass

        return packed
1038482
protected function isBinaryAvailable(): bool
    {
        if (OsHelper::isUnix()) {
            // Do not use the 'which' program to check if a binary exists.
            // See also http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script
            $process = new Process([
                'sh',
                '-c',
                'command -v $0',
                $this->getBinary(),
            ]);
        } else {
            // 'where' is available on Windows since Server 2003
            $process = new Process([
                'where',
                $this->getBinary(),
            ]);
        }

        $process->run();

        return $process->isSuccessful();
    }