d;0 UdZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl m Z m Z m Z mZmZmZddlmZddlmZddlmZmZmZeeZdad ed <iad ed <d=dZd>dZd?dZd?dZdZ d?dZ!ej"riZ#d ed<iZ$ded<d@dZ%nd@dZ%d@dZ&dAdZ'dBd Z(d?d!Z)dCd"Z*dDd&Z+Gd'd(Z,Gd)d*Z-Gd+d,Z.dEd.Z/d/d0DZ0dFd2Z1 dGdHd7Z2Gd8d9Z3dId<Z4edS)JzFile wrangling.) annotationsN)CallableDictIterableListOptionalTuple)env) ConfigError) human_sortedisolate_module join_regexstr RELATIVE_DIRzDict[str, str]CANONICAL_FILENAME_CACHEreturnNonecttj}|tjs|tjz}tj|aiadS)z?Set the directory that `relative_filename` will be relative to.N) abs_fileoscurdirendswithseppathnormcaserr) abs_curdirs /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/coverage/files.pyset_relative_directoryrs\ ")$$J   rv & &)"&( 7##J//L "ctS)z=Return the directory that `relative_filename` is relative to.)rr rrelative_directoryr#/s r filenamectj|}|tr|t td}|S)zReturn the relative form of `filename`. The file name will be relative to the current directory when the `set_relative_directory` was called. N)rrr startswithrlen)r$fnorms rrelative_filenamer)4sL G  X & &E  %%0C --../ Or c|tvr|}tj|sytjgt jzD]^}|tj||} tj|}n#t$rd}YnwxYw|r|}n_t|}|t|<t|S)zzReturn a canonical file name for `filename`. An absolute path with no redundant components and normalized case. NF) rrrisabsrsysjoinexists UnicodeErrorr)r$cfrfr.s rcanonical_filenamer2As /// w}}X&&  ch.  <GLLx00#W^^A..FF####"FFF#BEb\\-/ * #H --s+B  BBdctj|\}}|rItjd|ddd}d|d}nd}||ddzS) a7A base for a flat file name to correspond to this file. Useful for writing files about the code where you want all the files in the same directory, but need to differentiate same-named files from different directories. For example, the file a/b/c.py will return 'd_86bbcbe134d28fd2_c_py' sha3_256zUTF-8Nd__r.)ntpathsplithashlibnewencode hexdigestreplace)r$dirnamebasenamefpprefixs r flat_rootnamerE\s X..GX [W^^G%<%< = = G G I I#2# Nb H$$S#.. ..r _ACTUAL_PATH_CACHEzDict[str, List[str]]_ACTUAL_PATH_LIST_CACHErcH|tvr t|Stj|\}}|s|}n|s|}nt |}|t vrt |}n2 tj|}n#t$rg}YnwxYw|t |<tj |}|D])}tj ||kr|}n*tj ||}|t|<|S)z:Get the actual path of `path`, including the correct case.) rFrrr;upper actual_pathrGlistdir Exceptionrr-)rheadtailactpathfilesnormtailr1s rrJrJts9 % % %%d+ +W]]4(( d /jjllGG /GGt$$D.../5Jt,,EE EEE16'-w''--H  7##A&&(22DE3gll4..G#*4 s<B B B c|S)z*The actual path for non-Windows platforms.r"rs rrJrJs r cttjtj|S)z.Return the absolute normalized form of `path`.)rJrrabspathrealpathrSs rrrs. rwrw'7'7'='=>> ? ??r Optional[Tuple[str, str]]cdD]W}||t|z\}}}|r*||z}tj|r||fcSXdS)zSplit a filename into a zipfile / inner name pair. Only return a pair if the zipfile exists. No check is made if the inner name is in the zipfile. )z.zipz.whlz.eggz.pexN) partitionrrrr.)r$extzipbase extensioninnerzipfiles r zip_locationr_su0&&$,$6$6sS]]7J$K$K!E  &mGw~~g&& &~%%% 4r boolcjtj|rdSt|rdSdS)z'Determine if a source file path exists.TF)rrr.r_rSs r source_existsrbs9 w~~dtDt 5r cftjjrtj|}|S)z:Return the string as Python would describe this file name.)r PYBEHAVIORreport_absolute_filesrrrUr$s rpython_reported_filergs' ~+-7??8,, Or cRtj|ptj|S)z)Is `filename` an absolute path on any OS?)r:r+ posixpathrfs risabs_anywhererjs! < ! ! >Y_X%>%>>r patterns Iterable[str] List[str]cg}|pgD]N}|||ds"|t|O|S)aPrepare the file patterns for use in a `GlobMatcher`. If a pattern starts with a wildcard, it is used as a pattern as-is. If it does not start with a wildcard, then it is made absolute with the current directory. If `patterns` is None, an empty list is returned. )*?)appendr&r)rkpreppedps r prep_patternsrts`G ^((q||J'' ( NN8A;; ' ' ' Nr c4eZdZdZddd Zdd Zdd ZddZdS) TreeMatcherzA matcher for files in a tree. Construct with a list of paths, either files or directories. Paths match with the `match` method if they are one of the files, or if they are somewhere in a subtree rooted at one of the directories. unknownpathsrlnamerrrc^t||_d|D|_||_dS)NcLg|]!}tj|"Sr")rrr).0rss r z(TreeMatcher.__init__..s(999abg&&q))999r )r original_pathsrxry)selfrxrys r__init__zTreeMatcher.__init__s2)5e)<)<995999  r c(d|jd|jdS)Nz )ryr~rs r__repr__zTreeMatcher.__repr__s CtyCC4+>CCCCr rmc|jSz4A list of strings for displaying when dumping state.)r~rs rinfozTreeMatcher.infos ""r fpathr`ctj|}|jD]F}||r/||krdS|t |tjkrdSGdS)z1Does `fpath` indicate a file in one of our trees?TF)rrrrxr&r'r)rrrss rmatchzTreeMatcher.matchsr  ''  A"" A::44Q=BF**44ur Nrw)rxrlryrrrrrrrmrrrr`__name__ __module__ __qualname____doc__rrrrr"r rrvrvsw DDDD####      r rvc4eZdZdZddd Zdd Zdd ZddZdS) ModuleMatcherz A matcher for modules in a tree.rw module_namesrlryrrrc<t||_||_dSN)listmodulesry)rrrys rrzModuleMatcher.__init__sL))  r c(d|jd|jdS)Nz>>T\>>>>r rmc|jSr)rrs rrzModuleMatcher.infos |r module_namer`c|sdS|jD]<}||r%||krdS|t|dkrdS=dS)z)z[a-zA-Z0-9_-]+r)z[\[\]]N)r9z\\\g<0>patternc|dd}d|vrd|z}g}d}|t|krtD]v\}}|||}|rX|t d|d||||}nw|t|kd|S) z.Convert a file-path glob pattern into a regex.\rz**/r)posNzFile pattern can't include r) r@r' G2RX_TOKENSrr rqexpandendr-)rpath_rxrrrrs r_glob_to_regexrJsoodC((G ''/G C G  "  GBc**A ;%&LAaD&L&LMMMqxx}}---eegg   G   777  r Frpartialre.Pattern[str]cd}|r|tjz}ttt|}|sd|d}tj||}|S)a{Convert glob patterns to a compiled regex that matches any of them. Slashes are always converted to match either slash or backslash, for Windows support, even when running elsewhere. If the pattern has no slash or backslash, then it is interpreted as matching a file name anywhere it appears in the tree. Otherwise, the glob pattern must match the whole file path. If `partial` is true, then the pattern will match if the target string starts with the pattern. Otherwise, it must match the entire string. Returns: a compiled regex object. Use the .match method to compare target strings. rz(?:z)\Z)flags)r IGNORECASErmaprr)rkrrrrcompileds rrr^sb* E  C11 2 2B  B^^^z"E***H Or c<eZdZdZ ddd Zdd ZddZefddZdS) PathAliasesaA collection of aliases for paths. When combining data files from remote machines, often the paths to source code are different, for example, due to OS differences, or because of serialized checkouts on continuous integration machines. A `PathAliases` object tracks a list of pattern/result pairs, and can map a path through those aliases to produce a unified path. NFdebugfnOptional[Callable[[str], None]]relativer`rrcDg|_|pd|_||_d|_dS)NcdS)Nrr")msgs rz&PathAliases.__init__..sqr F)aliasesrrpprinted)rrrs rrzPathAliases.__init__s- @B 1==    r c |d|jd|jD])\}}}|d|d|d|j*dS)z;Dump the important parts of the PathAliases, for debugging.zAliases (relative=z):z Rule:  -> using regex N)rrrr)roriginal_patternregexresults rpprintzPathAliases.pprints| ;$-;;;<<'KBW3X3X ,"7++ ,, # { "Gy4NNN[[ u%% 2 -uf=>>>>>r rr.Callable[[str], bool]c  |js|d|_|jD]!\}}}||}|r||d|}|t |t |}|jst|}|dot|dk}|dr |s |dd}||s#| d|d|d|d d z| d |d |d |dd|z|cS#|jrt|stj d|} t| dkr| d} d|  dtj| d} | tj}t! fd|jDsd| d d |d| |j tj| |f|||S| d|d|S)aMap `path` through the aliases. `path` is checked against all of the patterns. The first pattern to match is used to replace the root of the path with the result root. Only one pattern is ever used. If no patterns match, `path` is returned unchanged. The separator style in the result is made to match that of the result in the alias. `exists` is a function to determine if the resulting path actually exists. Returns the mapped path. If a mapping has happened, this is a canonical path. If no mapping has happened, it is the original value of `path` unchanged. Tr)z./z.\NzRule z changed z to rzwhich doesn't exist, continuingz Matched path z to rule rz, z producing z[/\\]rz*/z ^(.*[\\/])?rc3,K|]\}}}|kVdSrr")r|rsr8rs r z"PathAliases.map..s-DDGAq!1<DDDDDDr zGenerating rule: r)r.zNo rules match, path z is unchanged)rrrrr@rrr2r&r'rrjrr;escaperanyrqrr) rrr.rrrrr= dot_startpartsdir1 regex_patrs @rrzPathAliases.maps&} ! KKMMM DM/3|   + eV D!!A ll1Q400kk#d))S[[99}2,S11C"--m<<PVq >>-00""abb'Cvc{{LLQ 0QQTQQQQQ9: YDYY5EYYVYYY((() % , = 9!5!5 9HXt,,E5zzA~~Qx%t++A29T??AAA  *"&**DDDDt|DDDDD9LL_G__6__R[__L''"*Y2G2G(PQQQ88D8888 BTBBBCCC r )NF)rrrr`rrrr)rrrrrr)rrr.rrr) rrrrrrrrbrr"r rrr}s  48     eeee %?%?%?%?N=J@@@@@@@r rrAinclude_namespace_packagesc#Kttj|D]W\}\}}}|s|dkr d|vr|dd=|D]9}tjd|r"tj||V:XdS)a|Yield all of the importable Python files in `dirname`, recursively. To be importable, the files have to be in a directory with a __init__.py, except for `dirname` itself, which isn't required to have one. The assumption is that `dirname` was specified directly, so the user knows best, but sub-directories are checked for a __init__.py to be sure we only find the importable files. If `include_namespace_packages` is True, then the check for __init__.py files is skipped. Files with strange characters are skipped, since they couldn't have been imported, and are probably editor side-files. rz __init__.pyNz^[^.#~!$@%^&*()+=,]+\.pyw?$) enumeraterwalkrrrr-)rAridirpathdirnames filenamesr$s rfind_python_filesrs .7rww7G7G-H-H 6 6) )GXy) 1uui77QQQK! 6 6Hx6AA 6gll7H55555  6 6 6r rr)r$rrr)rrrr)r$rrrW)rrrr`)r$rrr`)rkrlrrm)rrrr)rrrr)FF)rkrlrr`rr`rr)rArrr`rrl)5r __future__rr<r:ros.pathrirr,typingrrrrrr coverager coverage.exceptionsr coverage.miscr r rr__annotations__rrr#r)r2MAX_FLATrErrFrGrJrr_rbrgrjrtrvrrrrrrrrr"r rrs""""""  BBBBBBBBBBBBBBBB++++++BBBBBBBBBB^B +-----""""$    ....2 ////&;()+++++466666B @@@@        ???? $        F:00000000&5 ",#>CCCCCCCCL6666@r