idNPdZddlmZddlZddlZddlZddlmZddlm Z m Z m Z m Z m Z mZmZmZmZmZmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd l m!Z!m"Z"dd l#m$Z$ddl%m&Z&ddl'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.e"eZ ddl/m0Z0m1Z1dZ2nK#e3$rCej4ddkr*ej56dej7ddZ2YnwxYwedZ8GddZ9dS)z#Raw data collector for coverage.py.) annotationsN) FrameType) castAnyCallableDictListMappingOptionalSetTupleTypeTypeVar)env)CoverageConfig) CoverageData) short_stack)FileDisposition) ConfigError)human_sorted_itemsisolate_module)CoveragePlugin)PyTracer)TArcTFileDispositionTLineNo TTraceDataTTraceFnTTracerTWarnFn)CTracerCFileDispositionTCOVERAGE_TEST_TRACERcz:*** COVERAGE_TEST_TRACER is 'c' but can't import CTracer! FTceZdZUdZgZded<hdZd@dZdAdZdBdZ dAdZ dCdZ dCd Z dDd"Z dEd)ZdCd*ZdCd+ZdCd,ZdCd-ZdFd.ZdGd0ZdHd3Zejd45dId7ZdJd;ZdKd>ZdFd?Zd4S)L CollectoraCollects trace data. Creates a Tracer object for each thread, since they track stack information. Each Tracer points to the same shared data, contributing traced data points. When the Collector is started, it creates a Tracer for the current thread, and installs a function to create Tracers for each new thread started. When the Collector is stopped, all active Tracers are stopped. Threads started while the Collector is stopped will never have Tracers associated with them. zList[Collector] _collectors>geventeventletgreenlet should_trace,Callable[[str, FrameType], TFileDisposition] check_include Callable[[str, FrameType], bool]should_start_context.Optional[Callable[[FrameType], Optional[str]]] file_mapperCallable[[str], str]timidboolbranchwarnr concurrency List[str]returnNonec ||_||_||_||_||_||_||_|d|_d|_t|_ d|_ ||d} tr|sd} | r't|_t|_d|_d|_n&t&|_t(|_d|_d|_t+|j} | t,jz } | r4dt3| } t5d| | |jz} t9| dkr4dt3| } t5d| d}d} d | vrd }d dl}|j|_ n2d | vrd }d dl}|j j|_ nd | vrd }d dl!}|j|_ d | vrd}n(#tD$r}d|d}t5||d}~wwxYw|j rJtG|jds5t5d$||%|s| s d dl}||_|&dS)aCreate a collector. `should_trace` is a function, taking a file name and a frame, and returning a `coverage.FileDisposition object`. `check_include` is a function taking a file name and a frame. It returns a boolean: True if the file should be traced, False if not. `should_start_context` is a function taking a frame, and returning a string. If the frame should be the start of a new context, the string is the new context. If the frame should not be the start of a new context, return None. `file_mapper` is a function taking a filename, and returning a Unicode filename. The result is the name that will be recorded in the data file. If `timid` is true, then a slower simpler trace function will be used. This is important for some environments where manipulation of tracing functions make the faster more sophisticated trace function not operate properly. If `branch` is true, then branches will be measured. This involves collecting data on which statements followed each other (arcs). Use `get_arc_data` to get the arc data. `warn` is a warning function, taking a single string message argument and an optional slug argument which will be a string or None, to be used if a warning needs to be issued. `concurrency` is a list of strings indicating the concurrency libraries in use. Valid values are "greenlet", "eventlet", "gevent", or "thread" (the default). "thread" can be combined with one of the other three. Other values are ignored. NFTz, zUnknown concurrency choices: r%z"Conflicting concurrency settings: nothingr,rr+r*threadz Couldn't trace with concurrency=z, the module isn't installed.concur_id_funczACan't support concurrency={} with {}, only threads are supported.)'r-r/r1r3r7r8r9 threadingstatic_contextroriginr@ HAS_CTRACERr! _trace_classr"file_disposition_classsupports_plugins packed_arcsrrsetrCONCURRENCY_CHOICESjoinsortedr LIGHT_THREADSlenr, getcurrenteventlet.greenthread greenthreadr* ImportErrorhasattrformat tracer_namereset)selfr-r/r1r3r5r7r8r9 use_ctracer concurrenciesunknownshow light_threads do_threadingtriedr,r+r*exmsgrAs G/opt/cloudlinux/venv/lib/python3.11/site-packages/coverage/collector.py__init__zCollector.__init__Ls^)*$8!&  & "-1!mm " ( ;  u K  % 'D *:D '$(D !#D   (D *9D '$)D !$D D,-- ."DD  F99VG__--DDdDDEE E%(:: }   ! !99VM2233DI4IIJJ J  +]**"&.&9##},,"++++&.&:&E##]**  &,&7#=((#  + + +YUYYYCc"" * +   wt/@BR'S'S SZZ4++--   '} '    &DN s+AF;; G GG strcTdt|dd|dS)Nz)idrUrWs ra__repr__zCollector.__repr__s0E"T((EEE0@0@0B0BEEEEcovdatarcontext Optional[str]c`||_||_|j|jdS)z!Use `covdata` for recording data.N)rlrB set_context)rWrlrms rause_datazCollector.use_datas0 %   !455555rkc|jjS)z0Return the class name of the tracer we're using.)rE__name__ris rarUzCollector.tracer_names ))rkc|jD]}||jD]}|dS)z * * 4"&"3F  6; ' ' .#~F  6? + + 6#'#5F 61 2 2 D*.*CF ' 6+ , , 8$($7F ! 6+ , , 8$($7F ! \\^^ F### rkframereventargrOptional[TTraceFn]cttjd|}|r ||||}|S)z0Called on new threads, installs the real tracer.N)syssettracer)rWrrrrs ra_installation_tracezCollector._installation_trace9sG T!%!3!3!5!5  'E5#&&B rkcZ|jr|jdg|_g}tj}|r$t |dd}|rt |dg} |}n,#|jr|jdxYw|j||D];\\}}}} |||||#t$r} td| d} ~ wwxYw|j r!|j |j dSdS)z#Start collecting trace information.__self__Ntraces)linenoz3fullcoverage must be run with the C trace function.)r)pauserxrgettracegetattrrresumer TypeError RuntimeErrorrArr) rWtraces0fn0tracer0rrrrrr_s rarzCollector.startFs   )  R & & ( ( ( EGlnn  9c:t44G 9!'8R88 ##%%BB  . $++---  %%%,3 b b ' UE3 b5%V44444 b b b"#XYY_aa b > > N # #D$< = = = = = > >s$*A??)B(C!! D+C;;Dc4|jd|ur3td|jD]}td|d|j||j|jr!|jddSdS)z"Stop collecting trace information.rzself._collectors:z  N)r)printrCrpopr)rWr$s rastopzCollector.stopns  B t + + % & & &% . .,1,,!(,,----     *  R ' ' ) ) ) ) ) * *rkcJ|jD]w}||}|rKtdt |D]\}}t|dd|x|jr|jddSdS)z+Pause tracing, but be prepared to `resume`.z Coverage.py tracer stats:z>20rfN)rxr get_statsrritemsrAr)rWr{statskvs rarzCollector.pausesl + +F KKMMM$$&&E +3444.u{{}}==++DAqQ///a//**** > * N # #D ) ) ) ) ) * *rkc|jD]}||jr!|j|jdS|dS)zResume tracing after a `pause`.N)rxrrArrr)rWr{s rarzCollector.resumescl  F LLNNNN > ! N # #D$< = = = = =    rkc>td|jDS)zkHas any activity been traced? Returns a boolean, True if any trace function was invoked. c3>K|]}|VdS)N)activity).0r{s ra z&Collector._activity..s,@@6??$$@@@@@@rk)anyrxris ra _activityzCollector._activitys# @@4<@@@@@@rk new_contextc||jr|j}|r|d|zz }n|}|j|dS)z Switch to a new dynamic context.|N) flush_datarBrlrp)rWrrms rarzCollector.switch_contexts`    ")G -3,,!G   )))))rk dispositionrc~|j}|j}|j}|d|dd|_d|_dS)z.Disable the plugin mentioned in `disposition`.zDisabling plug-in z due to previous exceptionFN) file_tracer_coverage_plugin_coverage_plugin_namer8_coverage_enabledtrace)rWrrplugin plugin_names rarzCollector.disable_pluginsN!- -2  P{PPPQQQ#( ! rkN)maxsizefilenamec,||S)zBA locally cached version of file names mapped through file_mapper.)r3)rWrs racached_mapped_filezCollector.cached_mapped_files)))rkrzMapping[str, T] Dict[str, T]cd}tdD]>} t|}n#t$r }|}Yd}~7d}~wwxYw|fd|DS)zz.Collector.mapped_file_dict..s2EEE$!Q1E''**AEEErk)rangelistrr)rWrz runtime_err_rr_s` ramapped_file_dictzCollector.mapped_file_dicts  q  A QWWYY  ! ! !  !  EEEE%EEEEs!9 AA  ArrcD|j|jdS)z1Record that `plugin` was disabled during the run.N)raddr)rWrs raplugin_was_disabledzCollector.plugin_was_disableds" !!&">?????rkcsdSjrjri}ttt t tfj}| D]I\}}g}|D]:}|dz}|dzdz }|dzr|dz}|dzr|dz}| ||f;|||<Jn7ttt ttfj}j |ndttt t tfj} j | fdj D} j | d S) zSave the collected data to our associated `CoverageData`. Data may have also been saved along the way. This forces the last of the data to be saved. Returns True if there was data to save, False if not. Fillrlc.i|]\}}|jv||Sr)rrs rarz(Collector.flush_data..s7   Q--- q---rkT)rr7rHrrrcr intrurrr rrladd_arcsr add_linesradd_file_tracersr|) rWarc_data packed_datafnamepackedstuplespackedl1l2 line_datars ` rarzCollector.flush_datas~~ 5 ; E B35"4SX #6 BB &1&7&7&9&9 - -NE7F")00#g-$ 62=!W-%"HB!W-%"HB r2h////&,HUOO - S$t*_ 5tyAA L ! !$"7"7"A"A B B B BT#s3x-0$)<&>&>&>P****& * * * *!!!!AAAA * * * *""""Y&&&***'&*FFFF(@@@@++++++rkr():r __future__rrosrtypesrtypingrrrrr r r r r rrcoveragercoverage.configr coverage.datarcoverage.debugrcoverage.dispositionrcoverage.exceptionsr coverage.miscrrcoverage.pluginrcoverage.pytracerrcoverage.typesrrrrrrr coverage.tracerr!r"rDrRgetenvstderrwriteexitr&r(rrkrars*)"""""" ******&&&&&&&&&&&&000000++++++<<<<<<<<******&&&&&&^B99999999KK   ry'((C// VWWW KKK  GCLLHHHHHHHHHHs BACC