etSrSS/rSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK r SSK r SSK r SSK r SSK Jr SSKrSr"SS5rS rS r"S S5rS rS rSSjrSr"SS5rSr\S:Xa\"5 gg)aprogram/module to trace Python program or function execution Sample use, command line: trace.py -c -f counts --ignore-dir '$prefix' spam.py eggs trace.py -t --ignore-dir '$prefix' spam.py eggs trace.py --trackcalls spam.py eggs Sample use, programmatically import sys # create a Trace object, telling it what to ignore, and whether to # do tracing or line-counting or both. tracer = trace.Trace(ignoredirs=[sys.base_prefix, sys.base_exec_prefix,], trace=0, count=1) # run the new command using the given tracer tracer.run('main()') # make a report, placing output in /tmp r = tracer.results() r.write_results(show_missing=True, coverdir="/tmp") TraceCoverageResultsN) monotonicz#pragma NO COVERc$\rSrSrSSjrSrSrg)_IgnoreENcU(d [5O [U5UlU(d/O/UVs/sH"n[RR U5PM$ snUlSS0Ulgs snf)Nz)set_modsospathnormpath_dirs_ignore)selfmodulesdirsds +/opt/imh/python3.13/lib/python3.13/trace.py__init___Ignore.__init__FsW")SUs7| #R37*937a+-''*:*:1*=37*9 #Q( *9s)A*cX R;aURU$X R;aSURU'gURH-nURUS-5(dMSURU' g UcSURU'gURH;nURU[R -5(dM,SURU' g SURU'g)Nr .r)rr startswithrr sep)rfilename modulenamemodrs rnames _Ignore.namesLs  %<< + +  #'(DLL $::C$$S3Y//+, Z(   '(DLL $A""1rvv:..+, Z($% Z )rrr NN)__name__ __module__ __qualname____firstlineno__rr __static_attributes__r"rrrEs ) )r"rc[RRU5n[RRU5up#U$),Return a plausible module name for the path.)r rbasenamesplitext)rbaserexts r_modnamer0ws3 77  D !DGG$$T*MH Or"c[RRU5nSn[RHxn[RRU5nUR U5(dM:U[ U5[R :XdM\[ U5[ U5:dMvUnMz U(aU[ U5S-SnOUn[RRU5upTUR[R S5n[R(a UR[RS5n[RRU5upgURS5$)r+r Nr) r rnormcasesysrlenr splitdrivereplacealtsepr-lstrip)r comparepathlongestdirr.driverr/s r _fullmodnamer>~s''""4(KGxxggs#  ! !# & &;s3x+@BFF+J3x#g,&  CL1$%&''$$T*KE << $D yy||BIIs+GG$$T*MH ??3 r"cJ\rSrSrS SjrSrSrS SS.SjjrS S jrS r g)rNcXlURc0UlURR5UlX lURc0UlURR5UlX@lURc0UlURR5UlX0lXPlUR (aY[UR S5n[R"U5upnSSS5 URURXUS95 gg!,(df  N/=f![[[4a4n[SUR <SU<3[ R"S9 SnAgSnAff=f)Nrb)callerszSkipping counts file : file)countscopycounter calledfuncsrCinfileoutfileopenpickleloadupdate __class__OSErrorEOFError ValueErrorprintr4stderr)rrGrJrKrCrLferrs rrCoverageResults.__init__s$ ;; DK{{'') &    #!D ++002 << DL||((*   ;; N$++t,39;;q>0F- DNN6NPQ -,Xz2 N)-c;BE**N Ns0 D4 D#:'D4# D1-D44E= *E88E=cTURS5=(a URS5$)zOReturn True if the filename does not refer to a file we want to have reported. <>)rendswith)rrs ris_ignored_filename#CoverageResults.is_ignored_filenames%""3'BH,=,=c,BBr"c URnURnURnURnURnURnUHnURUS5XX-X('M UHnSX8'M UHnSXH'M g)z.Merge in the data from another CoverageResultsrr N)rGrJrCget) rotherrGrJrC other_countsother_calledfuncs other_callerskeys rrPCoverageResults.updates&& ,,|| !-- C **S!,|/@@FK %C K %!CGL!r"F)ignore_missing_filesc UR(aM[5 [S5 URn[U5Hupgn[SU<SU<SU<35 M UR(a[5 [S5 S=p[UR5H_uupn upnX:wa[5 [SU S5 U n Sn X:waX:wa[SU5 Un [S U <S U <S U<S U<35 Ma 0nURH1unnUR U05=nUU'URUU4UU'M3 0nUR 5GHunnURU5(aMURS 5(aUS SnU(a&[RRU5(dMgUcH[RR[RRU55n[U5nO"Un[R"USS9 [!U5nU(a [#U5nO0n[$R&"U5n[RR)UUS-5n[+US5n[,R."UR05unnS S S 5 UR3UUUUW5unnU(dGM|U(dGM[5SU-U- 5nUUXv4UU'GM U(a>U(a7[S5 [U5Hn UU unnpv[SUU -5 M UR6(aZ[+UR6S5n![8R:"URURUR4U!S5 S S S 5 g g !,(df  GN =f!,(df  g =f![<a%n"[SU"-[>R@S9 S n"A"g S n"A"ff=f)a Write the coverage results. :param show_missing: Show lines that had no hits. :param summary: Include coverage summary per module. :param coverdir: If None, the results of each module are placed in its directory, otherwise it is included in the directory specified. :param ignore_missing_files: If True, counts for files that no longer exist are silently ignored. Otherwise, a missing file will raise a FileNotFoundError. zfunctions called:z filename: z, modulename: , funcname: zcalling relationships:r2z***z -->z rz -> z.pycNT)exist_okz.coverrBdzlines cov% module (path)z%5d %3d%% %s (%s)wbr z"Can't save counts files because %srE)!rJrUsortedrCrGraitemsr^r]r risfiledirnameabspathr0makedirsr>_find_executable_linenos linecachegetlinesjoinrMtokenizedetect_encodingreadlinewrite_results_fileintrLrNdumprRr4rV)#r show_missingsummarycoverdirrhcallsrrfuncnamelastfile lastcfilepfilepmodpfunccfilecmodcfuncper_filelineno lines_hitsumscountr<lnotabsource coverpathfpencoding_n_hitsn_linespercentmrWrXs# r write_resultsCoverageResults.write_resultssZ    G % &$$E28-.h"J:<3@ << G * +#% %Hdll+=%%u';U$G%.$H "I>i&8'5) %IdE4GH, $ Hf-5\\(B-G GI* $ Xv,> ?If !, '~~/OHe''11  ((#CR=#BGGNN8,D,Dggoobggooh&?@%h/  C$/)(3 1(;''1F S*x*?@Ih%&66r{{C !&"55i6.> M !1&.- &%".- S:S@szzR SsB$N*O &:N< O * N9 < O O O O<O77O<c[USUS9nS nS n U [ US 5HupX;a!UR S XJ-5 U S - n US - nO7X;a![U ;aUR S 5 US - nOUR S 5 UR U RS55 M SSS5 X4$![a+n[SU<SU<S3[RS9 SnAgSnAff=f!,(df  X4$=f)z'Return a coverage results file in path.wrztrace: Could not open z for writing: z - skippingrEN)rrrr z%5d: z>>>>>> z ) rMrRrUr4rV enumeratewritePRAGMA_NOCOVER expandtabs) rrlinesrrrrLrXrrrlines rr|"CoverageResults.write_results_file.s 4x8G   )% 3 &MM'I,="=>aKFqLG%n.DMM),qLGMM), dooa01!4"1  26=DGJJ P W"s# B1BC)1 C&;!C!!C&) C9)rJrCrIrGrKrL)NNNNN)TFNN) r$r%r&r'rr^rPrr|r(r)r"rrrs0=A'+N4C $_S+0_SBr"c^0n[R"U5Hup4XA;dM SX$'M U$)z:Return dict where keys are lines in the line number table.r )disfindlinestarts)codestrslinenosrrs r_find_lines_from_coderNs2G''-   GO. Nr"c[X5nURH:n[R"U5(dM UR [ X155 M< U$)z>!   NN;q/ 0 Nr"cb0n[Rn[XS9n[R"UR 5nUHRupgpn U[R :Xa5U[R:Xa!UupU up[XS-5HnSX/'M UnMT SSS5 U$!,(df  U$=f)zReturn a dict of possible docstring positions. The dict maps line numbers to strings. There is an entry for line that contains only a string or a part of a triple-quoted string. rr N)tokenINDENTrMrygenerate_tokensr{STRINGrange)rrr prev_ttyperWtokttypetstrstartendrslinescolelineecolis r _find_stringsrds AJ h *a&&qzz2-0 )ET $-"'KE"%KE"5!)4 5J.1 + H + * Hs A9B B.cV[R"U5nUR5nURnSSS5 [WUS5n[UW5n[XV5$!,(df  N2=f![a,n[ SU<SU<3[ RS9 0sSnA$SnAff=f)zAReturn dict where keys are line numbers in the line number table.NzNot printing coverage data for rDrEexec) ryrMreadrrRrUr4rVcompilerr)rrWprogrrXrrs rruru{s ]]8 $668DzzH% 46 *D 8 ,D t ""% $  !)307:zz C s9A2A!A2! A/+A2/A22 B(B6~~   t// 0 LL)) * ) v &>> T"""4("4>> T"""4("s  B((AC(c&SnUR(d [R"UR5 U"U0UD6nUR(d[R"S5 U$!UR(d[R"S5 ff=fr)rr4rr)rfuncargskwresults rrunfunc Trace.runfuncsh~~ LL)) * #4&2&F>> T" >> T""s A&&*BcFURnURnU(a [U5nOSnURnSnX R;a!URUbURUnGOSURU'[ R "U5Vs/sH"n[R"U5(dM UPM$ nn[U5S:Xa[ R "US5V s/sHn [U [5(dMU PM n n [U 5S:Xah[ R "U S5V s/sHn [U S5(dMU PM n n [U 5S:XaU SRnX`RU'Ub U<SU<3nX4U4$s snfs sn fs sn f)Nr r __bases__r)f_code co_filenamer0co_namergc get_referrersr isfunctionr5 isinstancerhasattrr$) rframerrrrclsnamerWfuncsrdictsrclassess rfile_module_function_ofTrace.file_module_function_ofs||## !(+JJ<< %% %!!$'3,,T2'+D  t $!# 0 0 63 61#..q1 6E3 5zQ$&$4$4U1X$>5$>q *1d 3$>5u:?*,*:*:58*D?*DQ&-a&= !*DG?7|q(")!*"5"5 4;**40  ")84HX---3 5?s$F6F(FF7FFcUS:Xa=URU5nURUR5nSURXT4'gg)z[Handler for call events. Adds information about who called who to the self._callers dict. callr N)r f_backr)rrwhyarg this_func parent_funcs rrTrace.globaltrace_trackcallerssE &=44U;I66u||DK67DMM;2 3 r"cRUS:Xa!URU5nSURU'gg)z_Handler for call events. Adds (filename, modulename, funcname) to the self._calledfuncs dict. r r N)r r)rrrrrs rrTrace.globaltrace_countfuncs s0 &=44U;I+,D  i ( r"cHUS:XaURnURRSS5nU(al[U5nUb]URR XV5nU(d:UR (a[SU<SUR<35 UR$gggg)zzHandler for call events. If the code block being entered is to be ignored, returns `None', else returns self.localtrace. r __file__Nz --- modulename: rj) r f_globalsrar0rr rrUrr)rrrrrrr ignore_its rrTrace.globaltrace_lts &=<5m[R"S?5mUU4S@jnURVVs/sH+ofRSA5HnUR5PM M- snnUl URVVs/sH1ofR[R5H nU"U5PM M3 snnUlUR(aqUR (dUR#SB5 [%UR UR SC9n U R'UR(UR*UR,5$[/UR0UR2UR4UR6/5(dUR#SD5 UR4(a3UR2(dUR0(aUR#SE5 UR*(a"UR2(dUR#SF5 UR8cUR#SG5 [;UR2UR0UR4UR6URURUR UR UR<SH9 n UR>(anSSK n UR8n U RCU 5upnURD/URFQ[Hl%SIURDURLURNUSSJ.nOUR8/URFQ[Hl%[RPRSUR85[HRPS'[TRV"UR85n[YUR[5UR8SK5nSSS5 UR8SISSSL.nU R]WUU5 U Re5n URf(d2U R'UR(UR*UR,5 ggs snnfs snnf!,(df  N=f![^a9n[HR`"SM[HRJS<SNU<35 SnANSnAf[ba Nf=f)ONrz --versionversionz trace 2.0)actionr,z Main optionsz(One of these (or --report) must be givenz-cz--count store_truezCount the number of times each line is executed and write the counts to .cover for each module executed, in the module's directory. See also --coverdir, --file, --no-report below.)r-helpz-tz--tracez3Print each line to sys.stdout before it is executedz-lz --listfuncszKeep track of which functions are executed at least once and write the results to sys.stdout after the program exits. Cannot be specified alongside --trace or --count.z-Tz --trackcallsz^Keep track of caller/called pairs and write the results to sys.stdout after the program exits. Modifiersz-rz--reportzGenerate a report from a counts file; does not execute any code. --file must specify the results file to read, which must have been created in a previous run with --count --file=FILEz-Rz --no-reportz^Do not generate the coverage report files. Useful if you want to accumulate over several runs.z-fz--filez+File to accumulate counts over several runs)r/z-Cz --coverdirzDirectory where the report files go. The coverage report for . will be written to file //.coverz-mz --missingz?Annotate executable lines that were not executed with ">>>>>> "z-sz --summaryz\Write a brief summary for each file to sys.stdout. Can only be used with --count or --reportz-gz--timingzQPrefix each line with the time since the program started. Only used while tracingFilterszCan be specified multiple timesz--ignore-moduleappendzqIgnore the given module(s) and its submodules (if it is a package). Accepts comma separated list of module names.)r-defaultr/z --ignore-dirzWIgnore files in the given directory (multiple directories can be joined by os.pathsep).z--moduleFzTrace a module. progname?zfile to run as main program)nargsr/ argumentszarguments to the programstdlib platstdlibc>[RR[RRU55nUR ST5R ST5n[RR U5$)Nz$prefixz $exec_prefix)r r expanduser expandvarsr7r)s _exec_prefix_prefixs rparse_ignore_dirmain..parse_ignore_dirsX GG  rww11!4 5 IIi ) 1 1., Oww""r",z-r/--report requires -f/--file)rKrLzLmust specify one of --trace, --count, --report, --listfuncs, or --trackcallsz8cannot specify both --listfuncs and (--trace or --count)z3--summary can only be used with --count or --reportz3progname is missing: required with the main options)rrrrrKrLrr)r$r __package__ __loader____spec__ __cached__r)rr$rCrFzCannot run file z because: )4argparseArgumentParser add_argumentadd_argument_groupadd_mutually_exclusive_group REMAINDER parse_args ignore_dir sysconfigget_path ignore_modulesplitstripr pathsepreportrFerrorrrmissingrranyrr listfuncs trackcallsr4rrmodulerunpy_get_module_detailsrr7r4argvparentloaderrrrio open_coderrrrRexit SystemExitr) no_report)rGparsergrp_grpoptsr@rrr=r)tr\ module_namemod_namemod_specrglobsrrXr>r?s @@rmainro_s  $ $ &F  I{K  # #N 6 8CT9\&' T9\FHT=EFT>,78  # #K 0C  + + -DdJ|  dM,GHT8>@T<23T;|T;|=>T:l+,  # #I - /C&x!"^HbGH  </1  #.0  8+=+=+-    D $$X. )),7 # $(#5#5O#5a#))+AMOD!%N /19LA(*9L+ /NDO {{yy LL9 :!DIIF$$T\\4<<OO  DJJH I I 4 5 ~~4:: OP ||DJJ JK }} JK djj$**??t7I7Iii  5A ;; --K','@'@'M $H((:4>>:CH& ,,'&oo$" E 77CH''//$--8CHHQKdmm,rwwy$--@-!MM&#" E ue$ iikG >>dllDLL$--H ONX-, H SXXa[#FGG    sC62W28W8C;X &W>2,X> X X Y/Y  YYrr)__doc____all__rarvr r4rOrryrrrrNtimerrrrrr0r>rrrrrurror$r)r"rrss<( % &    ##00d 8rrh  . #T6T6lPId ZFr"