bgshddlmZddlmZmZmZmZddlmZddl m Z m Z m Z dZ GddZdS) )Path)CallableIterableIteratorList)PermissionMissing)is_python_moduleis_python_package is_virtualenv)z.gitz.toxz .mypy_cachez .pytest_cachez.venv __pycache__ node_modulesc@eZdZdZdddedeefdZdeefdZ d ede fd Z d eedeefd Z d ede efdZedeefdZedeefdZedeefdZedeefdZdS) FileFinderad This class is responsible for taking a combination of command-line arguments and configuration loaded from a profile to discover all files and modules which should be inspected. Individual tools can be told to ignore certain files, so the job of this class is basically to know which files to pass to which tools to be inspected. N)exclusion_filtersprovided_pathsrcg|_g|_dtgt|pgz|_|D]}|st ||}|r|j || r|j |dS)a? :param provided_paths: A list of Path objects to search for files and modules - can be either directories or files :param exclusion_filters: An optional list of filters. All paths will be checked against this list - if any return True, the path is excluded. cF|o |jtvSN)is_dirname_SKIP_DIRECTORIES)_paths b/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/prospector/finder.pyz%FileFinder.__init__.. s%,,..LUZ;L-LN) _provided_files_provided_dirsr list_exclusion_filtersexistsFileNotFoundErrorabsoluteis_fileappendr)selfrrpaths r__init__zFileFinder.__init__s "  M L #  "(b ) ) #* # 1 1D;;== .'---==??D||~~ 2$++D111{{}} 1#**4000 1 1rreturnct}|jD]}|||jD]}||jt |Sr)setraddpython_modulesparentsorted)r%pathsr&modules r make_syspathzFileFinder.make_syspath/sc'  D IIdOOOO) % %F IIfm $ $ $ $e}}rr&cDtfd|jDS)Nc3.K|]}|VdSr).0filtr&s r z)FileFinder.is_excluded..8s+BB$44::BBBBBBr)anyr)r%r&s `r is_excludedzFileFinder.is_excluded7s)BBBB$*ABBBBBBrr/c fd|DS)Nc>g|]}||Sr4)r9)r5r&r%s r z&FileFinder._filter..;s,EEEd.>.>t.D.DEEEErr4)r%r/s` r_filterzFileFinder._filter:sEEEEEEEEr directoryc#K||s|V|D]L}||r|r||Ed{VH|VMdSr)r9iterdirr_walk)r%r>r&s rrAzFileFinder._walk=s ** OOO%%''  D%% {{}} ::d++++++++++   rct}|jD]}|||jD]C}||D]+}|r||,D||S)z List every individual file found from the given configuration. This method is useful for tools which require an explicit list of files to check. )r*rr+ directoriesrAr#r=)r%filesr&r>s rrDzFileFinder.filesIs(  D IIdOOOO) $ $I 9-- $ $<<>>$IIdOOO $||E"""rcJ|d|jDS) Lists every directory found in the given configuration which is a python module (that is, contains an `__init__.py` file). This method is useful for passing to tools which will do their own discovery of python files. c38K|]}t||VdSr)r )r5ds rr7z-FileFinder.python_packages..cs0PP!;LQ;O;OPAPPPPPPr)r=rCr%s rpython_packageszFileFinder.python_packages[s(||PPt'7PPPPPPrcJ|d|jDS)rFc38K|]}t||VdSr)r )r5fs rr7z,FileFinder.python_modules..ms0II!5Ea5H5HIAIIIIIIr)r=rDrIs rr,zFileFinder.python_moduleses'||IItzIIIIIIrcNt}|jD]{}|| ||D]+}|r||,Z#t $r}t ||d}~wwxYw||S)z Lists every directory found from the given configuration, regardless of its contents. This method is useful for passing to tools which will do their own discovery of python files. N)r*rr+rArPermissionErrorrr=)r%dirsr>objerrs rrCzFileFinder.directoriesosuu, 6 6I HHY    6::i00&&Czz||& &# 6 6 6',,#5 6||D!!!sAA00 B:B  B)__name__ __module__ __qualname____doc__rrrr'rr1boolr9r=rrApropertyrDrJr,rCr4rrrr sW[1111(AS11116d4jCCCCCCFXd^FT FFFF t     #tDz###X#"QdQQQXQJT JJJXJ"T$Z"""X"""rrN)pathlibrtypingrrrrprospector.exceptionsrprospector.pathutilsr r r rrr4rrr]s555555555555333333SSSSSSSSSSlv"v"v"v"v"v"v"v"v"v"r