L i1"6dZddlmZddlZddlZddlZddlmZddl m Z ddl m Z ddl mZmZddlmZmZmZdd lmZmZdd lmZdd lmZmZdd lmZmZdd lm Z ddl!m"Z"m#Z#m$Z$m%Z%e rddl m&Z&eeZe'Z'ddZ(ddZ)ddZ*ddZ+ddZ,GddeZ-y)z'Python source expertise for coverage.py) annotationsN)Iterable) TYPE_CHECKING)env)CoverageExceptionNoSource)canonical_filenamerelative_filename zip_location)isolate_module join_regex) PythonParser)source_encodingsource_token_lines) CodeRegion FileReporter) code_regions)TArcTLineNoTMorfTSourceTokenLines)Coveragect|d5}|j}dddjddjddS#1swY+xYw)zFRead the Python source text from `filename`. Returns bytes. rbNs   )openreadreplace)filenamefsources U/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/coverage/python.pyread_python_sourcer$!sP h  >>'5 ) 1 1% ??s AActjj|\}}|dk(rtjrddg}n|g}|D]B}||z}tjj |r t |}n"t|}|Bntd|dd|jdd}|jt|d }|r |d d k7r|d z }|S) z#Return the source code, as unicode..pyz.pywzNo source for code: 'z'.z no-source)slug  r ) ospathsplitextrWINDOWSexistsr$ get_zip_bytesrrdecoder)r baseextexts try_filename source_bytesr"s r#get_python_sourcer8-s  *ID# e| vu Ocz 77>>, '-l;L %\2  #  O.xj;+NN ''t4L  !> JF&*$$ Mct|}|/|\}} tj|} |j |}|Sy#tj$rYywxYw#t $rYywxYw)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#r1r1Ps|!*M & &&w/B ;;u%D ''    s >AAA A#"A#c |jdr|S|jdr^|dd}tjj|r|Stj r&|dz}tjj|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)endswithr,r-r0rr/)r py_filename pyw_filenames r#source_for_filerJgs{   + ,sm 77>>+ &  ;;&,Lww~~l+## Or9ct|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)hasattrrL isinstancetypes ModuleTyperrJ)morfr s r#source_for_morfrRsUtZ T]]== D%** + '$| <==x(H Or9ceZdZdZddfd ZddZddZeddZddZ ddZ ddZ dd Z dd Z dd Zdd Zdd Z d ddZd dZddZd!dZd"dZd#dZd$dZxZS)%PythonFileReporterz!Report support for a Python file.c||_t|}|}d}|j"|jjjrd}|r t |}t ||t|drt|jjdtj}tjj|jdr|tjdzz }|dz }n t|}||_d|_d|_d|_y)NTF__name__.z __init__.__init__r&)coveragerRconfigrelative_filesr superrXrMrVrr,sepr-basename startswithr relname_source_parser _excluded)selfrQrYr fname canonicalizename __class__s r#rXzPythonFileReporter.__init__s  "4( == $}}##22$ &x0E  4 $==((bff5Dww)44[A++ EMD$X.D #' ,0 r9c"d|jdS)Nz)r rds r#__repr__zPythonFileReporter.__repr__s%dmm%6a88r9c|jSN)r`rks r#r z$PythonFileReporter.relative_filenames ||r9c|jJ|jOt|j|jj d|_|jj |jS)z&Lazily create a :class:`PythonParser`.exclude)r rp)rYrbrr _exclude_regex parse_sourcerks r#parserzPythonFileReporter.parsers_}}((( << ' 44Y?DL LL % % '||r9c.|jjSz2Return the line numbers of statements in the file.)rs statementsrks r#lineszPythonFileReporter.liness{{%%%r9c.|jjS)z>A map of line numbers to first-line in a multi-line statement.)rs multiline_maprks r#ryz PythonFileReporter.multiline_maps{{(((r9c.|jjSru)rsexcludedrks r#excluded_linesz!PythonFileReporter.excluded_liness{{###r9c8|jj|Srn)rstranslate_lines)rdrws r#r~z"PythonFileReporter.translate_liness{{**511r9c8|jj|Srn)rstranslate_arcs)rdarcss r#rz!PythonFileReporter.translate_arcss{{))$//r9c|jJ|jjt|jjj |jjj z}|Srn)rYrslines_matchingr rZ partial_listpartial_always_list)rd no_branchs r#no_branch_linesz"PythonFileReporter.no_branch_liness[}}(((KK.. t}}++884==;O;O;c;cc d r9c6|jjSrn)rsrrks r#rzPythonFileReporter.arcss{{!!r9c6|jjSrn)rs exit_countsrks r#rzPythonFileReporter.exit_countss{{&&((r9c:|jj||Srn)rsmissing_arc_description)rdstartend executed_arcss r#rz*PythonFileReporter.missing_arc_descriptions {{225#>>r9c:|jj||Srn)rsarc_description)rdrrs r#rz"PythonFileReporter.arc_descriptions{{**5#66r9cf|jt|j|_|jSrn)rar8r rks r#r"zPythonFileReporter.sources& << ,T]];DL||r9ctjj|j\}}|j dry|syy)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)r,r-r.r r_)rd_r4s r#should_be_pythonz#PythonFileReporter.should_be_pythons:!!$--03 >>% r9c4t|jSrn)rr"rks r#rz%PythonFileReporter.source_token_liness!$++-00r9c4t|jSrn)rr"rks r#rzPythonFileReporter.code_regions sDKKM**r9c ddgS)N)function functions)classclassesrks r#code_region_kindsz$PythonFileReporter.code_region_kinds s %   r9rn)rQrrYzCoverage | NonereturnNone)rstr)rr)r set[TLineNo])rzdict[TLineNo, TLineNo])rwzIterable[TLineNo]rr)rzIterable[TArc]r set[TArc])rr)rzdict[TLineNo, int])rrrrrzIterable[TArc] | Nonerr)rrrrrr)rbool)rr)rzIterable[CodeRegion])rzIterable[tuple[str, str]])rV __module__ __qualname____doc__rXrlr propertyrsrwryr|r~rrrrrrr"rrrr __classcell__)rhs@r#rTrTs+69  &)$20")04 ???- ? ?7 (1+ r9rT)r rrbytes)r rrr)r rrz bytes | None)rQrrr).r __future__ros.pathr,rOr;collections.abcrtypingrrYrcoverage.exceptionsrrcoverage.filesr r r coverage.miscr r coverage.parserrcoverage.phystokensrrcoverage.pluginrrcoverage.regionsrcoverage.typesrrrrrrr$r8r1rJrRrTrr9r#rs}." $ ;NN4(C4)BB!B  @ F.: } } r9