L ilerdZddlmZddlZddlZddlZddlZddlZddlZddl Zddl Z ddl m Z ddl mZmZmZmZddlmZddlmZmZmZddlmZmZdd lmZmZmZmZm Z m!Z!eeZGd d ejDZ#e#ezZ$gd Z%d gZ&ddgZ'Gddee!Z(ddZ)ddZ*ddZ+ddZ, ddZ-y)zConfig file for coverage.py) annotationsN)Iterable)AnyCallableFinalMapping) ConfigError)human_sorted_itemsisolate_modulesubstitute_variables)TomlConfigParserTomlDecodeError)TConfigSectionInTConfigSectionOut TConfigurableTConfigValueInTConfigValueOut TPluginConfigceZdZdZd fd Z d dfd Zdfd Zdfd ZddZdfd Z ddZ dfd Z dd Z dd Z dd ZxZS)HandyConfigParserz#Our specialization of ConfigParser.crt|ddg|_|r|jjdyy)zCreate the HandyConfigParser. `our_file` is True if this config file is specifically for coverage, False if we are examining another config file (tox.ini, setup.cfg) for possible settings. N) interpolationz coverage:)super__init__section_prefixesappend)selfour_file __class__s U/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/coverage/config.pyrzHandyConfigParser.__init__%s; t,!,    ! ! ( ( , c&t||dS)z-Read a file name as UTF-8 configuration data.zutf-8)encoding)rread)r filenamesencoding_unusedr s r!r%zHandyConfigParser.read2s w|I|88r"c\|jD]}||z}t| |}|s|cSy)z!Get the actual name of a section.N)rr has_section)rsectionsection_prefix real_sectionhasr s r!r,zHandyConfigParser.real_section:s?"33 $N)G3L'%l3C##  $ r"cL|j|}|t| ||Sy)NF)r,r has_option)rr*optionr,r s r!r/zHandyConfigParser.has_optionCs.((1  #7%lF; ;r"c6t|j|SN)boolr,)rr*s r!r)zHandyConfigParser.has_sectionIsD%%g.//r"cd|j|}|t| |Std|)Nz No section: )r,roptionsr )rr*r,r s r!r5zHandyConfigParser.optionsLs:((1  #7?<0 0L 455r"c`i}|j|D]}|j||||<|S)z/Get the contents of a section, as a dictionary.)r5get)rr*dopts r! get_sectionzHandyConfigParser.get_sectionRs8(*<<( ,CXXgs+AcF ,r"c|jD]}||z}t| ||sntd|d|t|||g|i|}t |t j}|S)aGet a value, replacing environment variables also. The arguments are the same as `ConfigParser.get`, but in the found value, ``$WORD`` or ``${WORD}`` are replaced by the value of the environment variable ``WORD``. Returns the finished value. z No option z in section: )rrr/r r7r osenviron) rr*r0argskwargsr+r,vr s r!r7zHandyConfigParser.getYs#33 ON)G3Lw!,7 O  6*M'MN N\6CDCFC BJJ /r"c<|j||}t|S)zFix up a file path setting.)r7process_file_value)rr*r0paths r!getfilezHandyConfigParser.getfilensxx(!$''r"c|j||}g}|jdD]<}|jdD]&}|j}|s|j|(>|S)zRead a list of strings. The value of `section` and `option` is treated as a comma- and newline- separated list of strings. Each value is stripped of white space. Returns the list of strings.  ,)r7splitstripr)rr*r0 value_listvalues value_linevalues r!getlistzHandyConfigParser.getlistssnXXgv. $**40 )J#))#. ) MM%( ) )  r"c\|j||}t|||jS)zRead a list of full-line regexes. The value of `section` and `option` is treated as a newline-separated list of regexes. Each value is stripped of white space. Returns the list of strings. )r7process_regexlist splitlines)rr*r0 line_lists r! getregexlistzHandyConfigParser.getregexlists,HHWf-  &)2F2F2HIIr")rr3returnNoner2)r&z Iterable[str]r' str | NonerT list[str])r*strrTrV)r*rXr0rXrTr3)r*rXrTr3)r*rXrTrW)r*rXrTr) r*rXr0rXr>rr?rrTrX)r*rXr0rXrTrX)r*rXr0rXrTrW)__name__ __module__ __qualname____doc__rr%r,r/r)r5r:r7rDrNrS __classcell__)r s@r!rr"s_- - '+9 9$9  9 06 *( $ Jr"r)z3#\s*(pragma|PRAGMA)[:\s]?\s*(no|NO)\s*(cover|COVER)z9^\s*(((async )?def .*?)?\)(\s*->.*?)?:\s*)?\.\.\.\s*(#|$)zif (typing\.)?TYPE_CHECKING:z5#\s*(pragma|PRAGMA)[:\s]?\s*(no|NO)\s*(branch|BRANCH)zwhile (True|1|False|0):zif (True|1|False|0):ceZdZUdZddZhdZhdZddZddZddZ hdZ d e d <hd Z gd Z d dd ZddZddZddZddZddZd dZed!dZy)"CoverageConfigzCoverage.py configuration. The attributes of this class are the various settings that control the operation of coverage.py. cg|_g|_d|_d|_d|_d|_d|_d|_g|_d|_ d|_ d|_ d|_ g|_ d|_g|_d|_d|_g|_g|_d|_g|_g|_d|_d|_g|_g|_d|_d|_t:dd|_g|_d|_ d|_!d|_"d|_#d|_$d|_%tLdd|_'tPdd|_)g|_*d|_+d|_,d|_-d|_.d|_/d|_0d|_1d|_2d|_3d|_4d|_5d|_6d|_7d |_8d |_9d|_:d|_;d |_<d|_=i|_>i|_?y) z:Initialize the configuration attributes to their defaults.NFz .coveragegrhtmlcovzCoverage reportz coverage.xmlcz coverage.jsonz coverage.lcov)@config_files_attemptedconfig_files_read config_file_config_contents_include_omitbranch command_line concurrencycontextcore cover_pylib data_filedebug debug_filedisable_warningsdynamic_contextparallelpatchpluginsrelative_files run_includerun_omitsigtermsource source_pkgs source_dirstimid_crashDEFAULT_EXCLUDE exclude_list exclude_also fail_underformat ignore_errorsinclude_namespace_packagesreport_include report_omitDEFAULT_PARTIAL_ALWAYSpartial_always_listDEFAULT_PARTIAL partial_list partial_also precisionreport_contexts show_missing skip_covered skip_emptysort extra_csshtml_dirhtml_skip_coveredhtml_skip_empty html_title show_contexts xml_outputxml_package_depth json_outputjson_pretty_printjson_show_contexts lcov_outputlcov_line_checksumspathsplugin_optionsrs r!rzCoverageConfig.__init__s24#,.'+.2   (,&(#' $  $ " &*+-+/ " "$ #&(#%  (, &(&( "& ,A.')"& "*/'04-1#9!#< +A.')15!! $ &*! .2,0+")!#+!&"'+#( ,. =?r">rprurvryrkrrxr>r{TroFrqFr}Fc |jD]6\}}| ||jvrt|tr|g}t |||8y)z!Read config values from `kwargs`.N)items MUST_BE_LIST isinstancerXsetattr)rr?kr@s r! from_argszCoverageConfig.from_args sJLLN $DAq})))jC.@Aa#  $r"c tjj|\}}|dk(r t|}n t |}|j j tjj| |j|}|sy|jjttjj|d} |j D]} |j"|g| } | sd}  t'j(t*} |j D]-} | dj-d\} }| | j/|/| j1D]T\} }|j3| }|st+|j5| |z D]}|d j7|||V|j9d r7|j5d D]#}|j;d ||j<|<d} %|j>D]4}|j9|s|jA||jB|<d} 6|rd}n| }|rPtjj||_"tG|d 5}|j|_$ddd|S|S#tjtf$r}td|d||d}~wwxYw#t$$r}td|d||d}~wwxYw#1swY|SxYw) aRead configuration from a .rc file. `filename` is a file name to read. `our_file` is True if this config file is specifically for coverage, False if we are examining another config file (tox.ini, setup.cfg) for possible settings. Returns True or False, whether the file could be read, and it had some coverage.py settings in it. z.tomlzCouldn't read config file : NFT:z0Unrecognized option '[{}] {}=' in config file {}rrb)%r<rCsplitextr rrcrabspathr% configparserErrorrr rdextendmapCONFIG_FILE_OPTIONS_set_attr_from_config_option ValueError collections defaultdictsetrHaddrr,r5rr)rNrrvr:rreopenrf)rfilenamewarnr_extcp files_readerrany_set option_specwas_set all_optionsr*r0r5r,unknownpluginusedfs r! from_filezCoverageConfig.from_file(s!!(+3 '>!(+B"8,B ##**277??8+DE W*J %%c"''//:&FG W#77 # ;$;;BMM"G #"--c2 33 -K)!n2237OGV  $ $V , -!, 1 1 3  GW??73L"2::g#67'AGJQQ(#$  >>' "**W- %'ZZ%@ 6"  ll F~~f%.0nnV.D##F+  DD !wwx8D h% 1()% 1 t w""O4 W :8*BseLMSV V W W :8*BseLMSV V WV 1 sB8J $K 1K 6K.K1KK K+K&&K+.K8c,tj|S)z#Return a copy of the configuration.)copydeepcopyrs r!rzCoverageConfig.copy}s}}T""r">geventthreadeventletgreenletmultiprocessingzFinal[set[str]]CONCURRENCY_CHOICES>rrr)5)riz run:branchboolean)rjzrun:command_line)rkzrun:concurrencylist)rlz run:context)rmzrun:core)rnzrun:cover_pylibr)roz run:data_filefile)rpz run:debugr)rqzrun:debug_filer)rrzrun:disable_warningsr)rszrun:dynamic_context)rtz run:parallelr)ruz run:patchr)rvz run:pluginsr)rwzrun:relative_filesr)rxz run:includer)ryzrun:omitr)rzz run:sigtermr)r{z run:sourcer)r|zrun:source_pkgsr)r}zrun:source_dirsr)r~z run:timidr)rz run:_crash)rzreport:exclude_lines regexlist)rzreport:exclude_alsor)rzreport:fail_underfloat)rz report:format)rzreport:ignore_errorsr)rz!report:include_namespace_packagesr)rzreport:partial_branches_alwaysr)rzreport:partial_branchesr)rzreport:partial_alsor)rzreport:precisionint)rzreport:contextsr)rzreport:includer)rz report:omitr)rzreport:show_missingr)rzreport:skip_coveredr)rzreport:skip_emptyr)rz report:sort)rzhtml:extra_css)rzhtml:directoryr)rzhtml:skip_coveredr)rzhtml:skip_emptyr)rz html:title)rzhtml:show_contextsr)rz xml:outputr)rzxml:package_depthr)rz json:outputr)rzjson:pretty_printr)rzjson:show_contextsr)rz lcov:outputr)rzlcov:line_checksumsrc|jd\}}|j||r$t|d|}t|||||yy)ztSet an attribute on self if it exists in the ConfigParser. Returns True if the attribute was set. rr7TF)rHr/getattrr)rrattrwheretype_r*r0methods r!rz+CoverageConfig._set_attr_from_config_optionsO ++c* ==& )R3ug/F D$w 7 8r"c:|jj|iS)z:Get a dictionary of options for the plugin named `plugin`.)rr7)rrs r!get_plugin_optionsz!CoverageConfig.get_plugin_optionss""&&vr22r"c|dk(r\i|_t|tsJ|jD]/\}}t|tsJt ||j|<1y|j D]}|dd\}}||k(st|||y|jd\}} } | r.||jvr ||jj|i| <ytd|)aBSet an option in the configuration. `option_name` is a colon-separated string indicating the section and option name. For example, the ``branch`` option in the ``[run]`` section of the config file would be indicated with `"run:branch"`. `value` is the new value for the option. rNrNo such option: ) rrrrrrrr partitionrvr setdefaultr ) r option_namerMrr@rrr plugin_namerkeys r! set_optionzCoverageConfig.set_options ' !DJeW- --  (1!!X... $Q 1  (  33 K%bq/KD% #dE*  *33C8 Q ;$,,.CHD   * *; ;C @ ,[O<==r"c8|dk(r |jS|jD]}|dd\}}||k(st||cS|jd\}}}|r9||jvr+|j j |ij |Std|)a<Get an option from the configuration. `option_name` is a colon-separated string indicating the section and option name. For example, the ``branch`` option in the ``[run]`` section of the config file would be indicated with `"run:branch"`. Returns the value of the option. rNrrr)rrrrrvrr7r )rrrrrrrrs r! get_optionzCoverageConfig.get_options ' !::  33 +K%bq/KD% #tT** + *33C8 Q ;$,,.&&**;;??D D,[O<==r"c |jjDcic]\}}||Dcgc] }t|c}!c}}}|_|xj|jz c_|xj |j z c_d|jvrd|_t|j}||jz }|r(djt|}td|||jz}t!|dkDr(djt|}td|ycc}wcc}}}w)z7Make final adjustments to settings to make them usable. subprocessTz, zUnknown concurrency choices: rz"Conflicting concurrency settings: N)rrrBrrrrrurtrrkrjoinsortedr LIGHT_THREADSlen)rrr@r concurrenciesrshow light_threadss r! post_processzCoverageConfig.post_process/sHL HXHXHZ[[1a;A,Q/;;[  T... T... 4:: % DMD,,- $":":: 99VG_-D =dVDE E%(:(:: }  !99VM23D B4&IJ J "<[s D9D4D94D9cVtd|jjDS)z:Make a list of (name, value) pairs for writing debug info.c3NK|]\}}|jdr||fyw)rN) startswith).0rr@s r! z,CoverageConfig.debug_info..Fs'!dTQRSR^R^_bRc1a&!ds% %)r __dict__rrs r! debug_infozCoverageConfig.debug_infoDs !!dT]]5H5H5J!dddr"c|jjDcic]\}}|jdr||}}}|jD]o\}}|rtnt j j}||}t|trtt||}nt|tr||}|||<qtjtj|j!j#Scc}}w)zConvert to a string that can be ingested with `deserialize`. File paths used by `coverage run` are made absolute to ensure the deserialized config will refer to the same files. r)rrrSERIALIZE_ABSPATHabs_path_if_existsr<rCrrrrrXbase64 b64encodejsondumpsencodedecode)rrr@data must_existabs_fns r! serializezCoverageConfig.serializeHs "&!4!4!6PAall3>O1PP!33 MAz+5'277??FQA!T"VQ(As#1IDG  4 0 7 7 9:AACCQs DDctjtj|j j }|}|j j||S)z:Take a string from `serialize`, and make a CoverageConfig.)r loadsr b64decoder r rupdate)cls config_strrconfigs r! deserializezCoverageConfig.deserializeYsMzz&**:+<+<+>?FFHIt$ r"N)rTrU)r?rrTrU)rrXrCallable[[str], None]rr3rTr3)rTr_)r) r TConfigParserrrXrrXrrXrTr3)rrXrTr)rrXrMz!TConfigValueIn | TConfigSectionInrTrU)rrXrTzTConfigValueOut | None)rTzlist[tuple[str, Any]])rTrX)rrXrTr_)rYrZr[r\rrrrrrr__annotations__rrrrrrrrr classmethodrr"r!r_r_sT?l L$Sj#,7MI`       &3#>J>8K*eD"r"r_c@tjj|S)z2Make adjustments to a file path to make it usable.)r<rC expanduserrCs r!rBrBbs 77  d ##r"ctjj|rtjj|S|S)z-os.path.abspath, but only if the path exists.)r<rCexistsrr!s r!rrgs* ww~~dwwt$$ r"c g}|D]<}|j} tj||s,|j |>|S#tj$r}t d|d|d|d||d}~wwxYw)z=Check the values in a regex list and keep the non-blank ones.z Invalid [z].z value rN)rIrecompileerrorr r)namer0rKrJrMes r!rPrPosJ%  X JJu     e $%  xx X $r& A3OPVW W XsAA6A11A6c|dk(rd}|du}|stjd}|r|}d}|sd}t|tsJ|d|fdddg}|S)zWhat config files should we try to read? Returns a list of tuples: (filename, is_our_file, was_file_specified) z .coveragercTCOVERAGE_RCFILE)z setup.cfgFF)ztox.iniFF)zpyproject.tomlFF)r<getenvrrX)respecified_filercfile files_to_trys r!config_files_to_tryr0}stm#  ,N ,-  K!N # k3 '' ' dN+#!( L r"c >t}|r?t|}|D]/\}}}|j|||}|rn|s"td|dt j d} | r| |_t j d} | r1|jjd| jdDt j d} | r| |_ |jd i|t j d } | r|j| |d |j|S) aRead the coverage.py configuration. Arguments: config_file: a boolean or string, see the `Coverage` class for the tricky details. warn: a function to issue warnings. all others: keyword arguments from the `Coverage` class, used for setting values in the configuration. Returns: config: config is a CoverageConfig object read from the appropriate configuration file. )rzCouldn't read z as a config file COVERAGE_FILECOVERAGE_DEBUGc3<K|]}|jywr2)rI)rr8s r!rz'read_coverage_config..sA!AGGIAsrG COVERAGE_CORECOVERAGE_FORCE_CONFIGTr) r_r0rr r<r,rorprrHrmrr) rerr?rr/fnamerr- config_read env_data_filedebugsenv_core force_files r!read_coverage_configr=s#, F*;7 /; O +E8^ **5$*JK!N5);L"MNN  OIIo.M(YY' (F  Av||C/@AAyy)H Fv23JTD9  Mr")rCrXrTrX)r(rXr0rXrKrWrTrW)re bool | strrTzlist[tuple[str, bool, bool]])rer>rrr?rrTr_).r\ __future__rrrrrr r<os.pathr%collections.abcrtypingrrrrcoverage.exceptionsr coverage.miscr r r coverage.tomlconfigr rcoverage.typesrrrrrr ConfigParserrrrrrr_rBrrPr0r=rr"r!rHs""   $00+RRABmJ 11mJ`"$44 = u]Mup $  >?? ?? ?r"