=$PdZddlmZddlZddlZddlZddlZddlZddlZddl m Z m Z m Z m Z mZmZmZmZddlmZddlmZmZmZddlmZmZddlmZmZmZmZm Z m!Z!eeZGd d ej"Z#ee#efZ$d gZ%d gZ&d dgZ'Gddee!Z(ddZ)ddZ*dS)zConfig file for coverage.py) annotationsN)AnyCallableDictIterableListOptionalTupleUnion) ConfigError)isolate_modulehuman_sorted_itemssubstitute_variables)TomlConfigParserTomlDecodeError) TConfigurableTConfigSectionInTConfigValueInTConfigSectionOutTConfigValueOut TPluginConfigceZdZdZdfd Z ddfd Zd fd Zd!fd Zd"dZd#fd Z d$dZ d%fd Z d&dZ d&dZ xZS)'HandyConfigParserz#Our specialization of ConfigParser.our_fileboolreturnNonectddg|_|r|jddSdS)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)selfr __class__s /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/coverage/config.pyr"zHandyConfigParser.__init__!sY t,,,!,   -  ! ( ( , , , , , - -N filenames Iterable[str]encoding_unused Optional[str] List[str]cJt|dS)z-Read a file name as UTF-8 configuration data.zutf-8)encoding)r!read)r%r)r+r&s r'r0zHandyConfigParser.read.s ww||I|888r(sectionstrct|jD].}||z}t|}|r|cS/dS)z!Get the actual name of a section.N)r#r! has_section)r%r1section_prefix real_sectionhasr&s r'r6zHandyConfigParser.real_section6sT"3 $ $N)G3L''%%l33C $#### $tr(optioncz||}|"t||SdS)NF)r6r! has_option)r%r1r8r6r&s r'r:zHandyConfigParser.has_option?s;((11  #77%%lF;; ;ur(cFt||SN)rr6)r%r1s r'r4zHandyConfigParser.has_sectionEsD%%g..///r(c||}|!t|Std|)Nz No section: )r6r!optionsr )r%r1r6r&s r'r>zHandyConfigParser.optionsHsI((11  #77??<00 0444555r(rcli}||D]}|||||<|S)z/Get the contents of a section, as a dictionary.)r>get)r%r1dopts r' get_sectionzHandyConfigParser.get_sectionNs@(*<<(( , ,CXXgs++AcFFr(argsrkwargsc|jD]+}||z}t||rn,td|d|tj||g|Ri|}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: )r#r!r:r r@rosenviron) r%r1r8rDrEr5r6vr&s r'r@zHandyConfigParser.getUs#3 O ON)G3Lww!!,77  M6MM'MMNN N\6CDCCCFCC BJ / /r(c|||}g}|dD]E}|dD]-}|}|r||.F|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.  ,)r@splitstripr$)r%r1r8 value_listvalues value_linevalues r'getlistzHandyConfigParser.getlistjsXXgv.. $**400 ) )J#))#.. ) ) )MM%((( ) r(c L|||}g}|D]v}|} tj|n3#tj$r!}t d|d|d|d||d}~wwxYw|r||w|S)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. z Invalid [z].z value : N)r@ splitlinesrNrecompileerrorr r$)r%r1r8 line_listrOrRes r' getregexlistzHandyConfigParser.getregexlist|sHHWf--  ))++ ) )EKKMME  5!!!!8   !HHH6HH%HHQHH  )!!%(((sAB (BB )rrrrr<)r)r*r+r,rr-)r1r2rr,)r1r2r8r2rr)r1r2rr)r1r2rr-)r1r2rr) r1r2r8r2rDrrErrr2)r1r2r8r2rr-)__name__ __module__ __qualname____doc__r"r0r6r:r4r>rCr@rSr\ __classcell__)r&s@r'rrs3-- - - - - - - *.9999999 0000666666 *$r(rz3#\s*(pragma|PRAGMA)[:\s]?\s*(no|NO)\s*(cover|COVER)z5#\s*(pragma|PRAGMA)[:\s]?\s*(no|NO)\s*(branch|BRANCH)zwhile (True|1|False|0):zif (True|1|False|0):ceZdZdZd)dZhdZd*dZd+dZd,dZhdZ gdZ d-d.dZ d/dZ d0d Z d1d"Zd2d$Zd)d%Zd3d'Zd(S)4CoverageConfigzCoverage.py configuration. The attributes of this class are the various settings that control the operation of coverage.py. rrcdg|_g|_d|_d|_d|_d|_d|_d|_g|_d|_ d|_ d|_ g|_ d|_ g|_d|_d|_g|_d|_g|_g|_d|_d|_g|_d|_d|_t4dd|_g|_d|_d|_d|_d|_ d|_!d|_"tFdd|_$tJdd|_&d|_'d|_(d|_)d|_*d|_+d|_,d|_-d|_.d|_/d|_0d|_1d|_2d|_3d |_4d |_5d|_6d|_7d |_8i|_9i|_:dS) z:Initialize the configuration attributes to their defaults.NFz .coveragegrhtmlcovzCoverage reportz coverage.xmlcz coverage.jsonz coverage.lcov);attempted_config_filesconfig_files_read config_file_config_contents_include_omitbranch command_line concurrencycontext cover_pylib data_filedebug debug_filedisable_warningsdynamic_contextparallelpluginsrelative_files run_includerun_omitsigtermsource source_pkgstimid_crashDEFAULT_EXCLUDE exclude_list exclude_also fail_underformat ignore_errorsinclude_namespace_packagesreport_include report_omitDEFAULT_PARTIAL_ALWAYSpartial_always_listDEFAULT_PARTIAL partial_list 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_outputpathsplugin_optionsr%s r'r"zCoverageConfig.__init__s24#,.*.15   +/&(&*  $ " )-+-.2 "$ #&(#%  +/ &( %) ,AAA.')%) "*/'3704#9!!!#< +AAA.48!!#' )-! 15/3+")!#+!&"'+,. =?r(>rsrxr{rorrzrrErc |D]9\}}|2||jvrt|tr|g}t |||:dS)z!Read config values from `kwargs`.N)items MUST_BE_LIST isinstancer2setattr)r%rEkrIs r' from_argszCoverageConfig.from_args scLLNN $ $DAq})))jC.@.@)Aa###  $ $r(filenamer2warnCallable[[str], None]rrc tj|\}}|dkrt|}nt |}|j| ||}n4#tj tf$r}td|d||d}~wwxYw|sdS|j ttjj|d} |jD]} |j|g| R} | rd} n(#t$$r}td|d||d}~wwxYwt'jt*} |jD];} | dd\} }| | |<| D]d\} }|| }|rHt+|| |z D]"}|d |||#e|d r8|d D]"}|d ||j|<d} #|jD]6}||r| ||j!|<d} 7|rd}n| }|retj||_"tG|d 5}||_$dddn #1swxYwY|S) 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 rUNFT:z0Unrecognized option '[{}] {}=' in config file {}rrb)%rGpathsplitextrrrgr$r0 configparserErrorrr rhextendmapabspathCONFIG_FILE_OPTIONS_set_attr_from_config_option ValueError collections defaultdictsetrMaddrr6r>rr4rSrrxrCrriopenrj)r%rrr_extcp files_readerrany_set option_specwas_set all_optionsr1r8r>r6unknownpluginusedfs r' from_filezCoverageConfig.from_files!!(++3 '>>!(++BB"8,,B #**8444 W**JJ"O4 W W WL8LLsLLMMSV V W 5 %%c"'/:&F&FGGG W#7 # # ;$;BMMMM#"G # W W WL8LLsLLMMSV V W"-c22 3 - -K)!n22377OGV  $ $V , , , , + 1 1 3 3   GW??733L "2::g#6#677'AGDJQQ('8 >>' " " **W--  %'ZZ%@%@ 6"l  F~~f%% .0nnV.D.D#F+  DDD  1!wx88D h%% 1()% 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 sB#A99B*B%%B*+D D-D((D- K33K7:K7c*tj|S)z#Return a copy of the configuration.)copydeepcopyrs r'rzCoverageConfig.copyes}T"""r(>geventthreadeventletgreenletmultiprocessing)0)rmz run:branchboolean)rnzrun:command_line)rozrun:concurrencylist)rpz run:context)rqzrun:cover_pylibr)rrz run:data_file)rsz run:debugr)rtzrun:debug_file)ruzrun:disable_warningsr)rvzrun:dynamic_context)rwz run:parallelr)rxz run:pluginsr)ryzrun:relative_filesr)rzz run:includer)r{zrun:omitr)r|z run:sigtermr)r}z run:sourcer)r~zrun:source_pkgsr)rz run:timidr)rz run:_crash)rzreport:exclude_lines regexlist)rzreport:exclude_alsor)rzreport:fail_underfloat)rz report:formatr)rzreport:ignore_errorsr)rz!report:include_namespace_packagesr)rzreport:partial_branches_alwaysr)rzreport:partial_branchesr)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:directory)rzhtml:skip_coveredr)rzhtml:skip_emptyr)rz html:title)rzhtml:show_contextsr)rz xml:output)rzxml:package_depthr)rz json:output)rzjson:pretty_printr)rzjson:show_contextsr)rz lcov:outputr r TConfigParserattrwheretype_c|d\}}|||r0t|d|z}t|||||dSdS)ztSet an attribute on self if it exists in the ConfigParser. Returns True if the attribute was set. rr@TF)rMr:getattrr)r%rrrrr1r8methods r'rz+CoverageConfig._set_attr_from_config_optionsj ++c** ==& ) ) R//F D$w 7 7 8 8 84ur(rrc8|j|iS)z:Get a dictionary of options for the plugin named `plugin`.)rr@)r%rs r'get_plugin_optionsz!CoverageConfig.get_plugin_optionss"&&vr222r( option_namerR'Union[TConfigValueIn, TConfigSectionIn]c.|dkr ||_dS|jD])}|dd\}}||krt|||dS*|d\}}}|r)||jvr ||j|i|<dStd|)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: )rrr partitionrxr setdefaultr ) r%rrRrrr plugin_namerkeys r' set_optionzCoverageConfig.set_options ' ! !DJ F 3  K%bqb/KD% ##dE***$ *33C88 Q  ;$,..CHD  * *; ; ;C @ F<[<<===r(Optional[TConfigValueOut]cB|dkr|jS|jD]'}|dd\}}||krt||cS(|d\}}}|r7||jvr.|j|i|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)rrrrrxrr@r )r%rrrrrrrs r' get_optionzCoverageConfig.get_options ' ! !:  3 + +K%bqb/KD% ##tT*****$*33C88 Q  E;$,..&**;;;??DD D<[<<===r(rc@tj|S)z8Make final adjustments to a file path to make it usable.)rGr expanduser)r%rs r'post_process_filez CoverageConfig.post_process_filesw!!$'''r(cZj_j_j_t fdjD_xjjz c_dS)z7Make final adjustments to settings to make them usable.c3>K|]\}}|fd|DfVdS)c:g|]}|S)r).0rr%s r' z9CoverageConfig.post_process... s'666q''**666r(Nr)rrrIr%s r' z.CoverageConfig.post_process.. sU  16666A666 7      r(N) rrrrrdictrrrrrs`r' post_processzCoverageConfig.post_processs//??..t}== 00AA     ((**       T..r(List[Tuple[str, Any]]cbtd|jDS)z:Make a list of (name, value) pairs for writing debug info.c3NK|] \}}|d||fV!dS)rN) startswith)rrrIs r'rz,CoverageConfig.debug_info..sO" " q!ALL!" " #}2244" " "    r(N)rr)rErrr)rr2rrrrrr)rrc)r ) rrrr2rr2rr2rr)rr2rr)rr2rRrrr)rr2rr)rr2rr2)rr)r]r^r_r`r"rrrrCONCURRENCY_CHOICESrrrrrrrrrr(r'rcrcsDO?O?O?O?bL $$$$QQQQf####ZYYDDDV &3333>>>>>>>>>8(((( / / / /      r(rcriUnion[bool, str]rList[Tuple[str, bool, bool]]c|dkrd}|du}|s%tjd}|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)rGrHr@rr2)rispecified_filercfile files_to_trys r'config_files_to_tryr sm## !-N " 122  " K!N $# k3 ' ''' ' dN+#!( L r(rrrErc t}|rIt|}|D]7\}}}||||}|rn|rtd|d8tjd} | r| |_tjd} | r7|j d| dD|j di|| |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|]}|VdSr<)rN)rrAs r'rz'read_coverage_config..bs*AA!AGGIIAAAAAAr(rLr) rcr rr rGrHr@rrrsrrMrr) rirrEconfigr fnamerr config_read env_data_filedebugss r'read_coverage_configr8s6,  FO*;77 /; O O +E8^ **5$*JJK  O!"M5"M"M"MNNN O JNN?33M)( Z^^, - -F B AAv||C/@/@AAAAAAFv  Mr()rirrr)rirrrrErrrc)+r` __future__rrrrrGos.pathrWtypingrrrrrr r r coverage.exceptionsr coverage.miscr rrcoverage.tomlconfigrrcoverage.typesrrrrrr ConfigParserrrrrrrcr rrr(r'rsB"!""""""  ,+++++RRRRRRRRRRAAAAAAAA ^Bsssss 1sssl')99: ; = l l l l l ]Ml l l ^ >333333r(