4C&SdZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl mZmZmZmZmZmZmZmZddlZddlmZmZddlmZddlmZdd lmZm Z m!Z!m"Z"m#Z#dd lm$Z$m%Z%m&Z&dd l'm(Z(dd l)m*Z*m+Z+dd l,m-Z-ddl.m/Z/m0Z0ddl1m2Z2er.ddlm3Z3ddl4m5Z5ddl m6Z6Gdde6Z7Gdde6Z8e"eZd5dZ9d5dZ:d6dZ;e Gdd ZGd%d&Z?e j@e jAzd'zZBejCd(d7d+ZDGd,d-ZEGd.d/ZFd8d1ZGd9d4ZHdS):zHTML reporting for coverage.py.) annotationsN) dataclass)AnyDictIterableListOptionalTuple TYPE_CHECKINGcast) CoverageDataadd_data_to_hash) NoDataError) flat_rootname) ensure_dir file_be_goneHasherisolate_moduleformat_local_datetime) human_sortedplural stdout_link)get_analysis_to_report)AnalysisNumbers)Templite)TLineNoTMorf)__url__)Coverage) FileReporter) TypedDictc2eZdZUdZded<ded<ded<dS) IndexInfoDictz4Information for each file, to render the index file.rnumsstr html_filenamerelative_filenameN__name__ __module__ __qualname____doc____annotations__/srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/coverage/html.pyr$r$)s9BB r0r$c(eZdZUdZded<ded<dS) FileInfoDictzHSummary of the information from last rendering, to avoid duplicate work.r&hashr$indexNr)r/r0r1r3r3/s-VV r0r3fnamer&returnctjtjtd}tj||}|S)z9Return the path to an "htmlfiles" data file of ours. htmlfiles)ospathjoindirname__file__)r6 static_dirstatic_filenames r1 data_filenamerA8sBbgooh77EEJgll:u55O r0ctt|5}|cdddS#1swxYwYdS)z+Return the contents of a data file of ours.N)openrAread)r6 data_files r1 read_datarF@s mE"" # # y~~                  s>AAhtmlNonectjdd|tjdz}t|d5}||ddddddS#1swxYwYdS) z*Write `html` to `fname`, properly encoded.z(\A\s+)|(\s+$))flags wbasciixmlcharrefreplaceN)resub MULTILINErCwriteencode)r6rGfouts r1 write_htmlrVFs 6#RR\ B B BT ID eT  >d 4;;w(;<<===>>>>>>>>>>>>>>>>>>s*A--A14A1ceZdZUdZded<ded<ded<ded <d ed <ded <d ed <d ed<d ed<dZded<dZded<dZded<dZded<dZ ded<dS)LineDataz-The data for each source line of HTML output.zList[Tuple[str, str]]tokensrnumberr&categorybool statementz List[str]contextscontexts_label context_listshort_annotationslong_annotationsrJrGNz Optional[str] context_strannotate annotate_long css_class) r*r+r,r-r.rGrcrdrerfr/r0r1rXrXMs77!!!!OOOMMMOOO    DNNNN!%K%%%%"H""""#'M''''Ir0rXc2eZdZUdZded<ded<ded<dS) FileDataz-The data for each source file of HTML output.r&r(rr%zList[LineData]linesNr)r/r0r1rhrh`s977MMMr0rhc&eZdZdZdZddZdd ZdS)HtmlDataGenerationz8Generate structured data to be turned into HTML reports.z(empty)covr r7rHcV||_|jj|_|j}||_|jjr3|dhkr|jd||jjdS)NrJzNo contexts were measured) coverageconfigget_datahas_arcs show_contextsmeasured_contexts_warnset_query_contextsreport_contexts)selfrldatas r1__init__zHtmlDataGeneration.__init__ms m* }%%''  ; $ A%%''B4// ##$?@@@  ;<<<<z3HtmlDataGeneration.data_for_file..s)'d'dATZ'd'd'd'd'd'dr0r/z ctx) rYrZr[r]r^r_r`rarb)r(r%ri)rqmissing_branch_arcs arcs_executedrorrrxcontexts_by_linenofilename enumeratesource_token_linesexcludedmissingappendr&missing_arc_description statementsrgetrlenrXrhr(numbers)rwrzr{rrrrilinenorYr[rarbbr^r_r` file_datas` r1 data_for_filez HtmlDataGeneration.data_for_filews = 5"*">">"@"@ $2244M ; $ U!)!A!A(BS!T!T '(=(=(?(?qIII* * NFFH " ! *** 8+++  !6-@#@#@ ,V4bbA1uu)008888)00Q888$++B,F,FvqR_,`,`aaaa b 8... HNL ,DK5 ,''d'd'd'dASAWAWX^`bAcAc'd'd'ddd |++%)ZNN(+H %;%;%;N#+L LL!!X%88!-)"3!1        2244!   r0Nrlr r7rH)rzr!r{rr7rh)r*r+r,r-rryrr/r0r1rkrkhsGBB E==========r0rkceZdZdZd dZd S) FileToReportz#A file we're considering reporting.rzr!r{rr7rHc||_||_t||_|jdz|_dS)Nz.html)rzr{rr(rootnamer')rwrzr{s r1ryzFileToReport.__init__s@  %b&:&:&<&<== !]W4r0N)rzr!r{rr7rH)r*r+r,r-ryr/r0r1rrs.--555555r0rz!#$%'()*+,-./:;=?@[]^_`{|}~)maxsizenintc|dkr tdSg}|rGt|tt\}}|t||Gd|S)zACreate a short HTML-safe string from an integer, using HTML_SAFE.rrJ) HTML_SAFEdivmodrrr<)rrts r1 encode_intrso Avv| A aY((1 1  771::r0cReZdZdZgdZddZdd Zdd Zdd ZddZ ddZ ddZ dS) HtmlReporterzHTML reporting.)z style.csszcoverage_html.jszkeybd_closed.pngzkeybd_open.pngzfavicon_32.pngrlr r7rHcd||_|jj|_|jj|_|jj|_|j|jj|_|jj|_|j|jj|_d|_d|_ |jj }||jj r/tj |jj |_ nd|_ |j|_|j|_g|_g|_t)|j|_t-|j|_t1|jj|_d|_d|_d|_t<t>t@tBtj"|tGtHj$%|j |j|jj&dddddd |_'tQd |_)tU|j)|j'|_+dS) Nr) precisionFz exc show_excz mis show_miszpar run show_parr)rrrr) escapepairrr __version__title time_stamp extra_cssrqrrr[z pyfile.html),rnrohtml_dir directoryhtml_skip_covered skip_coveredhtml_skip_empty skip_emptyskipped_covered_countskipped_empty_count html_titlerr:r;basenamerprxrqfile_summariesall_files_numsIncrementalCheckerincrrkdatagenrrtotalsdirectory_was_emptyfirst_frfinal_frrrrrrrdatetimenowrrtemplate_globalsrFpyfile_html_sourcer source_tmpl)rwrlrs r1ryzHtmlReporter.__init__s m* - K9   $ $ 8D +5 ? ""k4DO%&"#$  & % ;  "W--dk.CDDDNN!DNM**,,  **,, 35-/&t~66 )$-88  (=>>> #(   #//0A0E0E0G0GHH ![6 &%) #! ! 0#,M":":#D$;T=RSSr0morfsOptional[Iterable[TMorf]]floatc|j|j|j|jg}t |j|D]y\}}t||}||}|r| |Bttj |j|jzt!|D]^\}}|dkrd}n||dz j}|t#|dz krd} n||dzj} |||| _|jst)dt+t,t/|j|_|r|dj} |dj} ndx} } || | ||jjo |jjS)zcGenerate an HTML report for `morfs`. `morfs` is a list of modules or file names. r index.htmlr}zNo data to report.)rrDcheck_global_datarorrrnrshould_report_filerrr:r;r<rr'rrwrite_html_filerrr rsumr index_filemake_local_static_report_files n_statements pc_covered) rwrfiles_to_reportrzr{ftrshouldi prev_html next_html first_html final_htmls r1reportzHtmlReporter.reports  ##DK1HIII24=%HH N NLBr8,,C,,S11F N&&s++++RW\\$.#:KLLMMMM00 < 4>"""z$.)) ,'+D $ $ $ , ,r0c.|jD]G}tjt|tj|j|H|jr`ttj|jdd5}| ddddn #1swxYwY|j rW|j j Jtj|j j tj|j|j dSdS)z5Make local instances of static files for HTML report.z .gitignorewz# Created by coverage.py * N) STATIC_FILESshutilcopyfilerAr:r;r<rrrCrSrro)rwstaticfgis r1rz+HtmlReporter.make_local_static_report_filesQs9' Y YF OM&1127<<PV3W3W X X X X  # ;bgll4><@@#FF ;# 9::: ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; > a;(444 ODK127<<PTP^3_3_ ` ` ` ` ` a as B,,B03B0rrr\c|jj}|j||jr,|jdk}|jdk}|r|r|xjdz c_dS|jr|j dkr|xj dz c_ dSdS)z$Determine if we'll report this file.rr}FT) r{rrrr n_missingn_partial_branchesrrrr)rwrr%no_missing_linesno_missing_branchess r1rzHtmlReporter.should_report_filecs|# ""4(((    $! 3 #'#:a#?  $7 **a/**u ?  A%%((A-((utr0rr&rc ||j|j|j|jr9|j|j|jdS|j |j|j }tj d|jD}dtd|DDr3t#jdDd}nd}|jD]g}jD][\}} |dkr#|t+| .t+| pd } |d |d | d \d |_jrcfdjD} t3d| Dt5d fd| Dz_nd _jr,dfdjD_nd_jr}j} t?| dkr| d_ n\d!t?| ddt| dD_ nd_ g} j"r+| |j#dj"d| pd_$ tJj&|j'|j(}|j)*i|j+|||d}tY|||j j-|j(|j.d}|j||j/|j|dS)z*Generate an HTML file for one source file.Nc3.K|]}|jD]}|VdSr)r^)rcliners r1rz/HtmlReporter.write_html_file..s1&^&^Uu~&^&^!q&^&^&^&^&^&^&^r0ci|]\}}|| Sr/r/)rrys r1 z0HtmlReporter.write_html_file..s\\\&1aA\\\r0c3&K|] }|dV dS)rNr/)rxs r1rz/HtmlReporter.write_html_file..s&5[5[qad5[5[5[5[5[5[r0c4i|]\}}t||Sr/r)rkvs r1rz0HtmlReporter.write_html_file..s$FFFfq!AFFFr0)indentwsz z zrJc:g|]}t|Sr/r)r c_context context_codess r1 z0HtmlReporter.write_html_file..s3$$$=FJ}Y788$$$r0c34K|]}t|VdSr)r)recs r1rz/HtmlReporter.write_html_file..s( D DRR D D D D D Dr0c3BK|]}|VdSr)ljust)rr code_widths r1rz/HtmlReporter.write_html_file..s/NNrbhhz22NNNNNNr0z,   c30K|]}jd|VdS)z ↛ N)rZ)rdldatas r1rz/HtmlReporter.write_html_file..sG77|@@Q@@777777r0r}rz{:d} missed branches: {}z, c3,K|]\}}|dd|VdS)r z) Nr/)rnumann_longs r1rz/HtmlReporter.write_html_file..sK"" -X #22222""""""r0r~r[ pln) contexts_jsonrr)r%r'r()0rr can_skip_filerxrzrrr index_inforrr{ collectionsCounterrir most_commonjsondumpsitemsrYrr<rGr`maxr&rcrardrbrreformatr[rrfr:r;rr'rrender__dict__rVrr(set_index_info)rwrrrrr^r html_partstok_typetok_texttok_htmlencoded_contextslongs css_classes html_pathrGrr rrs @@@r1rzHtmlReporter.write_html_filezs  9 " "49cfcl C C    & &ty';';CL'I'I J J J FL..svs|DD &&^&^io&^&^&^^^\\I5[5[HDXDXDZDZ5[5[5[,[,[\\\  ! JFF 0C0C0E0EFFFMM !M_4 =4 =EJ&+l U U"(t##%%fX&6&67777%h//;8H%%&Sh&S&S(&S&S&STTTT,,EJ! '$$$$JOJ\$$$ ! D D3C D D DDD  OOggNNNN=MNNNNNO!! %'!& &"2!6!67777"4777"" "&% +.u::??*/(E''*D*K*KE  ""1:51J1J1J"""++E'''+#K~ "")*5enE"hh{3343CDD "&*"2"2"4"4 ' ' HhW%E!&M3355E&M&E(OO(+|    +s # # ;t Ifdz : : : : ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;s!CC  C rxrct}|D]}|||}|j|kr|||_dSdS)zrys,&%"""""" !!!!!!RRRRRRRRRRRRRRRRRRRR88888888++++++((((((aaaaaaaaaaaaaa;;;;;;;;;;777777........&&&&&&))))))))$$$$$$!!!!!!------!       y ^B    >>>>  $  LLLLLLLL^55555555  6= 03P P T"""   #" ffffffffR A9A9A9A9A9A9A9A9L8888r0