
    L-PhZ                    P   d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZmZmZ ddlmZ ddlmZ ddlmZmZmZ ddlmZmZ dd	lmZmZmZmZmZm Z   ee          Z G d
 dej!                  Z"ee"ef         Z#dgZ$dgZ%ddgZ& G d dee           Z'ddZ(ddZ)dS )zConfig file for coverage.py    )annotationsN)AnyCallableFinalMappingUnion)Iterable)ConfigError)isolate_modulehuman_sorted_itemssubstitute_variables)TomlConfigParserTomlDecodeError)TConfigurableTConfigSectionInTConfigValueInTConfigSectionOutTConfigValueOutTPluginConfigc                       e Zd ZdZd fdZ	 dd fdZd  fdZd! fdZd"dZd# fdZ	d$dZ
d% fdZd&dZd&dZ xZS )'HandyConfigParserz#Our specialization of ConfigParser.our_fileboolreturnNonec                    t                                          d           dg| _        |r| j                            d           dS dS )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_prefixesappend)selfr   	__class__s     O/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/coverage/config.pyr    zHandyConfigParser.__init__"   sY     	t,,,!, 	-!((,,,,,	- 	-    N	filenamesIterable[str]encoding_unused
str | None	list[str]c                J    t                                          |d          S )z-Read a file name as UTF-8 configuration data.zutf-8)encoding)r   read)r#   r'   r)   r$   s      r%   r.   zHandyConfigParser.read/   s     ww||I|888r&   sectionstrc                t    | j         D ].}||z   }t                                          |          }|r|c S /dS )z!Get the actual name of a section.N)r!   r   has_section)r#   r/   section_prefixreal_sectionhasr$   s        r%   r4   zHandyConfigParser.real_section7   sT    "3 	$ 	$N)G3L''%%l33C $####$tr&   optionc                z    |                      |          }|"t                                          ||          S dS )NF)r4   r   
has_option)r#   r/   r6   r4   r$   s       r%   r8   zHandyConfigParser.has_option@   s;    ((11#77%%lF;;;ur&   c                F    t          |                     |                    S N)r   r4   )r#   r/   s     r%   r2   zHandyConfigParser.has_sectionF   s    D%%g..///r&   c                    |                      |          }|!t                                          |          S t          d|          )NzNo section: )r4   r   optionsr
   )r#   r/   r4   r$   s      r%   r<   zHandyConfigParser.optionsI   sI    ((11#77??<000444555r&   r   c                l    i }|                      |          D ]}|                     ||          ||<   |S )z/Get the contents of a section, as a dictionary.)r<   get)r#   r/   dopts       r%   get_sectionzHandyConfigParser.get_sectionO   s@    (*<<(( 	, 	,CXXgs++AcFFr&   argsr   kwargsc                   | j         D ]+}||z   }t                                          ||          r n,t          d|d|           t                      j        ||g|R i |}t          |t          j                  }|S )a  Get 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   r8   r
   r>   r   osenviron)	r#   r/   r6   rB   rC   r3   r4   vr$   s	           r%   r>   zHandyConfigParser.getV   s     #3 	O 	ON)G3Lww!!,77  M6MM'MMNNN\6CDCCCFCC BJ//r&   c                    |                      ||          }g }|                    d          D ]E}|                    d          D ]-}|                                }|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>   splitstripr"   )r#   r/   r6   
value_listvalues
value_linevalues          r%   getlistzHandyConfigParser.getlistk   s     XXgv..
$**400 	) 	)J#))#.. ) ) )MM%((() r&   c                L   |                      ||          }g }|                                D ]v}|                                }	 t          j        |           n3# t          j        $ r!}t          d| d| d|d|           |d}~ww xY w|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>   
splitlinesrL   recompileerrorr
   r"   )r#   r/   r6   	line_listrM   rP   es          r%   getregexlistzHandyConfigParser.getregexlist}   s     HHWf--	
))++ 		) 		)EKKMME
5!!!!8   !HHH6HH%HHQHH   )!!%(((s   AB	(BB	)r   r   r   r   r:   )r'   r(   r)   r*   r   r+   )r/   r0   r   r*   )r/   r0   r6   r0   r   r   )r/   r0   r   r   )r/   r0   r   r+   )r/   r0   r   r   )
r/   r0   r6   r0   rB   r   rC   r   r   r0   )r/   r0   r6   r0   r   r+   )__name__
__module____qualname____doc__r    r.   r4   r8   r2   r<   rA   r>   rQ   rZ   __classcell__)r$   s   @r%   r   r      s3       --- - - - - -  '+9 9 9 9 9 9 9          0 0 0 06 6 6 6 6 6        *   $       r&   r   z3#\s*(pragma|PRAGMA)[:\s]?\s*(no|NO)\s*(cover|COVER)z5#\s*(pragma|PRAGMA)[:\s]?\s*(no|NO)\s*(branch|BRANCH)zwhile (True|1|False|0):zif (True|1|False|0):c                      e Zd ZU dZd+dZh dZd,dZd-dZd.dZh dZ	de
d<   g dZ	 d/d0dZd1dZd2d"Zd3d$Zd4d&Zd+d'Zd5d)Zd*S )6CoverageConfigzCoverage.py configuration.

    The attributes of this class are the various settings that control the
    operation of coverage.py.

    r   r   c                   g | _         g | _        d| _        d| _        d| _        d| _        d| _        d| _        g | _        d| _	        d| _
        d| _        d| _        g | _        d| _        g | _        d| _        d| _        g | _        d| _        g | _        g | _        d| _        d| _        g | _        g | _        d| _        d| _        t8          dd         | _        g | _        d| _        d| _         d| _!        d| _"        d| _#        d| _$        tJ          dd         | _&        tN          dd         | _(        d| _)        d| _*        d| _+        d| _,        d| _-        d| _.        d| _/        d| _0        d| _1        d| _2        d| _3        d| _4        d| _5        d	| _6        d
| _7        d| _8        d| _9        d| _:        d| _;        i | _<        i | _=        dS )z:Initialize the configuration attributes to their defaults.NFz	.coverageg        r   htmlcovzCoverage reportzcoverage.xmlc   zcoverage.jsonzcoverage.lcov)>config_files_attemptedconfig_files_readconfig_file_config_contents_include_omitbranchcommand_lineconcurrencycontextcorecover_pylib	data_filedebug
debug_filedisable_warningsdynamic_contextparallelpluginsrelative_filesrun_includerun_omitsigtermsourcesource_pkgssource_dirstimid_crashDEFAULT_EXCLUDEexclude_listexclude_also
fail_underformatignore_errorsinclude_namespace_packagesreport_includereport_omitDEFAULT_PARTIAL_ALWAYSpartial_always_listDEFAULT_PARTIALpartial_list	precisionreport_contextsshow_missingskip_covered
skip_emptysort	extra_csshtml_dirhtml_skip_coveredhtml_skip_empty
html_titleshow_contexts
xml_outputxml_package_depthjson_outputjson_pretty_printjson_show_contextslcov_outputlcov_line_checksumspathsplugin_optionsr#   s    r%   r    zCoverageConfig.__init__   s    24#,.'+.2 
 (,&(#' $	 $ "
&*+-+/"$#&(#%(,&(&(
"& ,AAA.')"&"*/'04-1#9!!!#< +AAA.15!! $	 &*!.2,0+" )!# +!&"' +#(  ,.
 =?r&   >   rr   rw   rz   rm   r   ry   r   rC   r   c                    |                                 D ]9\  }}|2|| j        v rt          |t                    r|g}t	          | ||           :dS )z!Read config values from `kwargs`.N)itemsMUST_BE_LIST
isinstancer0   setattr)r#   rC   krG   s       r%   	from_argszCoverageConfig.from_args  sc    LLNN 	$ 	$DAq})))jC.@.@)Aa###		$ 	$r&   filenamer0   warnCallable[[str], None]r   r   c           	     :   t           j                            |          \  }}|dk    rt          |          }nt	          |          }| j                            t           j                            |                     	 |                    |          }n4# t          j
        t          f$ r}t          d| d|           |d}~ww xY w|sdS | j                            t          t           j        j        |                     d}		 | j        D ]}
 | j        |g|
R  }|rd}	n(# t$          $ r}t          d| d|           |d}~ww xY wt'          j        t*                    }| j        D ];}
|
d                             d          \  }}||                             |           <|                                D ]d\  }}|                    |          }|rHt+          |                    |                    |z
  D ]"} |d	                    |||                     #e|                    d
          r8|                    d
          D ]"}|                    d
|          | j        |<   d}	#| j        D ]6}|                    |          r|                     |          | j!        |<   d}	7|rd}n|	}|ret           j                            |          | _"        tG          |d          5 }|                                | _$        ddd           n# 1 swxY w Y   |S )a  Read 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.tomlzCouldn't read config file rS   NFT   :z0Unrecognized option '[{}] {}=' in config file {}r   rb)%rE   pathsplitextr   r   re   r"   abspathr.   configparserErrorr   r
   rf   extendmapCONFIG_FILE_OPTIONS_set_attr_from_config_option
ValueErrorcollectionsdefaultdictsetrK   addr   r4   r<   r   r2   rQ   r   rw   rA   r   rg   openrh   )r#   r   r   r   _extcp
files_readerrany_setoption_specwas_setall_optionsr/   r6   r<   r4   unknownpluginusedfs                        r%   	from_filezCoverageConfig.from_file  s    !!(++3'>>!(++BB"8,,B#**27??8+D+DEEE	W**JJ"O4 	W 	W 	WL8LLsLLMMSVV	W 	5%%c"'/:&F&FGGG	W#7 # #;$;BMMMM #"G#  	W 	W 	WL8LLsLLMMSVV	W "-c223 	- 	-K)!n22377OGV $$V,,,, + 1 1 3 3 	 	GW??733L "2::g#6#677'A  GDJQQ('8     >>'"" 	**W--  %'ZZ%@%@
6" l 	 	F~~f%% .0nnV.D.D#F+
  	DDD 	1!wx88Dh%% 1()%1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 sB    B C,CCD% %
E
/EE
*LLLc                *    t          j        |           S )z#Return a copy of the configuration.)copydeepcopyr   s    r%   r   zCoverageConfig.copyi  s    }T"""r&   >   geventthreadeventletgreenletmultiprocessingzFinal[set[str]]CONCURRENCY_CHOICES)3)rk   z
run:branchboolean)rl   zrun:command_line)rm   zrun:concurrencylist)rn   zrun:context)ro   zrun:core)rp   zrun:cover_pylibr   )rq   zrun:data_file)rr   z	run:debugr   )rs   zrun:debug_file)rt   zrun:disable_warningsr   )ru   zrun:dynamic_context)rv   zrun:parallelr   )rw   zrun:pluginsr   )rx   zrun:relative_filesr   )ry   zrun:includer   )rz   zrun:omitr   )r{   zrun:sigtermr   )r|   z
run:sourcer   )r}   zrun:source_pkgsr   )r~   zrun:source_dirsr   )r   z	run:timidr   )r   z
run:_crash)r   zreport:exclude_lines	regexlist)r   zreport:exclude_alsor   )r   zreport:fail_underfloat)r   zreport:format)r   zreport:ignore_errorsr   )r   z!report:include_namespace_packagesr   )r   zreport:partial_branches_alwaysr   )r   zreport:partial_branchesr   )r   zreport:precisionint)r   zreport:contextsr   )r   zreport:includer   )r   zreport:omitr   )r   zreport:show_missingr   )r   zreport:skip_coveredr   )r   zreport:skip_emptyr   )r   zreport:sort)r   zhtml:extra_css)r   zhtml:directory)r   zhtml:skip_coveredr   )r   zhtml:skip_emptyr   )r   z
html:title)r   zhtml:show_contextsr   )r   z
xml:output)r   zxml:package_depthr   )r   zjson:output)r   zjson:pretty_printr   )r   zjson:show_contextsr   )r   zlcov:output)r   zlcov:line_checksumsr   r   r   TConfigParserattrwheretype_c                    |                     d          \  }}|                    ||          r0t          |d|           }t          | | |||                     dS dS )ztSet an attribute on self if it exists in the ConfigParser.

        Returns True if the attribute was set.

        r   r>   TF)rK   r8   getattrr   )r#   r   r   r   r   r/   r6   methods           r%   r   z+CoverageConfig._set_attr_from_config_option  sl      ++c**==&)) 	Ru//FD$w 7 78884ur&   r   r   c                8    | j                             |i           S )z:Get a dictionary of options for the plugin named `plugin`.)r   r>   )r#   r   s     r%   get_plugin_optionsz!CoverageConfig.get_plugin_options  s    "&&vr222r&   option_namerP   !TConfigValueIn | TConfigSectionInc                   |dk    rhi | _         t          |t                    sJ |                                D ]3\  }}t          |t                    sJ t          |          | j         |<   4dS | j        D ])}|dd         \  }}||k    rt          | ||            dS *|                    d          \  }}	}
|
r)|| j	        v r || j
                            |i           |
<   dS t          d|          )aB  Set 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.

        r   N   r   No such option: )r   r   r   r   r	   r   r   r   	partitionrw   r   
setdefaultr
   )r#   r   rP   r   rG   r   r   r   plugin_namer   keys              r%   
set_optionzCoverageConfig.set_option  s0    '!! DJeW----- ( (1!!X..... $Q
1F  3 	 	K%bqb/KD%##dE*** $
 *33C88Q 	;$,..CHD**;;;C@F <[<<===r&   TConfigValueOut | Nonec                B   |dk    r| j         S | j        D ]'}|dd         \  }}||k    rt          | |          c S (|                    d          \  }}}|r7|| j        v r.| j                            |i                               |          S t          d|          )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.

        r   Nr   r   r   )r   r   r   r   rw   r   r>   r
   )r#   r   r   r   r   r   r   r   s           r%   
get_optionzCoverageConfig.get_option  s     '!!:  3 	+ 	+K%bqb/KD%##tT***** $ *33C88Q 	E;$,..&**;;;??DDD <[<<===r&   r   c                @    t           j                            |          S )z8Make final adjustments to a file path to make it usable.)rE   r   
expanduser)r#   r   s     r%   post_process_filez CoverageConfig.post_process_file  s    w!!$'''r&   c                @                           j                   _                               j                   _                               j                   _         fd j                                        D              _         xj         j        z  c_        dS )z7Make final adjustments to settings to make them usable.c                4    i | ]\  }}|fd |D             S )c                :    g | ]}                     |          S  )r   ).0r   r#   s     r%   
<listcomp>z:CoverageConfig.post_process.<locals>.<dictcomp>.<listcomp>  s'    555a&&q))555r&   r   )r   r   rG   r#   s      r%   
<dictcomp>z/CoverageConfig.post_process.<locals>.<dictcomp>  sD     
 
 
1 55551555
 
 
r&   N)r   rq   r   r   r   r   r   r   r   s   `r%   post_processzCoverageConfig.post_process  s    //??..t}==00AA
 
 
 

((**
 
 

 	T..r&   list[tuple[str, Any]]c                b    t          d | j                                        D                       S )z:Make a list of (name, value) pairs for writing debug info.c              3  N   K   | ] \  }}|                     d           ||fV  !dS )r   N)
startswith)r   r   rG   s      r%   	<genexpr>z,CoverageConfig.debug_info.<locals>.<genexpr>#  sO       "
 "
q!ALL<M<M"
F"
 "
 "
 "
 "
 "
r&   )r   __dict__r   r   s    r%   
debug_infozCoverageConfig.debug_info!  s>    ! "
 "
#}2244"
 "
 "
 
 
 	
r&   N)r   r   )rC   r   r   r   )r   r0   r   r   r   r   r   r   )r   ra   )r   )
r   r   r   r0   r   r0   r   r0   r   r   )r   r0   r   r   )r   r0   rP   r   r   r   )r   r0   r   r   )r   r0   r   r0   )r   r   )r[   r\   r]   r^   r    r   r   r   r   r   __annotations__r   r   r   r   r   r   r   r  r   r&   r%   ra   ra      s^         R? R? R? R?h  L$ $ $ $Q Q Q Qf# # # #, , ,    G G G\     &3 3 3 3#> #> #> #>J> > > >8( ( ( (	/ 	/ 	/ 	/
 
 
 
 
 
r&   ra   rg   
bool | strr   list[tuple[str, bool, bool]]c                    | dk    rd} | du}|st          j        d          }|r|} d}|sd} t          | t                    sJ | d|fdddg}|S )zWhat config files should we try to read?

    Returns a list of tuples:
        (filename, is_our_file, was_file_specified)
    z.coveragercTCOVERAGE_RCFILE)z	setup.cfgFF)ztox.iniFF)zpyproject.tomlFF)rE   getenvr   r0   )rg   specified_filercfilefiles_to_trys       r%   config_files_to_tryr  (  s     m##!-N ",-- 	" K!N $#k3'''''	dN+#!(	L r&   r   r   rC   r   c                d   t                      }| rIt          |           }|D ]7\  }}}|                    |||          }|r n|rt          d|d          8t	          j        d          }	|	r|	|_        t	          j        d          }
|
r7|j                            d |
	                    d          D                        t	          j        d          }|r||_
         |j        di | t	          j        d	          }|r|                    ||d
           |                                 |S )a  Read 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.

    )r   zCouldn't read z as a config fileCOVERAGE_FILECOVERAGE_DEBUGc              3  >   K   | ]}|                                 V  d S r:   )rL   )r   r?   s     r%   r  z'read_coverage_config.<locals>.<genexpr>r  s*      AA!AGGIIAAAAAAr&   rJ   COVERAGE_CORECOVERAGE_FORCE_CONFIGTr   )ra   r  r   r
   rE   r
  rq   rr   r   rK   ro   r   r   )rg   r   rC   configr  fnamer   r  config_readenv_data_filedebugsenv_core
force_files                r%   read_coverage_configr  G  s   , F  O*;77/; 	O 	O+E8^ **5$*JJK  O!"M5"M"M"MNNNO Io..M )( Y'((F BAAv||C/@/@AAAAAA y))H  Fv 233J :TD999 Mr&   )rg   r  r   r  )rg   r  r   r   rC   r   r   ra   )*r^   
__future__r   r   r   r   rE   os.pathrU   typingr   r   r   r   r   collections.abcr	   coverage.exceptionsr
   coverage.miscr   r   r   coverage.tomlconfigr   r   coverage.typesr   r   r   r   r   r   ConfigParserr   r   r   r   r   ra   r  r  r   r&   r%   <module>r&     s6   " ! " " " " " "          				  				              % $ $ $ $ $ + + + + + + R R R R R R R R R R A A A A A A A A               
 ^Bs s s s s1 s s sl ')99:
 ; =  z
 z
 z
 z
 z
]M z
 z
 z
z   >? ? ? ? ? ?r&   