L i(.dZddlmZddlZddlZddlZddlmZmZddl m Z ddl m Z m Z ddlmZddlmZdd lmZmZmZdd lmZmZmZmZmZmZeeZGd d Ze egdfZGd dZGddeZ GddeZ!GddeZ"y)zSupport for plugins.) annotationsN)IterableIterator) FrameType)AnyCallable) PluginError)isolate_module)CoveragePlugin FileReporter FileTracer)TArc TConfigurable TDebugCtlTLineNo TPluginConfigTSourceTokenLinesceZdZdZdddZ ddZ ddZddZddZddZ dd Z dd Z dd Z dd Z dd Zy)Pluginsz7The currently loaded collection of coverage.py plugins.Ncfg|_i|_g|_g|_g|_d|_||_yN)ordernames file_tracers configurerscontext_switcherscurrent_moduledebug)selfrs ]/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/coverage/plugin_support.py__init__zPlugins.__init__s7+- 02 241379*. c|D]_}||_t|tj|}t |dd}|st d|d|j |}|||ad|_y)z@Load plugin modules, and read their settings from configuration. coverage_initNzPlugin module z' didn't define a coverage_init function)r __import__sysmodulesgetattrr get_plugin_options)rr'configmodulemodr$optionss r load_from_configzPlugins.load_from_config$s )F"(D  v ++f%C#C$?M !$VJ.UV//7G $ ( )#r"c"|D] }|| y)z%Load plugins from callables provided.N)r plugin_initsfns r load_from_callableszPlugins.load_from_callables;s  B tH r"c<|j||jy)zAdd a file tracer plugin. `plugin` is an instance of a third-party plugin class. It must implement the :meth:`CoveragePlugin.file_tracer` method. N) _add_pluginrrplugins r add_file_tracerzPlugins.add_file_tracerCs !2!23r"c<|j||jy)zAdd a configuring plugin. `plugin` is an instance of a third-party plugin class. It must implement the :meth:`CoveragePlugin.configure` method. N)r5rr6s r add_configurerzPlugins.add_configurerLs !1!12r"c<|j||jy)zAdd a dynamic context plugin. `plugin` is an instance of a third-party plugin class. It must implement the :meth:`CoveragePlugin.dynamic_context` method. N)r5rr6s r add_dynamic_contextzPlugins.add_dynamic_contextUs !7!78r"c(|j|dy)zfAdd a plugin that does nothing. This is only useful for testing the plugin support. N)r5r6s r add_noopzPlugins.add_noop^s &r"c|jd|jj}|jru|jj drZ|jj d|jd|t d|j|j}t||}||_d|_ |jj|||j|<||j|yy)zAdd a plugin object. `plugin` is a :class:`CoveragePlugin` instance to add. `specialized` is a list to append the plugin to. .r7zLoaded plugin z: zplugin TN) r __class____name__rshouldwrite LabelledDebugDebugPluginWrapper_coverage_plugin_name_coverage_enabledrappendr)rr7 specialized plugin_namelabelleds r r5zPlugins._add_pluginfs,,-Qv/?/?/H/H.IJ ::$**++H5 JJ  ~d.A.A-DBvjQ R$wt/B/B.E%F SH'9F'2$#'  &!"( ;  "   v & #r"c,t|jSr)boolrrs r __bool__zPlugins.__bool__~DJJr"c,t|jSr)iterrrOs r __iter__zPlugins.__iter__rQr"c |j|S)zReturn a plugin by name.)r)rrKs r getz Plugins.getszz+&&r"r)rzTDebugCtl | NonereturnNone)r' Iterable[str]r*rrWrX)r1zIterable[TCoverageInit]rWrX)r7r rWrX)r7r rJzlist[CoveragePlugin] | NonerWrXrWrN)rWzIterator[CoveragePlugin])rKstrrWr )rB __module__ __qualname____doc__r!r.r3r8r:r<r>r5rPrTrVr0r"r rrsA###  #.- 439'''1'  '0  'r"rc2eZdZdZdddZd dZd dZd dZy) rEz?A Debug writer, but with labels for prepending to the messages.c:t||gz|_||_yr)listlabelsr)rlabelr prev_labelss r r!zLabelledDebug.__init__s;'5'1  r"cDt||j|jS)zz/LabelledDebug.message_prefix..sOxq%$(U*Os)rbjoin enumerate)rprefixess r message_prefixzLabelledDebug.message_prefixs,;;"%zzO9X;NOOOr"c^|jj|j|y)z/Write `message`, but with the labels prepended.N)rrDrp)rmessages r rDzLabelledDebug.writes' D//127)<=r"N)r0)rcr[rrrdrY)rcr[rWrErWr[)rrr[rWrX)rBr\r]r^r!rfrprDr0r"r rErEsI=P >r"rEcTeZdZdZd fd Zd dZd dZd dZd dZddZ ddZ xZ S)rFz:Wrap a plugin, and use debug to report on what it's doing.c>t|||_||_yr)superr!r7r)rr7rrAs r r!zDebugPluginWrapper.__init__s   r"c|jj|}|jjd|d||r*|jj d|}t ||}|S)Nz file_tracer() --> file )r7 file_tracerrrDrfDebugFileTracerWrapper)rfilenametracerrs r rzzDebugPluginWrapper.file_tracersd((2 <|6&DE JJ((5 )=>E+FE:F r"c|jj|}t|tsJ|jj d|d||r+|jj d|}t|||}|S)Nzfile_reporter(rxry)r7 file_reporter isinstancer rrDrfDebugFileReporterWrapper)rr|reporterrs r rz DebugPluginWrapper.file_reportersv;;,,X6(L111 >(VH<HI JJ((5 )=>E/(EJHr"c~|jj|}|jjd|d||S)Nzdynamic_context(rx)r7dynamic_contextrrD)rframecontexts r rz"DebugPluginWrapper.dynamic_contexts;++--e4 +E9F7+FGr"c~|jj|}|jjd|d||S)Nzfind_executable_files(rx)r7find_executable_filesrrD)rsrc_direxecutable_filess r rz(DebugPluginWrapper.find_executable_filess?;;< )r}source_filenamerrD)r sfilenames r rz&DebugFileTracerWrapper.source_filenames4KK//1  1)?@r"cv|jj}|jjd||S)Nz"has_dynamic_source_filename() --> )r}has_dynamic_source_filenamerrD)rhass r rz2DebugFileTracerWrapper.has_dynamic_source_filenames3kk557 =cWEF r"c|jj||}|jjdj ||j |||S)Nz*dynamic_source_filename({!r}, {}) --> {!r})r}dynamic_source_filenamerrDformatr)rr|rdyns r rz.DebugFileTracerWrapper.dynamic_source_filenamesSkk11(EB  8 ? ?  '   r"c|jj|}|jjd|j |d||S)Nzline_number_range(rx)r}line_number_rangerrDr)rrpairs r rz(DebugFileTracerWrapper.line_number_rangesG{{,,U3 -d.>.>u.E-FfTHUV r"N)r}r rrErWrX)rrrWr[rsrZ)r|r[rrrWr)rrrWztuple[TLineNo, TLineNo]) rBr\r]r^r!rrrrrr0r"r r{r{s##.   r"r{cteZdZdZd fd ZddZddZddZddZddZ ddZ dd Z dd Z dd Z dd ZxZS)rzA debugging `FileReporter`.c@t||||_||_yr)rvr!rr)rr|rrrAs r r!z!DebugFileReporterWrapper.__init__s "   r"cv|jj}|jjd||S)Nzrelative_filename() --> )rrelative_filenamerrDrrets r rz*DebugFileReporterWrapper.relative_filenames3mm--/ 3C7;< r"cv|jj}|jjd||S)Nz lines() --> )rlinesrrDrs r rzDebugFileReporterWrapper.liness2mm!!# <w/0 r"cv|jj}|jjd||S)Nzexcluded_lines() --> )rexcluded_linesrrDrs r rz'DebugFileReporterWrapper.excluded_liness3mm**, 089 r"c~|jj|}|jjd|d||S)Nztranslate_lines(rx)rtranslate_linesrrD)rrrs r rz(DebugFileReporterWrapper.translate_lines s;mm++E2 +E9F3'BC r"c~|jj|}|jjd|d||S)Nztranslate_arcs(rx)rtranslate_arcsrrD)rarcsrs r rz'DebugFileReporterWrapper.translate_arcss:mm**40 ?4(&@A r"cv|jj}|jjd||S)Nzno_branch_lines() --> )rno_branch_linesrrDrs r rz(DebugFileReporterWrapper.no_branch_liness3mm++- 1#9: r"cv|jj}|jjd||S)Nzexit_counts() --> )r exit_countsrrDrs r rz$DebugFileReporterWrapper.exit_countss3mm'') -cW56 r"cv|jj}|jjd||S)Nz arcs() --> )rrrrDrs r rzDebugFileReporterWrapper.arcss2mm  " ;sg./ r"c|jj}|jjdt |d|S)Nz source() --> z chars)rsourcerrDlenrs r rzDebugFileReporterWrapper.source#s8mm""$ =S &9: r"ct|jj}|jj dt |d|S)Nzsource_token_lines() --> z tokens)rarsource_token_linesrrDrrs r rz+DebugFileReporterWrapper.source_token_lines(s>4==3356 4SXJgFG r")r|r[rr rrErWrXrs)rW set[TLineNo])rzIterable[TLineNo]rWr)rzIterable[TArc]rW set[TArc])rWzdict[TLineNo, int])rWr)rWr)rBr\r]r^r!rrrrrrrrrrrrs@r rrs=%          r"r)#r^ __future__rros.pathr&collections.abcrrtypesrtypingrrcoverage.exceptionsr coverage.miscr coverage.pluginr r r coverage.typesrrrrrrr TCoverageInitrErFr{rr0r"r rs"  . +(DDddBo'o'd'D) >>*(&(&V$Z$N8|8r"