L i${dZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddlm Z mZddlmZmZddlZddlmZmZddlmZdd lmZdd lmZmZmZmZmZm Z m!Z!m"Z"dd l#m$Z$dd l%m&Z&m'Z'm(Z(dd l)m*Z*ddl+m,Z,m-Z-ddl.m/Z/er ddlm0Z0ddl1m2Z2e eZd-dZ3d-dZ4d.dZ5e GddZ6e GddZ7e GddZ8e GddZ9GddZ:Gdd Z;e jxe jzzd!zZ>ej~d/d"Z@d0d#ZAGd$d%ZBe Gd&d'ZCGd(d)ZDd1d*ZEd2d+ZFd3d,ZGy)4zHTML reporting for coverage.py.) annotationsN)Iterable) dataclassfield) TYPE_CHECKINGAny) CoverageDataadd_data_to_hash) NoDataError) flat_rootname)Hasher ensure_dir file_be_goneformat_local_datetime human_sortedisolate_moduleplural stdout_link)get_analysis_to_report)AnalysisAnalysisNarrowerNumbers)Templite)TLineNoTMorf)__url__)Coverage) FileReporterctjjtjjtd}tjj||}|S)z4Return the path to an "htmlfiles" data file of ours. htmlfiles)ospathjoindirname__file__)fname static_dirstatic_filenames S/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/coverage/html.py data_filenamer*0s=bggooh7EJggll:u5O cztt|d5}|jcdddS#1swYyxYw)z+Return the contents of a data file of ours.utf-8encodingN)openr*read)r& data_files r) read_datar37s2 mE"W 5 ~~   s1:ctjdd|tjdz}t|d5}|j |j dddddy#1swYyxYw) z*Write `html` to `fname`, properly encoded.z(\A\s+)|(\s+$))flags wbasciixmlcharrefreplaceN)resub MULTILINEr0writeencode)r&htmlfouts r) write_htmlrB=sY 66#RR\\ BT ID eT >d 4;;w(;<=>>>s "A""A+ceZdZUdZded<ded<ded<ded <ded <ded <ded <ded <dZded<dZded<dZded<dZded<dZ ded<y)LineDataz-The data for each source line of HTML output.zlist[tuple[str, str]]tokensrnumberstrcategoryz list[str]contextscontexts_label context_listshort_annotationslong_annotationsr5r@Nz str | None context_strannotate annotate_long css_class) __name__ __module__ __qualname____doc____annotations__r@rNrOrPrQr+r)rDrDDsd7 !! OM  D#N"K"Hj $M:$Isr+rDc0eZdZUdZded<ded<ded<y) FileDataz-The data for each source file of HTML output.rGrelative_filenamernumszlist[LineData]linesNrRrSrTrUrVrWr+r)rYrYWs7 M r+rYcXeZdZUdZdZded<dZded<dZded<ee Z ded <y ) IndexItemz:Information for each index entry, to render an index page.r5rGurlfile descriptiondefault_factoryrr[N) rRrSrTrUr`rVrarbrrr[rWr+r)r_r_`s0DCMD#NK'2D'2r+r_cXeZdZUdZded<ded<ded<ded<ded <d ed <d ed <y ) IndexPagezData for each index page.rGnounrfilenamezlist[IndexItem] summariesrtotalsintskipped_covered_countskipped_empty_countNr]rWr+r)rfrfjs+# I KM Or+rfc$eZdZdZdZddZddZy)HtmlDataGenerationz8Generate structured data to be turned into HTML reports.z(empty)c||_|jj|_|jj|_|jj |_|jj r9|jj dhk(r|jjd|jj|jjy)Nr5zNo contexts were measured) coverageconfigget_datadatahas_arcs show_contextsmeasured_contexts_warnset_query_contextsreport_contexts)selfcovs r)__init__zHtmlDataGeneration.__init__|s mm** MM**,  **, ;; $ $yy**,4 ##$?@ $$T[[%@%@Ar+c jr|j}|j}ni}g}jjr%j j |j}g}|j}i}t|dr|j}t|jdD]\} } dx} } g} g}| |jvrd} n+| |jvrd} njr| |vrd} || }t||| dk(r'| j!d |j!d | d n|| D]U}|dkr| j!d n| j!t#||j!|j%| ||Wni| |j&vrd } nX|j)| x}rE||jvrd} n4||jvrd} n#jr||vrd} n||j&vrd} g}d}g}| rgjjrQt+fdj)| dD}|j,gk(r j,}nt|d}|}|j!t/| | | xs| |||| |t1|j3|j4|}|S)z.Produce the data needed for one file's report. multiline_map)startr5excmisparranywherezline z5 didn't jump anywhere: it always raised an exception.exitrunexc2mis2par2run2c3>K|]}|xs jywN)EMPTY).0cr{s r) z3HtmlDataGeneration.data_for_file..s'dATZZ'dsrWz ctx)rErFrHrIrJrKrLrM)rZr[r\)rumissing_branch_arcs arcs_executedrrrvrtcontexts_by_linenorh branch_statshasattrr enumeratesource_token_linesexcludedmissinglenappendrGmissing_arc_description statementsgetrrrDrYrZnumbers)r{franalysisrrrr\rrlinenorErH category2rLrMmbab first_linerIrJrK file_datas` r) data_for_filez HtmlDataGeneration.data_for_files =="*">">"@ $22M"$ M ;; $ $!%!=!=h>O>O!P ,,.  2 ',,.M'(=(=(?qIA NFF#% %Hy " ! *** 8+++ 6-@#@ )&1s8|F3A66%,,Z8$++x'\]18q5-44V<-44SV<(//66vq-P 8... ,00888!2!22 &I8#3#33 &I]]z5H'H &I 8#6#66 &IHNLDKK55''dASAWAWX^`bAc'dd |+%)ZZN(+H d%;N#+L LL!!%2%#1!-&7%5  mA F 224!! r+Nr|rreturnNone)rrrrrrY)rRrSrTrUrr}rrWr+r)rorowsB EB[r+roceZdZdZddZy) FileToReportz#A file we're considering reporting.c||_||_t|j|_|jdz|_dx|_|_y)Nz.htmlr5)rrr rZrootname html_filename prev_html next_html)r{rrs r)r}zFileToReport.__init__sD  %b&:&:&<= !]]W4*,,r+N)rrrrrr)rRrSrTrUr}rWr+r)rrs --r+rz!#$%'()*+,-./:;=?@[]^_`{|}~c|dk(r tdSg}|r7t|tt\}}|jt||r7dj |S)zACreate a short HTML-safe string from an integer, using HTML_SAFE.rr5) HTML_SAFEdivmodrrr#)nrts r) encode_intrsV Av| A aY(1 1  771:r+ct|d5}|j}dddt}|j|j dd}t j j|}|jdd|d}tt j j||d5}|j|ddd|S#1swYxYw#1swY|SxYw)zsCopy `src` to `dest_dir`, adding a hash to the name. Returns the updated destination file name with hash. rbN._cb_r8) r0r1r update hexdigestr!r"basenamereplacer#r>)srcdest_dirftexth cache_bustsrc_basedests r)copy_with_cache_bustrs c4AvvxAHHTNr"Jww$H   C4 |1!5 6D bggll8T*D 1Q   K KsC3CCC%creZdZdZgdZddZddZddZddZdddZ ddZ dd Z dd Z dd Z dd Zdd Zy) HtmlReporterzHTML reporting.)z style.csszcoverage_html.jszkeybd_closed.pngzfavicon_32.pngc||_|jj|_|jj|_|jj|_|j |jj |_|jj |_|j|jj|_|jj}t|jj|_ |jj|_ |jj|_ d|jddi|_t!|j|_t%|j|_d|_d|_d|_t.t0t2t4tj6|t9t:j:j=|j|jidddddd d d d d |_tAtCd|j>|_"tCd|_#tA|jF|j>|_$y)NrafilesFz exc show_excz mis show_miszpar run show_parrzexc exc2 show_exczmis mis2 show_miszpar par2 ru2 show_parzrun run2)rrrrrrrr) escapepair pretty_filer __version__title time_stamp extra_cssrustaticsrH index.htmlz pyfile.html)%rqrrhtml_dir directoryhtml_skip_covered skip_coveredhtml_skip_empty skip_empty html_titleboolrrsrtrunew_index_page index_pagesIncrementalCheckerincrrodatagendirectory_was_emptyfirst_frfinal_frrrrrrrdatetimenowtemplate_globalsrr3 index_tmplpyfile_html_source source_tmpl)r{r|rs r)r}zHtmlReporter.__init__s mm** -- KK99    $ $ 8 8D ++55 ?? ""kk44DO &&dkk334MM**,  **,  D''82 't~~6 )$--8 #(   &#///0A0A0E0E0GH &%)++/" ! 4#9\#:DS) zcGenerate an HTML report for `morfs`. `morfs` is a list of modules or file names. FTrazNo data to report.Nrrr) rr1check_global_datarrrrrqr should_reportrrrr!r"r#rrr make_directorymake_local_static_report_filesziprrwrite_html_pagercode_region_kindsrwrite_file_index_pagewrite_region_index_pagesrj n_statements pc_covered) r{morfsfiles_to_report have_datarrftrftr1ftr2rgr first_html final_htmls r)reportzHtmlReporter.reportbs=  ##DKK1H1HI 24==%H NLBIr8,C!!(D,<,>"zz$..)'+D $*r+ct||j}|s/tjj |j dd}||j d|<y)z@Copy a static file into the output directory with cache busting.r_rN)rrr!r"rrr)r{rslugrs r)copy_static_filezHtmlReporter.copy_static_filesK#C877##C(00c:D15i(.r+c|jD]}|jt||jr?|jjJ|j|jjd|j rQt tjj|jddd5}|jddddyy#1swYyxYw) z5Make local instances of static files for HTML report.Nr)rz .gitignorewr-r.z# Created by coverage.py * ) STATIC_FILESrr*rrrrr0r!r"r#rr>)r{staticfgis r)rz+HtmlReporter.make_local_static_report_filess'' 9F  ! !-"7 8 9 >>;;((4 44  ! !$++"7"7k ! J  # #bggll4>><@#PWX ;\_ 9: ; ; $ ; ;s 9CCc0|j}|xj|z c_|jr8|jdk(}|jdk(}|r|r|xj dz c_y|j r%|jdk(r|xjdz c_yy)z.Determine if we'll report this file or region.rrFT) rrjr n_missingn_partial_branchesrlrrrm)r{r index_pager[no_missing_linesno_missing_branchess r)rzHtmlReporter.should_reportsT!    $! 3 #'#:#:a#? $700A50 ??  A%..!3.r+c |jj|j|j|jrL|j dj j|jj|jy|jj|j|j}tjd|jD}td|j!DDcic]\}}|| }}}|rCt#j$|j'Dcic]\}}t)||c}}d} nd} |jD]g} j*D]L\} } | dk(r| jt-| &t-| xsd} | jd | d | d Nd j/| _j2rcj2Dcgc]}t)||}}t5d |Dt7d j/fd|Dz_nd _j:r*dj/fdj:D_nd_j>rJj>}tA|dk(s%Jd|jjCd||d_"nd_"g}jFr+|j|jHdjFdj/|xsd_%tLjNj/|jP|jR}|jTjWi|jX| |jZ|j\d}t_||ta|jRt-|jjC|jjb}|j dj j||jje|j|ycc}}wcc}}wcc}w)aGenerate an HTML page for one source file. If the page on disk is already correct based on our incremental status checking, then the page doesn't have to be generated, and this function only does page summary bookkeeping. raNc3BK|]}|jD]}|ywr)rI)rcliners r)rz/HtmlReporter.write_html_page..s &^Uu~~&^!q&^q&^sc3&K|] }|d yw)rNrW)rxs r)rz/HtmlReporter.write_html_page..s5[qad5[s)indentwsz z zr5c32K|]}t|ywr)r)recs r)rz/HtmlReporter.write_html_page..s DRR Dsc3@K|]}|jywr)ljust)rr$ code_widths r)rz/HtmlReporter.write_html_page..s>-/BHHZ(>z,   c3@K|]}jd|yw)z ↛ N)rF)rdldatas r)rz/HtmlReporter.write_html_page..s&7EFu||n$3C>7%!%'!&&"2!6!67JOJaJa7""&%%..5zQ.svv/G/G/I.J"UGT',Ah#&*#K~~""))*5ennE"hh{3)r{rr index_file print_hrefs r)rz"HtmlReporter.write_file_index_page1sx**   V $!!+ !wrwwz7R6S-TU  !6zlCD r+c |D]}|jjDcgc]}|d }}t|jjj }|jj }|D],|j }ttd|dz}|D]!} | jk7r|| jz}#t|j} | jfd|D| j|g|D]} | jk7r| j| j} |j| |sB| j j#ddj%d} |j&j)t+|j,d| j.t1|jj3dt1| d t1| j zd z| j4 | j|} |j| |s|j&j)t+|j,t1|jj3d d t1dzd z| j4 /|j j7D]\} dk7s |j9| ycc}w)z,Write the other index pages for this report.rrc3VK|] }|jk(s|j"ywr)kindr\)rrrgs r)rz8HtmlReporter.write_region_index_pages..Ps$P4QWW$Ps))rrr z#tz z)r`rarbr[zz(no z)raN)rrrsource splitlines code_regionsrsetrangerQr\rr add_regionsnarrowrname rpartitionlstriprirr_rrrrZrr6rJ)r{rrr region_nouns num_linesregions page_data outside_linesregionnarrowerr sorting_namerrgs @r)rz%HtmlReporter.write_region_index_pages?s"3 C030H0H0JKDGKLKCFFMMO6689Iff))+G$.  ,,T2 #E!Y]$; < %2F{{d* !V\\1M2 ,CLL9$$$Pg$PP$$m_5%F{{d* 'v||r#B#I#I##NL''..!##4"5R ~ F!'(@(@(B!C"/|0D/ER H"("5!6"+!,"*!1!1  ($??=9%%h :''..! # 1 1!'(@(@(B!C 1$>vd|nH"U!V"+!,"*!1!1  G.  3 j!% 0 0 6 6 8 2 D*v~%%j1 2iLs K,c jdx}}|jx}r)t||j|j}|d|d}|jx}r)t||j|j}|d|d}|jj Dcgc]\}|jj |j|jk7r |jnd|j|jk(d^}}|j|j|j|jdk7r |jnd|j||dd|d } | j||jj| } tjj!|j"|j} t%| | | Scc}w) z^Write an index page specified by `index_page`. Returns the filename created. r5r,z" skipped due to complete coverage.z empty z skipped.)labelr`currentra) r^rjrg region_nounrskipped_covered_msgskipped_empty_msgrr index_buttons)rlrrgrmrvaluesrrhrirjrrrr8r!r"r#rrB) r{rkwargsrhrirwordiprj render_datar@rMs r)rJzHtmlReporter.write_index_pagezs 354/00 01 0!Z__j.?.?@D%&Cq.P"Q .. .1 .!Z__j.?.?@D#$#WTF) < &&--/   *&(gg&@r{{b77joo5   "++ ''OO.8oo.G:??R --#6!2*   6"%%k2WW\\$..*2E2EF :t$3 sA!F0Nr)rgrGrrGrrf)rzIterable[TMorf] | Nonerfloatrr)r5)rrGrrGrr)rrrrfrr)rrrr)rrGrrGrr)rzIterable[FileToReport]rr)rrfrlrGrrG)rRrSrTrUrr}rrrrrrrrrrJrWr+r)rrsIL8Tt  9 v, 6;&,\;| 92v&r+rc<eZdZUdZdZded<eeZded<y) FileInfozHSummary of the information from last rendering, to avoid duplicate work.r5rGhashrcr_indexN) rRrSrTrUrtrVrr_rurWr+r)rsrssRD#NY7E97r+rsc\eZdZdZdZdZdZddZddZddZ ddZ dd Z dd Z dd Z dd Zy )raLogic and data to support incremental reporting. When generating an HTML report, often only a few of the source files have changed since the last time we made the HTML report. This means previously created HTML pages can be reused without generating them again, speeding the command. This class manages a JSON data file that captures enough information to know whether an HTML page for a .py file needs to be regenerated or not. The data file also needs to store all the information needed to create the entry for the file on the index page so that if the HTML page is reused, the index page can still be created to refer to it. The data looks like:: { "note": "This file is an internal implementation detail ...", // A fixed number indicating the data format. STATUS_FORMAT "format": 5, // The version of coverage.py "version": "7.4.4", // A hash of a number of global things, including the configuration // settings and the pyfile.html template itself. "globals": "540ee119c15d52a68a53fe6f0897346d", "files": { // An entry for each source file keyed by the flat_rootname(). "z_7b071bdc2a35fa80___init___py": { // Hash of the source, the text of the .py file. "hash": "e45581a5b48f879f301c0f30bf77a50c", // Information for the index.html file. "index": { "url": "z_7b071bdc2a35fa80___init___py.html", "file": "cogapp/__init__.py", "description": "", // The Numbers for this file. "nums": { "precision": 2, "n_files": 1, "n_statements": 43, ... } } }, ... } } z status.jsonzThis file is an internal implementation detail to speed up HTML report generation. Its format can change at any time. You might be looking for the JSON report: https://coverage.rtfd.io/cmd.html#cmd-jsonc2||_|jyr)r_reset)r{rs r)r}zIncrementalChecker.__init__s" r+c d|_i|_y)z5Initialize to empty. Causes all files to be reported.r5N)globalsrr s r)ryzIncrementalChecker._resets *, r+cn tjj|j|j}t |d5}t j|}dddd|jk7rd}n|dtjk7rd}nd} |roi|_ djD]G\}}|d }tdi|}t!di|d |_t%|d | } | |j|<I|d |_y|j)y#1swYxYw#ttf$rd}YwxYw)z)Read the information we stored last time.r-r.NformatFversionTrrur[rt)rtrur{rW)r!r"r#r STATUS_FILEr0r4load STATUS_FORMATrqrOSError ValueErrorrr6r_rr[rsr{ry) r{ status_filefstatusstatususablerhfiledict indexdict index_itemfileinfos r)r1zIncrementalChecker.reads5 '',,t~~t7G7GHKkG4 ,7+ , h4#5#55 "h&:&:: DJ&,Wo&;&;&= 0"($W- &33 ")">If,="> #!&)$(0 8$ 0"),DL KKM5 , ,$ F s*AD DD DD D43D4c tjj|j|j}|j |j tj|j|jjDcic]\}}|tj|c}}d}t|dd5}tj ||ddddycc}}w#1swYyxYw)zWrite the current status.)noter}r~r{rrr-r.),:) separatorsN)r!r"r#rrNOTErrqrr{rr6 dataclassesasdictr0r4dump)r{rr&finfo status_datarAs r)r>zIncrementalChecker.write sggll4>>43C3CD II((++||KO::K[K[K]^<5%e[//66^  +sW 5 @ IIk4J ? @ @_ @ @s C6CC'ct}|D]}|j||j}|j|k7r|j ||_yy)aCheck the global data that can affect incremental reporting. Pass in whatever global information could affect the content of the HTML pages. If the global data has changed since last time, this will clear the data so that all files are regenerated. N)r rrr{ry)r{rtmr* these_globalss r)rz$IncrementalChecker.check_global_datasQ H A HHQK  <<= ( KKM(DL )r+c8t}|j|jjdt ||j ||j }|jj|t}||jk(ry||_ y)aCan we skip reporting this file? `data` is a CoverageData object, `fr` is a `FileReporter`, and `rootname` is the name being used for the file. Returns True if the HTML page is fine as-is, False if we need to recreate the HTML page. r-TF) r rrRr?r rhrr setdefaultrsrt)r{rtrrr this_hash file_infos r)r/z IncrementalChecker.can_skip_file&sv H ##G,-r{{A.KKM JJ))(HJ?   &'INr+c^|jj|tjS)z/Get the information for index.html for `fname`.)rrrsru)r{r&s r)r0zIncrementalChecker.index_info?szz~~eXZ0666r+cV||jj|t_y)z/Set the information for index.html for `fname`.N)rrrsru)r{r&infos r)r:z!IncrementalChecker.set_index_infoCs9= eXZ06r+N)rrGrrrq)rtrrr)rtr rrrrGrr)r&rGrr_)r&rGrr_rr)rRrSrTrUrrrr}ryr1r>rr/r0r:rWr+r)rrsI*X KM M - @ @) 27>r+rcF|jddjddS)z\HTML-escape the text in `t`. This is only suitable for HTML text, not attributes. &z&>5 !!r+c0tjdd|S)z4Return a prettier version of `filename` for display.z[/\\]u  \g<0> )r;r<)rhs r)rrZs 66(@( KKr+)r&rGrrG)r&rGr@rGrr)rrkrrG)rrGrrGrrG)rrGrrG)rztuple[int, int]rrG)rhrGrrG)HrU __future__rr1rr functoolsr4r!r;stringcollections.abcrrrtypingrrrq coverage.datar r coverage.exceptionsr coverage.filesr coverage.miscr rrrrrrrcoverage.report_corercoverage.resultsrrrcoverage.templitercoverage.typesrrcoverage.versionrrcoverage.pluginsrr*r3rBrDrYr_rfror ascii_lettersdigitsrcacherrrrsrrrrrWr+r)rsx&" $(%8+(   8@@&)$!-B >  $   33 3     jjZ--  6== 03P P    "PPf  88 8Z>Z>@8" Lr+