_n&ǡ8dZddlmZddlZddlZddlZddlmZm Z m Z m Z m Z ddl mZddlmZmZddlmZmZmZddlmZmZmZdd lmZdd lmZmZdd lm Z dd l!m"Z"m#Z#m$Z$m%Z%e rdd l m&Z&eeZddZ'ddZ(ddZ)ddZ*ddZ+Gdde Z,dS) z'Python source expertise for coverage.py) annotationsN)DictIterableOptionalSet TYPE_CHECKING)env)CoverageExceptionNoSource)canonical_filenamerelative_filename zip_location) expensiveisolate_module join_regex) PythonParser)source_token_linessource_encoding) FileReporter)TArcTLineNoTMorfTSourceTokenLines)Coveragefilenamestrreturnbytesct|d5}|}dddn #1swxYwY|ddddS)zFRead the Python source text from `filename`. Returns bytes. rbNs   )openreadreplace)rfsources /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/coverage/python.pyread_python_sourcer)s h   >>'5 ) ) 1 1% ? ??s 266ctj|\}}|dkrtjrddg}n|g}|D]J}||z}tj|rt |}n't|}|nKtd|d| dd}| t|d}|r|d d kr|d z }|S) z#Return the source code, as unicode..pyz.pywNzNo source for code: 'z'.  r% ) ospathsplitextr WINDOWSexistsr) get_zip_bytesr r%decoder)rbaseextexts try_filename source_bytesr's r(get_python_sourcer<)s  **ID# e|| |vu = =cz 7>>, ' ' -l;;L E%\22  # E $;x;;;<<< ''t44L  !>!> J JF&*$$$ MOptional[bytes]ct|}|[|\}} tj|}n#tj$rYdSwxYw ||}n#t $rYdSwxYw|SdS)zGet data from `filename` if it is a zip file path. Returns the bytestring data read from the zip file, or None if no zip file could be found or `filename` isn't in it. The data returned will be an empty string if the file is empty. N)r zipimport zipimporterZipImportErrorget_dataOSError)r zipfile_innerzipfileinnerzidatas r(r5r5Ls!**M & &w//BB'   44  ;;u%%DD   44  4s -AAA A('A(c|dr|S|dr_|dd}tj|r|Stjr&|dz}tj|r|S|S|S)zReturn the source filename for `filename`. Given a file name being traced, return the best guess as to the source file to attribute it to. r+)z.pycz.pyoNr.w)endswithr0r1r4r r3)r py_filename pyw_filenames r(source_for_filerOcs   + , , ssm 7>>+ & &   ; $&,Lw~~l++ $## Or=morfrct|dr|jr|j}n/t|tjrt d|d|}t |}|S)z6Get the source filename for the module-or-file `morf`.__file__zModule z has no file)hasattrrR isinstancetypes ModuleTyper rO)rPrs r(source_for_morfrWsntZ  T]= D%* + + <$ < < <===x((H Or=ceZdZdZd(d)fd Zd*d Zd*d Zed+dZd,dZ d,dZ d-dZ d.dZ e d,dZe d/dZe d0dZ d(d1d"Zd*d#Zd2d%Zd3d'ZxZS)4PythonFileReporterz!Report support for a Python file.NrPrcoverageOptional[Coverage]rNonec(||_t|}|}d}|j|jjjrd}|rt |}t |t|dro|j dtj }tj |dr|tj dzz }|dz }nt|}||_d|_d|_d|_dS)NTF__name__.z __init__.__init__r+)rZrWconfigrelative_filesr superr`rSr^r%r0sepr1basename startswithr relname_source_parser _excluded)selfrPrZrfname canonicalizename __class__s r(r`zPythonFileReporter.__init__s  "4(( = $}#2 %$  1&x00E  4 $ $ /=((bf55Dw))44[AA ,++ EMDD$X..D &* /3 r=rcd|jdS)Nz)rrks r(__repr__zPythonFileReporter.__repr__s8dm8888r=c|jSN)rgrrs r(r z$PythonFileReporter.relative_filenames |r=rc|jJ|jLt|j|jd|_|j|jS)z&Lazily create a :class:`PythonParser`.Nexclude)rrw)rZrirr_exclude_regex parse_sourcerrs r(parserzPythonFileReporter.parsersf}((( < ' 44Y??DL L % % ' ' '|r= Set[TLineNo]c|jjSz2Return the line numbers of statements in the file.)rz statementsrrs r(lineszPythonFileReporter.liness {%%r=c|jjSr})rzexcludedrrs r(excluded_linesz!PythonFileReporter.excluded_liness {##r=rIterable[TLineNo]c6|j|Sru)rztranslate_lines)rkrs r(rz"PythonFileReporter.translate_liness{**5111r=arcsIterable[TArc] Set[TArc]c6|j|Sru)rztranslate_arcs)rkrs r(rz!PythonFileReporter.translate_arcss{))$///r=c|jJ|jt|jjjt|jjj}|Sru)rZrzlines_matchingrra partial_listpartial_always_list)rk no_branchs r(no_branch_linesz"PythonFileReporter.no_branch_linessU}(((K.. t}+8 9 9 t}+? @ @  r=c4|jSru)rzrrrs r(rzPythonFileReporter.arcss{!!!r=Dict[TLineNo, int]c4|jSru)rz exit_countsrrs r(rzPythonFileReporter.exit_countss{&&(((r=startrend executed_arcsOptional[Iterable[TArc]]c:|j|||Sru)rzmissing_arc_description)rkrrrs r(rz*PythonFileReporter.missing_arc_descriptions {225#}MMMr=cP|jt|j|_|jSru)rhr<rrrs r(r'zPythonFileReporter.sources# < ,T];;DL|r=boolctj|j\}}|drdS|sdSdS)zDoes it seem like this file should contain Python? This is used to decide if a file reported as part of the execution of a program was really likely to have contained Python in the first place. r+TF)r0r1r2rrf)rk_r8s r(should_be_pythonz#PythonFileReporter.should_be_pythonsL!!$-003 >>%  4 4ur=rcDt|Sru)rr'rrs r(rz%PythonFileReporter.source_token_liness!$++--000r=ru)rPrrZr[rr\)rr)rr)rr{)rrrr{)rrrr)rr)rr)rrrrrrrr)rr)rr)r^ __module__ __qualname____doc__r`rsr propertyrzrrrrrrrrrr'rr __classcell__)ros@r(rYrYs++69999   X &&&&$$$$22220000Y"""Y")))Y)37 NNNNN (11111111r=rY)rrrr)rrrr)rrrr>)rPrrr)-r __future__ros.pathr0rUr@typingrrrrrrZr coverage.exceptionsr r coverage.filesr r r coverage.miscrrrcoverage.parserrcoverage.phystokensrrcoverage.pluginrcoverage.typesrrrrrr)r<r5rOrWrYr=r(rs.-"""""" ??????????????;;;;;;;;NNNNNNNNNN??????????((((((CCCCCCCC((((((BBBBBBBBBBBB"!!!!!!^B @ @ @ @    F.:    q1q1q1q1q1q1q1q1q1q1r=