?@"^UdZddlmZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZmZddlmZmZmZmZmZmZmZmZmZddlmZddlmZmZddlm Z m!Z!dd l"m#Z#m$Z$m%Z%dd l"m&Z&m'Z'm(Z(dd l)m*Z*dd l+m,Z,m-Z-dd l.m/Z/m0Z0m1Z1m2Z2er ddl3m4Z4ddl5m6Z6eeeee e e gZ7de8d<ej9rL ddl:Z:e7;e:n #e<$rYnwxYw ddl=Z=e7;e=n #e<$rYnwxYwd-d.dZ>d/dZ?d0d Z@d0d!ZAd1d$ZBd2d(ZCd2d)ZDd2d*ZEGd+d,ZFdS)3z=Determining whether files are being measured/reported or not.) annotationsN) FrameType ModuleType) castAnyIterableListOptionalSetTupleType TYPE_CHECKING)env)FileDispositiondisposition_init)CoverageException PluginError) TreeMatcher GlobMatcher ModuleMatcher) prep_patternsfind_python_filescanonical_filename)sys_modules_saved)source_for_filesource_for_morf)TFileDispositionTMorfTWarnFn TDebugCtl)CoverageConfig)PluginszList[ModuleType]modules_we_happen_to_haveFmorfr directoryboolreturnstrctt|}|ds|r%tj|d}|S)zReturn the canonical path of the module or file `morf`. If the module is a package, then return its directory. If it is a module, then return its file, unless `directory` is True, in which case return its enclosing directory. z __init__.pyr)rrendswithospathsplit)r$r% morf_paths /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/coverage/inorout.pycanonical_pathr0;sT#?4#8#899I-((0I0GMM),,Q/ filenameframeOptional[FrameType]cj||jni}|dd}t|tr|dkr|S|dd}dD]C}t ||rt ||}n$t|tr |dkr|cSDt j|}||S|S)aGet the name of the module for a filename and frame. For configurability's sake, we allow __main__ modules to be matched by their importable name. If loaded via runpy (aka -m), we can usually recover the "original" full dotted module name, otherwise, we resort to interpreting the file name to get the module's name. In the case that the module name can't be determined, None is returned. N__name____main__ __loader__)fullnamename) f_globalsget isinstancer(hasattrgetattrinspect getmodulename)r2r3module_globals dunder_nameloaderattrnamer9 inspectednames r/name_for_modulerGIs).(9U__rN%))*d;;K+s## z(A(A    d 3 3F( 68 $ $ vx00HH  h $ $ Z)?)?OOO)(33M r1modrcHt|dot|ddduS)z5Is the module object `mod` a PEP420 namespace module?__path____file__N)r>r?)rHs r/module_is_namespacerLos( 3 # # NZ(F(F$(NNr1cjt|dd}|dStj|S)z8Does the module object `mod` have an existing __file__ ?rKNF)r?r+r,exists)rH mod__file__s r/module_has_filerPts2#z400Ku 7>>+ & &&r1 modulenameTuple[Optional[str], List[str]]cd}g} tj|}||j}t |jpd}n#t $rYnwxYw||fS)zFind the file and search path for `modulename`. Returns: filename: The filename of the module, or None. path: A list (possibly empty) of directories to find submodules in. N) importlibutil find_specoriginlistsubmodule_search_locations Exception)rQr2r,specs r/file_and_path_for_moduler]|s{H D?~'' 33  {H7=2>>D      T>sA AApathsSet[str]NonectD]6}t|dr$|t|d7dS)z;Add paths where the stdlib can be found to the set `paths`.rKTr%N)r#r>addr0)r^ms r/add_stdlib_pathsresO'99 1j ! ! 9 IInQ$777 8 8 899r1cttj}|D]a}|dkrdn|}tj|dvr4tj|}dD]}|||bdS)z:Add locations for third-party packages to the set `paths`.pypy pypy_posix_)platlibpurelibscriptsN)set sysconfigget_scheme_namesr+r:r- get_pathsrc)r^ scheme_namesscheme better_scheme config_paths path_names r/add_third_party_pathsrvsy13344L33(.&(8(8 f 7m))#.. . .$.v66L> 3 3  ,y12222 33r1cttd}||tjr5|t j|ddSdS)zAAdd paths where coverage.py code can be found to the set `paths`.TrbtestsN)r0rKrcrTESTINGr+r,join)r^ cover_paths r/add_coverage_pathsr|sbD999J IIj {5 "',,z7334444455r1cleZdZdZd#d Zd$d%dZd&dZd'dZd'dZd'dZ d(dZ d)dZ d*dZ d+d Z d,d"Zd S)-InOrOutz0Machinery for determining what files to measure.configr!warnrdebugOptional[TDebugCtl]include_namespace_packagesr&r'r`c v |_|_|_g_g_j|j|jpgD]c}t j|r(j t|Ij |djdd_ t|j _t|j_t#_|jst)jt#_t-jt#_t1jd$fd }|dddt4jDzd_d_d_dx__jsjrg}jr7tAjd _| d jjr7tCjd _| d j|d d|zn4jr-tAjd_|djjr-tEjd_|djjr-tEjd_|djtAjd_#|dj#tAjd_$|dj$t#_%tM5jD]} tO|\} } |d|d| n(#tP$r} |d|d| Yd} ~ Gd} ~ wwxYw| r`j$)| rE|d|d| j%*tWtY| | D]G} j$)| r+|d|d | j%*| H dddn #1swxYwYjD]D}j$)|r(|d!|j%*|EtAj%d"_-|d#j-t\_/dS)%Nmsgr(r'r`cNjrj|dSdSN)rwrite)rselfs r/_debugz InOrOut.__init__.._debugs3z &   %%%%% & &r1z sys.path:c3 K|] }d|V dS)z NrT).0ps r/ z#InOrOut.__init__..s($D$Da\a\\$D$D$D$D$D$Dr1sourceztrees source_pkgszmodules zSource matching against z and pylibzPython stdlib matching: includezInclude matching: omitzOmit matching: coveragezCoverage code matching: thirdzThird-party lib matching: zImported source package z as zCouldn't import source package z: z"Source in third-party: source_pkg z at zSource in third-party: z path directory at z(Source in third-party: source directory source_in_thirdz Source in third-party matching: )rr(r'r`)0rrrrrextendr+r,isdirappendrsource_pkgs_unmatchedr run_includerrun_omitrrm pylib_paths cover_pylibre cover_pathsr| third_pathsrvrzsys source_matchsource_pkgs_match pylib_match include_match omit_matchrrr cover_match third_matchsource_in_third_pathsrr]rmatchrcr0rsource_in_third_matchr disp_class) rrrrrsrcragainstpkgmodfiler,excpathdirs ` r/__init__zInOrOut.__init__s<  *D'!# &(  2333=&B - -Cw}}S!! - ""#5c#:#:;;;; '',,,,%)%5aaa%8"$V%788 !&/22 &)UU! / T- . . .&)UU4+,,,&)UUd./// & & & & & & {RWW$D$D38$D$D$DDDDEEE!!%/33T_ ; H$* HG{ ?$/ X$F$F!=(9==>>> F)6t7G)W)W&D$*@DDEEE F- W0E0EE F F F F H#.t/?#I#I F$2BFFGGG < @!,T\9!E!ED  F>(:>> ? ? ? 9 :)$)V<$*:>>???&t'7AA@D,<@@AAA &)UU"   D D' D D$.nope6sDJ DKKr1?? ?   /Meo.A.A*.M.MK 5*;77$5->-I-I#-N-N57++,=>>Drw//9999$5 @4>?? ?   y ) ) 84677 7   s # # 7 4566 6&x00 "+l/ - -F+  $00;; *39K0!%DJ'2D$">>@@4811/A'779900,E+   $: )++ Y{YYUWYYZZZ+0(  DJ#,D ( #' !bfbbI_bbb001EuMMF #T6""" s A.F<t||}|js|jrd}d}|jrF|j|r&d}||jvr|j|nd|d}|s#|jr|j|rd}|s|dzS|j|r|j|sdSn|jr|j|sdSn[|j |rd S|j r|j |rd S|j|rd S|j r|j |rd S | d n#t$rYdSwxYwdS)zCheck a file name against the include, omit, etc, rules. Returns a string or None. String means, don't trace, and is the reason why. None means no reason found to not trace. rFTzmodule  zfalls outside the --source specz#inside --source, but is third-partyz!falls outside the --include treeszis part of coverage.pyzis in the stdlibzis a third-party modulezis inside an --omit patternzutf-8znon-encodable filenameN)rGrrrrremoverrrrrrencodeUnicodeEncodeError)rr2r3rQextraoks r/rzInOrOut.check_include_omit_etcs%Xu55  ! 1 6! 1EB% 6)// ;;6B!T%???299*EEE5j555E $+ $**844B A@@@%%h// =8R8X8XYa8b8b =<<   1%++H55 ;:: ; %%h// 0// *D$4$:$:8$D$D *))%%h// 100 ? 1t44X>> 100 , OOG $ $ $ $! , , ,+++ ,ts6F FFcf|jr'|js|jr|dddSdSdS)z)Warn if there are settings that conflict.z,--include is ignored because --source is setzinclude-ignoredslugN)rrrr)rs r/warn_conflicting_settingsz!InOrOut.warn_conflicting_settingssY < b{ bd. b HO` aaaaa b b b br1c|js|js|jr't}t t jD]}t|dd}|||vrtt|dddkr>| |}|j r[|j r2d|}| |d|||jrR|jd r8|jd |j|jdSdS) zCWarn if files have already been imported that we will be measuring.rKNrJrTz/Already imported a file that will be measured: zalready-importedrrz+Didn't trace already imported file {!r}: {})rrrrmrYrmodulesvaluesr?lenrrrrrcrshouldrformatrr)rwarnedrHr2rrs r/warn_already_imported_filesz#InOrOut.warn_already_imported_filessj < 4; $*: UUFCK..0011  "3 D99#v%%wsJ3344q88((22,: VHVVCIIc(:I;;;JJx((((ZDJ$5$5g$>$>J$$ELL 2DK1    r1cD|jD]}||dS)zCWarn about source packages that were of interest, but never traced.N)r_warn_about_unmeasured_code)rrs r/warn_unimported_sourcezInOrOut.warn_unimported_sources5- 2 2C  , ,S 1 1 1 1 2 2r1rc6tj|}||d|dddSt |rdSt |s|d|dddSd|d}||d dS) z}Warn about a package or module that we never traced. `pkg` is a string, the name of the package or module. NzModule z was never imported.zmodule-not-importedrz has no Python source.zmodule-not-pythonz* was previously imported, but not measuredzmodule-not-measured)rrr<rrLrP)rrrHrs r/rz#InOrOut._warn_about_unmeasured_codes kooc"" ; II9999@UI V V V F s # #  Fs##  II;;;;BUI V V V F HGGG #1 22222r1#Iterable[Tuple[str, Optional[str]]]c#K|jD]}|tjvsttj|s0t t t tj|j}|t|Ed{V|j D]}||Ed{VdS)zFind files in the areas of interest that might be untraced. Yields pairs: file path, and responsible plug-in name. N) rrrrPrrr(rK_find_executable_filesr0r)rrpkg_filers r/find_possibly_unexecuted_filesz&InOrOut.find_possibly_unexecuted_files s # M MC3;&&#CK$455'&tCS1A1J'K'KLLH22>(3K3KLL L L L L L L L L; 8 8C22377 7 7 7 7 7 7 7 7 8 8r1src_dirIterable[Tuple[str, str]]c#nK|jjD]%}||D] }||jfV&dS)z&Get executable files from the plugins.N)rrfind_executable_filesr)rrrx_files r/_find_plugin_fileszInOrOut._find_plugin_filess]l/ ; ;F 66w?? ; ;f:::::: ; ; ;r1c#Kdt||jD}||}tj||D]<\}}t |}|jr|j|r6||fV=dS)a(Find executable files in `src_dir`. Search for files in `src_dir` that can be executed because they are probably importable. Don't include ones that have been omitted by the configuration. Yield the file path, and the plugin name that handles the file. c3K|]}|dfV dSrrT)rpy_files r/rz1InOrOut._find_executable_files..,s7  'WdO      r1N)rrr itertoolschainrrr)rrpy_files plugin_files file_pathrs r/rzInOrOut._find_executable_files"s  gt'F G G   ..w77 &/oh &M&M ) ) "I{*955I 4?#8#8#C#C [( ( ( ( (  ) )r1Iterable[Tuple[str, Any]]cd|jfd|jfd|jfd|jfg}gd}|D]B}t ||}|r|}nd}|||fC|S)z^Our information for Coverage.sys_info. Returns a list of (key, value) pairs. coverage_paths stdlib_pathsthird_party_pathssource_in_third_party_paths)rrrrrrrrz-none-)rrrrr?infor)rr matcher_names matcher_namematcher matcher_infos r/sys_infozInOrOut.sys_info:s t/ 0 T- . $"2 3 *D,F G     * 6 6LdL11G (&||~~ ' KK|4 5 5 5 5 r1) rr!rrrrrr&r'r`r)r2r(r3r4r'r)r2r(r3r4r'r)r'r`)rr(r'r`)r'r)rr(r'r)rr(r'r)r'r)r6 __module__ __qualname____doc__rrrrrrrrrrr rTr1r/r~r~s::qBqBqBqBf_____B;;;;zbbbb @2222 33334 8 8 8 8;;;; ))))0r1r~)F)r$rr%r&r'r()r2r(r3r4r'r()rHrr'r&)rQr(r'rR)r^r_r'r`)Gr  __future__rimportlib.utilrUr@rr+platformrerrnrtypesrrtypingrrrr r r r r rrrcoverage.dispositionrrcoverage.exceptionsrrcoverage.filesrrrrrr coverage.miscrcoverage.pythonrrcoverage.typesrrrr coverage.configr!coverage.plugin_supportr"r#__annotations__PYPY _structseqr ImportError_pypy_irc_topicr0rGrLrPr]rervr|r~rTr1r/r!sDCC""""""  ''''''''BBBBBBBB>>>>>>>>BBBBBBBBBBOOOOOOOOOO++++++<<<<<<<<FFFFFFFFFFFF0......////// YHb)Y/8   !((4444       !((9999           ####LOOOO ''''* 9 9 9 9 3 3 3 35555``````````s$4CCCC44C<;C<