L iTUdZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlmZmZmZddlmZmZmZmZmZddlmZmZddlmZm Z ee Z gZ!de"d <dZ#Gd d Z$Gd d e$Z%Gdde%Z&d4dZ'd5dZ( d6dZ)d7dZ*dgZ+de"d<gZ,de"d<ed8dZ-ed9dZ-d:dZ-d8dZ. d; ddZ0d?d@dZ1dAdZ2dBd Z3d!hZ4dCd"Z5dDd#Z6dEd$Z7dFd%Z8dGd&Z9Gd'd(Z:Gd)d*Z;Gd+d,Z<Gd-d.Z=dHdId/Z> dJ dKd0Z?dLd1Z@e jZBe jZCd!ZD dM dNd2ZEdOd3ZFy)Pz'Control of and utilities for debugging.) annotationsN)IterableIteratorMapping)IOAnyCallableFinaloverload)human_sorted_itemsisolate_module) AnyCallable TWritablez list[str] FORCED_DEBUGcreZdZdZdZ d d dZd dZd dZejddZ dddd Z y) DebugControlz!Control and output for debugging.FNct|tz|_d|_g}|j drF|j t j|j tj|j dr#|j tj|j dr|j ttj||||_ |jj|_y)z4Configure the options and output file for debugging.Fprocesspytestpid) file_namefiltersN)listroptionssuppress_callersshouldappend CwdTrackerfilterProcessTracker PytestTrackeradd_pid_and_tidDebugOutputFileget_oneoutputoutfile raw_output)selfrr%rrs T/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/coverage/debug.py__init__zDebugControl.__init__+sG}|3 % ;;y ! NN:<.. / NN>+22 3 ;;x NN=?11 2 ;;u  NN? +%-- .  ++--c<d|jd|jdS)Nz)rr'r(s r)__repr__zDebugControl.__repr__Es"' '7|DOOCVVWXXr+cB|dk(r |jry||jvS)z@Decide whether to output debug information in category `option`.callersF)rrr(options r)rzDebugControl.shouldHs$ Y 4#8#8%%r+c#bK|j}d|_ d||_y#||_wxYww)z;A context manager to prevent call stacks from being logged.TN)r)r(olds r)without_callerszDebugControl.without_callersNs3## $ ( $'D !CD !s/#/ ,/excc $|jj|dz|I|jjdjtjd||j |j drTtjddjjd}||jjd|d|j drt|jd |jjy) zWrite a line of debug output. `msg` is the line to write. A newline will be appended. If `exc` is provided, a stack trace of the exception will be written after the message.  Nr(rzself: r1outskip) r%writejoin tracebackformat_exception __traceback__rinspectstackf_localsgetdump_stack_framesflush)r(msgr8 caller_selfs r)r@zDebugControl.writeXs #*% ? KK  bggi&@&@sCL]L]&^_ ` ;;v !--/!,Q/88<Br+rcTeZdZdZddZd dZejd dZddd dZ y) NoDebuggingzBA replacement for DebugControl that will never try to do anything.cyrMr_r.s r)r*zNoDebugging.__init__ps r+cy)z'Should we write debug messages? Never.Fr_r2s r)rzNoDebugging.shouldtsr+c#Kdyw)z+A dummy context manager to satisfy the api.Nr_r.s r)r6zNoDebugging.without_callersxs  sNr7ctd)zThis will never be called.z)NoDebugging.write should never be called.)AssertionErrorr(rKr8s r)r@zNoDebugging.write}sHIIr+rQrRrTrVrW) rXrYrZr[r*rr]r^r6r@r_r+r)rarams5L >BJr+raceZdZdZddddZy) DevNullDebugz)A DebugControl that won't write anywhere.Nr7cyrMr_rgs r)r@zDevNullDebug.writes r+rW)rXrYrZr[r@r_r+r)rjrjs 3=A r+rjc0djd|zdzS)zMake a nice header string.z --{:-<60s} format)labels r) info_headerrqs   sU{S0 11r+c#Kt|}|sydtfd|DsJ|D]\}}|gk(rd}|ddd}|xtdx#\tt |dkr ||Extdx\nxtdx\nxt dx\nn|D]}||d d zz} ||yw) zProduce a sequence of formatted lines from info. `info` is a sequence of pairs (label, data). The produced lines are nicely formatted, ready to print. Nc3@K|]\}}t|kywrMlen).0l_ LABEL_LENs r) z!info_formatter..s3das1v !3sz-none-r-r;: r_rm)ralltuplervrSset)inforpdataprefixerzs @r)info_formatterrs :D I 3d3 33 3 ( t 2:D!I;`'r*CD NR/''646ECE)3A#HQC.( IM2F3'' (sCCc\|t|t|D] }|d|y)a,Write a sequence of (label,data) pairs nicely. `write` is a function write(str) that accepts each line of output. `header` is a string to start the section. `info` is a sequence of (label, data) pairs, where label is a str, and data can be a single value, or a list/set/tuple. rmN)rqr)r@headerrlines r)write_formatted_infors3 +f t$ $jr+cptjt||}djd|DS)zIGet a one-line summary of an exception, including class name and message.|c3<K|]}|jywrM)rstrip)rwrxs r)r{zexc_one_line..s.1AHHJ.s)rBformat_exception_onlytyperA)r8liness r) exc_one_liners-  + +DIs ;E 88.. ..r+)z5.*[/\\]pytest-of-.*[/\\]pytest-\d+([/\\]popen-gw\d+)?ztmp:list[tuple[str, str]]_FILENAME_REGEXES_FILENAME_SUBScyrMr_filenames r)short_filenamerr+cyrMr_rs r)rrrr+ctstjD]}tj|dfddl}tjt jj |jdftjdd|EtD]\}}tj|||}tD]\}}|j||}|S)zIShorten a file name. Directories are replaced by prefixes like 'syspath:'zsyspath:rNzcov:ct|dSNrru)pairs r)z short_filename..sc$q'lr+T)keyreverse) rsyspathrcoverageosdirname__file__sortrresubreplace)rpathdirrpatrbeforeafters r)rrs xx 9G  ! !7J"7 8 9rwwx/@/@A6JK!:TJ) 2HCvvc31H 2+ 7MFE''6H 7 Or+c tj|}tjj|j}|j d|}|S#t $rd}Y|St$r}d|}Yd}~|Sd}~wwxYw)z/A one-line summary of a file, for log messages.z bytes, modified zdoes not existzerror: N)rstatdatetime fromtimestampst_mtimest_sizeFileNotFoundError Exception)rsmodsummaryrs r) file_summaryrs7 GGH  --ajj9YYK06 N #" N  A3- N  sA A9!A9)A44A9cgd}tjd|d}|s |D]}tj|fd|}g}|D]n}|jdd} |r| t |j ddz } |j} |r t| } | | d |jz } |j| pd j|S) a^Return a string summarizing the call stack. The string is multi-line, with one line per stack frame. Each line shows the function name, the file name, and the line number: ... start_import_stop : /Users/ned/coverage/trunk/tests/coveragetest.py:95 import_local_file : /Users/ned/coverage/trunk/tests/coveragetest.py:81 import_local_file : /Users/ned/coverage/trunk/coverage/backward.py:159 ... `skip` is the number of closest immediate frames to skip, so that debugging functions can call this and not be included in the result. If `full` is true, then include all frames. Otherwise, initial "boring" frames (ones in site-packages and earlier) are omitted. `short_filenames` will shorten filenames using `short_filename`, to reduce the amount of repetitive noise in stack traces. )zz \bigor.py$z\bsite-packages\bNcBtj||jSrM)rsearchr)firs r)rzshort_stack..sRYYsBKK%@r+z>30sz : z#xrm:r:) rErF itertools dropwhilefunctionidframerrlinenorrA) r?full frame_idsshort_filenamesBORING_PRELUDErFrr frame_inforrs r) short_stackrs:N*1$r)BE ! C'' #@E  E %%d+3/  r***+B/q1 1D&& %h/H 8*Aj//011 T 99U r+cF|jt|dzdzy)z&Print a summary of the stack to `out`.r<)r?r:N)r@rr=s r)rIrI(sIIktax(4/0r+cZtj}||_|j|S)z(`repr(text)`, but limited to `numchars`.)reprlibRepr maxstringrepr)textnumcharsrs r) clipped_reprr-s" AAK 66$<r+cDd}tdddD] }|||z z} |dzS)z-Given a 64-bit id, make a shorter 16-bit one.r@i)range)id64id16offsets r)short_idr4s7 D2r"  &=r+c~ttjd}tjdd|d|}|S)z.A filter to add pid and tid to debug messages.04x5d.r|)r_thread get_identrgetpid)rtids r)r"r"<s@g'') *3 /Ciik" Qse2dV ,D Kr+z$coverage.object_idcd|jjD}dj|jjt |dj d|DS)z.IsD Aq 1& -  # % % As;=z<{klass} @{id:#x}{attrs}>r;c32K|]\}}d|d|yw)rm=Nr_rs r)r{zauto_repr..Ss ;1!AaUm;)klassrattrs)__dict__itemsro __class__rXrrA)r( show_attrss r) auto_reprrGs^MM'')J ' - -nn%% d8gg; ;; . r+ct|tr-|jDcic]\}}|t|c}}St|tt frt |d|DSt|dr:t|jjDcic] \}}d|z| c}}S|Scc}}wcc}}w)z>Turn things which are nearly dict/list/etc into dict/list/etc.c32K|]}t|ywrM)simplify)rwvvs r)r{zsimplify..\s0x|0rrr) isinstancedictrrrrrhasattrr)rrrs r)rrWs!T-.WWY7EAr8B<77 Ae} %tAw0a000 J  0@0@0BC1q!CDD 8Ds B4B: cHtjt|ddddS)EDebug helper to pretty-print data, including SimpleNamespace objects.T)indentcompact sort_dictswidth)pprintpformatrrs r)ppformatr cs >>(1+a$VY ZZr+c,tt|y)rN)printr r s r)pprhs (1+r+c|j}|t|d}|}|D]O}g}|jD]'}|j||j)dj |}Q||zS)aQRun `text` through a series of filters. `filters` is a list of functions. Each takes a string and returns a string. Each is run in turn. After each filter, the text is split into lines, and each line is passed through the next filter. Returns: the final string that results after all of the filters have run. Nr:)rrv splitlinesextendrA)rr clean_textending filter_fnrrs r) filter_textrmsJ #j/# $F D OO% 7D LL4335 6 7yy  &=r+c eZdZdZddZddZy)rz*A class to add cwd info to debug messages.cd|_yrM)cwdr.s r)r*zCwdTracker.__init__s #r+cjtj}||jk7rd|d|}||_|S)z#Add a cwd message for each new cwd.z cwd is now r:)rgetcwdr)r(rrs r)rzCwdTracker.filters6iik $((? r$0DDH r+NrhrrSrQrSrXrYrZr[r*rr_r+r)rrs4$r+rc eZdZdZddZddZy)r z)Track process creation for debug logging.cDtj|_d|_y)NF)rrr did_welcomer.s r)r*zProcessTracker.__init__s  r+cJd}tj}|j|k7rd|jd|d}||_nT|jsHt t dd}d|dt j dd |dzd tjdz}|r d |_||zS|S) z1Add a message about how new processes came to be.r;zNew process: forked z -> r:argvNzNew process: pid=z, executable: zNew process: cmd: zNew process parent pid: T)rrrr rr executablegetppid)r(rwelcomerr"s r)rzProcessTracker.filtersiik 88s?,TXXJd3%rBGDH!!3-D$v^CNN3ERH&thb12,RZZ\, !Kr+Nrhrrr_r+r)r r s3!r+r c eZdZdZddZddZy)r!zr=singleton_modules r)r:z#DebugOutputFile._set_singleton_datasG!++C,<,<= #"4"4w6HI(8 C$$%r+ctjj|j}t ||j dS)zGet the one DebugOutputFile.)NT)rrGrHr@rrB)r;rHs r)r4z#DebugOutputFile._get_singleton_datas3;;??3+;+;<'););\JJr+ct|jtjvrtj|j=yy)z6Delete the one DebugOutputFile, just for tests to use.N)r@rrG)r;s r)_del_singleton_dataz#DebugOutputFile._del_singleton_datas-   s{{ * C,,- +r+c|jJ|jjsJ|jjt||j|jj yy)z9Just like file.write, but filter through all our filters.N)r&closedr@rrrJ)r(rs r)r@zDebugOutputFile.writesQ||'''||"" LL  {4> ? LL   #r+c|jJ|jjs|jjyy)zFlush our file.N)r&rMrJr.s r)rJzDebugOutputFile.flushs4||'''||"" LL   #r+)r&rOrIterable[Callable[[str], str]])NNr_F) r<rOrrPrrOr=rUrQr#)r>r#r=rUrQrR)rQz#tuple[DebugOutputFile | None, bool]rh)rrSrQrR)rXrYrZr[r* classmethodr$r@__annotations__rBr:r4rKr@rJr_r+r)r#r#sC0#' $24 ,,,0 ,  ,  ,,f IL*H!9NJ999 KK .. !!r+r#cxtjd}|j|dz|rt|dyy)z.Write a log message as forcefully as possible.Tr=r:r<r=N)r#r$r@rI)rKrFr>s r)logrT"s7  ! !$ ! /CIIcDj c* r+cfd}|S)z2A class decorator to apply a decorator to methods.ctj|tjD]E\}}||jvr|dk7rs|j dr.|vr3t |||G|S)Nr*ry)rE getmembers isroutiner startswithrF)r;namemethbutnot decoratorprivates r) _decoratorz$decorate_methods.._decorator1sr!,,S'2C2CD 0JD$3<<'z!4??3#7v~ Cy / 0 r+r_)r]r\r^r_s``` r)decorate_methodsr`*s  r+cDtjdfd }|S)z;A function decorator to stop in the debugger for each call.cnddl}tjt_|j |i|Sr)pudbr __stdout__r2 set_trace)argskwargsrcfuncs r)_wrapperzbreak_in_pudb.._wrapperCs+^^  T$V$$r+)rfrrgrrQr functoolswraps)rhris` r) break_in_pudbrm@s'__T%% Or+cdfd }|S)z:A method decorator to debug-log each call to the function.cLtjdfd }|S)Nct|td}|9tjddt t d}t |t|d} rbdjtt|}djd|jD}|dz }||z }|r|r|dz }||z }|dz } r1|d z }|d jtd jz }t t}|d|dd j|d }tj!d j#| |g|i|} r>|d|dd jd| d }tj!d j#|| S)N08drm04dr;z, c3:K|]}dj|yw)z{}={!r}Nrn)rwitems r)r{zCshow_calls.._decorator.._wrapper..ds#W$4I$4$4d$;#Ws()z @ z; T)rr:rSz return )r OBJ_ID_ATTRrrnextOBJ_IDSrFrAmaprrrrCALLSrXr#r$r@)r(rfrgoidextraeargsekwargscallidrKretrh show_args show_return show_stacks r)riz0show_calls.._decorator.._wrapper[s{$ T2C{S)4=*=>k3/E #dD/2))#W #WW WTME  ;t#D#O#O#QRR%[FE6#,a ugR@C  # #D # 1 7 7 <t-d-f-CQvcl!DMM?(3'L'''5;;C@Jr+)r(rrfrrgrrQrrj)rhrirrrs` r)r_zshow_calls.._decoratorZs%     6r+rhrrQrr_)rrrr_s``` r) show_callsrSs> r+cj ddh}hd}hd}dh}d}g}|jD]\ }d} |vrd}nt fd |Drd}|s(t fd |Drtjd d |} |vrt ||kDr |d |dz dz}|j |ft |S)aLFilter environment variables for a debug display. Select variables to display (with COV or PY in the name, or HOME, TEMP, or TMP), and also cloak sensitive values with asterisks. Arguments: env: a dict of environment variable names and values. Returns: A list of pairs (name, value) to show. COVPY>TMPHOMETEMP>APIKEYPASSTOKENSECRET SIGNATURECOVERAGE_PROCESS_CONFIG<FTc3&K|]}|v ywrMr_rwslugrZs r)r{z/relevant_environment_display..s0$0c3&K|]}|v ywrMr_rs r)r{z/relevant_environment_display..s2D44<2rz\w*Nz...)ranyrrrvrr ) envSLUGSINCLUDECLOAKTRUNCATE TRUNCATE_LENto_showvalshowrZs @r)relevant_environment_displayr|sDME%G BE)*HLGYY[ ( c 7?D 0%0 0D 2E22ffUC-xs8l*0 q 01E9C NND#; ' ( g &&r+)rprSrQrS)rIterable[tuple[str, Any]]rQrN)r@zCallable[[str], None]rrSrrrQrR)r8rrQrS)rrSrQrS)rrRrQrR)rrPrQrP)rFFF) r?intrrUrrUrrUrQrS)r)r>rr?rrQrR)2)rrSrrrQrS)rrrQrr)r(rrQrS)rrrQr)rrrQrS)rrrQrR)rrSrrOrQrS)F)rKrSrFrUrQrR)r_F)r]Callable[..., Any]r\rNr^rUrQrr)TFF)rrUrrUrrUrQr)rzMapping[str, str]rQr)Gr[ __future__rrr7r]rrkrErrr rrrrBrDcollections.abcrrrtypingrrr r r coverage.miscr r coverage.typesrrrrQr6rrarjrqrrrrrrrrrIrrr"rrrr rrrr r!r#rTr`rmcountryr{rwrrr_r+r)rsW."    7755<1B  iDDNJ,J* ; 2 (6   $ $/G,()+%*        " ! 5 5 55 5  5p1 **  [  ,  :  a!a!H+!  ,  )//  # &&&& &R!'r+