(paths: Iterable[str], verbose: bool)
Generate a list of scannable files from a list of filepaths.
Generate a list of scannable files from a list of filepaths.
Generate a list of scannable files from a list of filepaths .
def generate_files_from_paths(paths: Iterable[str], verbose: bool) -> Iterable[File]:
    """Generate a list of scannable files from a list of filepaths."""
    for path in paths:
        if os.path.isdir(path) or not os.path.exists(path):
            continue

        file_size = os.path.getsize(path)
        if file_size > MAX_FILE_SIZE:
            if verbose:
                click.echo(f"ignoring file over 1MB: {path}")
            continue
        if path.endswith(BINARY_FILE_EXTENSIONS):
            if verbose:
                click.echo(f"ignoring binary file extension: {path}")
            continue
        with open(path, "r") as file:
            try:
                content = file.read()
                if content:
                    yield File(content, file.name, file_size)
            except UnicodeDecodeError:
                pass
def generate_files_from_paths ( paths : Iterable [ str ] , verbose : bool ) -> Iterable [ File ] : for path in paths : if os . path . isdir ( path ) or not os . path . exists ( path ) : continue file_size = os . path . getsize ( path ) if file_size > MAX_FILE_SIZE : if verbose : click . echo ( f"ignoring file over 1MB: {path}" ) continue if path . endswith ( BINARY_FILE_EXTENSIONS ) : if verbose : click . echo ( f"ignoring binary file extension: {path}" ) continue with open ( path , "r" ) as file : try : content = file . read ( ) if content : yield File ( content , file . name , file_size ) except UnicodeDecodeError : pass