Checks if the filename shows a tar/zip file
555656
def _check_if_zipped(self, path):
        

        filename = get_file(path).split('.')

        if filename[-1] in ['bz', 'bz2', 'gz']:
            return True

        return False
342303
def has_file(self, name: str):
        '''
        
        '''
        return os.path.isfile(self._path / name)
215608
def isfile(path, **kwargs):
    """"""
    import os.path
    return os.path.isfile(path, **kwargs)
1164256
def file_exists(fname):
    
    try:
        return fname and os.path.exists(fname) and os.path.getsize(fname) > 0
    except OSError:
        return False
1317217
def maybe_inspect_zip(models):
    
    '''

    if not(is_zip_file(models)):
        return models

    if len(models) > 1:
        return models

    if len(models) < 1:
        raise AssertionError('No models at all')

    return zipfile.ZipFile(models[0]).namelist()
1187232
def is_matching(cls, file_path):
        
        if file_path.endswith(".ndata") and os.path.exists(file_path):
            try:
                with open(file_path, "r+b") as fp:
                    local_files, dir_files, eocd = parse_zip(fp)
                    contains_data = b"data.npy" in dir_files
                    contains_metadata = b"metadata.json" in dir_files
                    file_count = contains_data + contains_metadata  # use fact that True is 1, False is 0
                    # TODO: make sure ndata isn't compressed, or handle it
                    if len(dir_files) != file_count or file_count == 0:
                        return False
                    return True
            except Exception as e:
                logging.error("Exception parsing ndata file: %s", file_path)
                logging.error(str(e))
        return False
860563
def is_binary(filename):
    
    with open(filename, 'rb') as fp:
        data = fp.read(1024)
        if not data:
            return False
        if b'\0' in data:
            return True
        return False
819436
public static boolean isZip(String fName)
  {
    if (Strings.isNullOrEmpty(fName)) {
      return false;
    }
    return fName.endsWith(ZIP_SUFFIX); // Technically a file named `.zip` would be fine
  }
811547
def is_zipfile(filename):
    """"""
    try:
        fpin = open(filename, "rb")
        endrec = _EndRecData(fpin)
        fpin.close()
        if endrec:
            return True                 # file has correct magic number
    except IOError:
        pass
    return False
1354582
def is_valid_filename(filename, return_ext=False):
    """"""
    ext = Path(filename).suffixes

    if len(ext) > 2:
        logg.warn('Your filename has more than two extensions: {}.\n'
                  'Only considering the two last: {}.'.format(ext, ext[-2:]))
        ext = ext[-2:]

    # cases for gzipped/bzipped text files
    if len(ext) == 2 and ext[0][1:] in text_exts and ext[1][1:] in ('gz', 'bz2'):
        return ext[0][1:] if return_ext else True
    elif ext and ext[-1][1:] in avail_exts:
        return ext[-1][1:] if return_ext else True
    elif ''.join(ext) == '.soft.gz':
        return 'soft.gz' if return_ext else True
    elif ''.join(ext) == '.mtx.gz':
        return 'mtx.gz' if return_ext else True
    else:
        if return_ext:
            raise ValueError('"{}" does not end on a valid extension.\n'
                             'Please, provide one of the available extensions.\n{}\n'
                             'Text files with .gz and .bz2 extensions are also supported.'
                             .format(filename, avail_exts))
        else:
            return False
252628
def _is_dir(self, f):
        ''''''
        return self._tar.getmember(f).type == tarfile.DIRTYPE
1258479
def is_file(path):
    """"""
    try:
        return path.expanduser().absolute().is_file()
    except AttributeError:
        return os.path.isfile(os.path.abspath(os.path.expanduser(str(path))))
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
1277671
def is_file(package):
    """"""
    if hasattr(package, "keys"):
        return any(key for key in package.keys() if key in ["file", "path"])

    if os.path.exists(str(package)):
        return True

    for start in SCHEME_LIST:
        if str(package).startswith(start):
            return True

    return False
997342
def __isValidTGZ(self, suffix):
        """"""
        if suffix and isinstance(suffix, string_types):
            if suffix.endswith(".tar.gz") or suffix.endswith(".tgz"):
                return True
        return False
244918
public static function check_filename(): bool
  {

    $args = \func_get_args();
    // Each argument must be a string starting with a letter, and having than one character made of letters, numbers and underscores
    foreach ( $args as $a ){
      if ( !\is_string($a) || (strpos($a, '/') !== false) || (strpos($a, '\\') !== false) ){
        return false;
      }
    }
    return true;
  }
1126036
def check_files_exist(filenames):
    ''''''
    files_not_found = [x for x in filenames if not os.path.exists(x)]
    if len(files_not_found):
        for filename in files_not_found:
            print('File not found: "', filename, '"', sep='', file=sys.stderr)
        raise Error('File(s) not found. Cannot continue')