def get_files(path:PathOrStr, extensions:Collection[str]=None, recurse:bool=False,
              include:Optional[Collection[str]]=None)->FilePathList:
    "Return list of files in `path` that have a suffix in `extensions`; optionally `recurse`."
    if recurse:
        res = []
        for i,(p,d,f) in enumerate(os.walk(path)):
            # skip hidden dirs
            if include is not None and i==0:  d[:] = [o for o in d if o in include]
            else:                             d[:] = [o for o in d if not o.startswith('.')]
            res += _get_files(path, p, f, extensions)
        return res
    else:
        f = [o.name for o in os.scandir(path) if o.is_file()]
        return _get_files(path, path, f, extensions)
def get_files ( path : PathOrStr , extensions : Collection [ str ] = None , recurse : bool = False , include : Optional [ Collection [ str ] ] = None ) -> FilePathList : if recurse : res = [ ] for i , ( p , d , f ) in enumerate ( os . walk ( path ) ) : if include is not None and i == 0 : d [ : ] = [ o for o in d if o in include ] else : d [ : ] = [ o for o in d if not o . startswith ( '.' ) ] res += _get_files ( path , p , f , extensions ) return res else : f = [ o . name for o in os . scandir ( path ) if o . is_file ( ) ] return _get_files ( path , path , f , extensions )
Return list of files in `path` that have a suffix in `extensions`; optionally `recurse`.