qh]u dZddlmZddlZddlZddlZddlmZddlm 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  ||_||_||_||_||_||_||_t|jtsJd|j|d|_ d|_ t|_ d|_ ||d} tr|sd} | r't|_t"|_d|_d|_n&t*|_t,|_d|_d|_t/|j} | t0jz } | r4dt7| } t9d| | |jz} t=| dkr4dt7| } t9d| d}d } d | vrd }d dl}|j |_ n2d | vrd }d dl!}|j"j |_ nd | vrd }d dl#}|j |_ d| vrd}n(#tH$r}d|d}t9||d}~wwxYw|j rJtK|jds5t9d&||'|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. zExpected a list: 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 isinstancelist 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*exmsgrCs /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/coverage/collector.py__init__zCollector.__init__Ls^)*$8!&  &$*D11[[3[tGW3[3[[[1 "-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 sAG'' H 1HH strcTdt|dd|dS)Nz)idrWrYs rc__repr__zCollector.__repr__s0E"T((EEE0@0@0B0BEEEEcovdatarcontext Optional[str]c`||_||_|j|jdS)z!Use `covdata` for recording data.N)rnrD set_context)rYrnros rcuse_datazCollector.use_datas0 %   !455555rmc|jjS)z0Return the class name of the tracer we're using.)rG__name__rks rcrWzCollector.tracer_names ))rmc|jD]}||jD]}|dS)z * * 4"&"3F  6; ' ' .#~F  6? + + 6#'#5F 61 2 2 D*.*CF ' 6+ , , 8$($7F ! 6+ , , 8$($7F ! \\^^ F### rmframereventargrOptional[TTraceFn]cttjd|}|r ||||}|S)z0Called on new threads, installs the real tracer.N)syssettracer)rYrrrrs rc_installation_tracezCollector._installation_trace9sG T!%!3!3!5!5  'E5#&&B rmcZ|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)pauserzrgettracegetattrrresumer TypeError RuntimeErrorrCrr) rYtraces0fn0tracer0rrrrrras rcrzCollector.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;;Dc|jsJ|jd|ur3td|jD]}td|d|j|jd|usJd|d|jd||j|jr!|jddSdS)z"Stop collecting trace information.rzself._collectors:z  z!Expected current collector to be z , but it's N)r)printrErpopr)rYr$s rcstopzCollector.stopns  B t + + % & & &% . .,1,,!(,,----#t+++ [ [ [4CSTVCW [ [,++     *  R ' ' ) ) ) ) ) * *rmcJ|jD]w}||}|rKtdt |D]\}}t|dd|x|jr|jddSdS)z+Pause tracing, but be prepared to `resume`.z Coverage.py tracer stats:z>20rhN)rzr get_statsrritemsrCr)rYr}statskvs rcrzCollector.pausesl + +F KKMMM$$&&E +3444.u{{}}==++DAqQ///a//**** > * N # #D ) ) ) ) ) * *rmc|jD]}||jr!|j|jdS|dS)zResume tracing after a `pause`.N)rzrrCrrr)rYr}s rcrzCollector.resumescl  F LLNNNN > ! N # #D$< = = = = =    rmc>td|jDS)zkHas any activity been traced? Returns a boolean, True if any trace function was invoked. c3>K|]}|VdS)N)activity).0r}s rc z&Collector._activity..s,@@6??$$@@@@@@rm)anyrzrks rc _activityzCollector._activitys# @@4<@@@@@@rm new_contextc||jr|j}|r|d|zz }n|}|j|dS)z Switch to a new dynamic context.|N) flush_datarDrnrr)rYrros rcrzCollector.switch_contexts`    ")G -3,,!G   )))))rm dispositionrc|j}|J|j}|j}|d|dd|_d|_dS)z.Disable the plugin mentioned in `disposition`.NzDisabling plug-in z due to previous exceptionF) file_tracer_coverage_plugin_coverage_plugin_namer8_coverage_enabledtrace)rYrrplugin plugin_names rcrzCollector.disable_pluginsZ!- &&&-2  P{PPPQQQ#( ! rmN)maxsizefilenamec,||S)zBA locally cached version of file names mapped through file_mapper.)r3)rYrs rccached_mapped_filezCollector.cached_mapped_files)))rmr|Mapping[str, T] Dict[str, T]cd}tdD]>} t|}n2#t$r }|}Yd}~7d}~wwxYwt |t sJ|fd|DS)zz.Collector.mapped_file_dict..s2EEE$!Q1E''**AEEErm)rangerBrrrA Exception)rYr| runtime_err_rras` rcmapped_file_dictzCollector.mapped_file_dicts  q  A QWWYY  ! ! !  ! k955 5 55 EEEE%EEEEs!9 AA  ArrcD|j|jdS)z1Record that `plugin` was disabled during the run.N)raddr)rYrs rcplugin_was_disabledzCollector.plugin_was_disableds" !!&">?????rmcsdSjrjri}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 rcrz(Collector.flush_data..s7   Q--- q---rmT)rr7rJrrrer intrwrrr rrnadd_arcsr add_linesradd_file_tracersr~) rYarc_data packed_datafnamepackedstuplespackedl1l2 line_datars ` rcrzCollector.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(@@@@++++++rmr():r __future__rrosrtypesrtypingrrrrr r r r r rrcoveragercoverage.configr coverage.datarcoverage.debugrcoverage.dispositionrcoverage.exceptionsr coverage.miscrrcoverage.pluginrcoverage.pytracerrcoverage.typesrrrrrrr coverage.tracerr!r"rFrTgetenvstderrwriteexitr&r(rrmrcrs*)"""""" ******&&&&&&&&&&&&000000++++++<<<<<<<<******&&&&&&^B99999999KK   ry'((C// VWWW KKK  GCLLHHHHHHHHHHs BACC