
    V.j                       d Z ddlmZ ddlZddlZddlmZmZ ddlm	Z	m
Z
 ddlmZmZ ddlmZ ddlmZmZmZ dd	lmZmZ  ee      Zej.                  d
k\  rddlZdZn ed      \  ZZ G d de      Z e
d      Z G d d      Zy)z*TOML configuration support for coverage.py    )annotationsN)CallableIterable)AnyTypeVar)configenv)ConfigError)import_third_partyisolate_modulesubstitute_variables)TConfigSectionOutTConfigValueOut)      r   alpha   Ttomlic                      e Zd ZdZy)TomlDecodeErrorz>An exception class that exists even when toml isn't installed.N)__name__
__module____qualname____doc__     UC:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\coverage/tomlconfig.pyr   r      s    Hr   r   TWantc                      e Zd ZdZddZddZddZddZddZddZ	ddZ
dd	Zdd
ZddZddZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 d dZddZd!dZd"dZd#dZd#dZd$dZd%dZy)&TomlConfigParserz:TOML file reading with the interface of HandyConfigParser.c                     || _         i | _        y N)our_filedata)selfr#   s     r   __init__zTomlConfigParser.__init__-   s     $&	r   c                N   t        |t        t        t        j                  f      sJ t        j
                  |      }	 t        |d      5 }|j                         }d d d        t        r	 t        j                        | _        |gS t        j                   dt        j"                        }| j$                  s|rd}t'        |j)                  |            g S # 1 sw Y   xY w# t        $ r g cY S w xY w# t        j                  $ r}t        t        |            |d }~ww xY w)Nzutf-8)encodingz^\[tool\.coverage(\.|]))flagsz?Can't read {!r} without TOML support. Install with [toml] extra)
isinstancebytesstrosPathLikefspathopenreadOSErrorhas_tomllibtomllibloadsr$   TOMLDecodeErrorr   research	MULTILINEr#   r
   format)r%   	filenamesfilenamefp	toml_texterrhas_tomlmsgs           r   r1   zTomlConfigParser.read1   s     )eS"++%>???99Y'	h1RGGI	 2 9#MM)4	 :yy!;Ybll[H}}W!#**X"677I! 21 	I	
 ** 9%c#h/S89sA   C& CC& +C7 C#C& &C43C47D$
DD$c                    dg}| j                   r|j                  d       |D ]?  }||z   }|j                  d      }	 | j                  |d      }|dd D ]  }||   }	 	  ||fS  y# t        $ r Y Nw xY w)aC  Get a section from the data.

        Arguments:
            section (str): A section name, which can be dotted.

        Returns:
            name (str): the actual name of the section that was found, if any,
                or None.
            data (str): the dict of data in the section, or None if not found.

        ztool.coverage. .r      N)NN)r#   appendsplitr$   KeyError)r%   sectionprefixesprefixreal_sectionpartsr$   parts           r   _get_sectionzTomlConfigParser._get_sectionJ   s     %%==OOBF!G+L &&s+Eyyq*!!"ID:D &  T!!  	  s   !A&&	A21A2c                    | j                  |      \  }}|t        d|      |J 	 ||   }||fS # t        $ r t        d|d|      dw xY w)z;Like .get, but returns the real section name and the value.NNo section: z
No option z in section: )rO   r
   rH   )r%   rI   optionnamer$   values         r   _getzTomlConfigParser._getg   s    &&w/
d<WK899	VLE U{  	V
6*M$JKQUU	Vs	   3 Ac                    | j                  ||      \  }}t        |t              rt        |t        j
                        }||fS )zGet a single-valued option.

        Performs environment substitution if the value is a string. Other types
        will be converted later as needed.
        )rU   r*   r,   r   r-   environr%   rI   rR   rS   rT   s        r   _get_singlezTomlConfigParser._get_singles   s<     ii0eeS!(

;EU{r   c                8    | j                  |      \  }}|y||v S )NFrO   )r%   rI   rR   _r$   s        r   
has_optionzTomlConfigParser.has_option~   s(    ##G,4<~r   c                .    | j                  |      \  }}|S r"   r[   r%   rI   rS   r\   s       r   rL   zTomlConfigParser.real_section   s    ##G,ar   c                @    | j                  |      \  }}t        |      S r"   )rO   boolr_   s       r   has_sectionzTomlConfigParser.has_section   s     ##G,aDzr   c                |    | j                  |      \  }}|t        d|      t        |j                               S )NrQ   )rO   r
   listkeysr%   rI   r\   r$   s       r   optionszTomlConfigParser.options   s>    ##G,4<WK899DIIK  r   c                6    | j                  |      \  }}|xs i S r"   r[   rf   s       r   get_sectionzTomlConfigParser.get_section   s     ##G,4zrr   c                0    | j                  ||      \  }}|S r"   )rY   r%   rI   rR   r\   rT   s        r   getzTomlConfigParser.get   s    ##GV45r   c                    t        ||      r|S t        |t              r|		  ||      S t        d| d| d| d|      # t        $ r}t        d| d| d| d|      |d}~ww xY w)zCheck that `value` has the type we want, converting if needed.

        Returns the resulting value of the desired type.
        NzOption []z couldn't convert to z: z is not )r*   r,   	Exception
ValueError)r%   rI   rR   rT   type_	converter	type_desces           r   _check_typezTomlConfigParser._check_type   s     eU#LeS!i&; ''
 wiq2eYG
 	
	   wiq0Ei[PRSXR[\s   A 	A'
A""A'c                ~    | j                  ||      \  }}ddd}| j                  |||t        |j                  d      S )NTF)truefalsez	a boolean)rY   ru   ra   __getitem__)r%   rI   rR   rS   rT   bool_stringss         r   
getbooleanzTomlConfigParser.getboolean   sD    &&w7e $u5feT<;S;SU`aar   c                V    | j                  ||      \  }}t        j                  |      S r"   )rY   r   process_file_valuerk   s        r   getfilezTomlConfigParser.getfile   s)    ##GV45((//r   c                    | j                  ||      \  }}| j                  |||t        dd      }|D cg c]  }t        |t        j
                         }}||fS c c}w )zJGet a list of strings, substituting environment variables in the elements.Nza list)rU   ru   rd   r   r-   rW   )r%   rI   rR   rS   valuesrT   s         r   	_get_listzTomlConfigParser._get_list   s`    yy&1f!!$dHMGMNve&ubjj9vNV| Os   !Ac                0    | j                  ||      \  }}|S r"   )r   )r%   rI   rR   r\   r   s        r   getlistzTomlConfigParser.getlist   s    NN7F3	6r   c                Z    | j                  ||      \  }}t        j                  |||      S r"   )r   r   process_regexlist)r%   rI   rR   rS   r   s        r   getregexlistzTomlConfigParser.getregexlist   s+    ~~gv6f''ff==r   c                h    | j                  ||      \  }}| j                  |||t        t        d      S )Nz
an integer)rY   ru   intrX   s        r   getintzTomlConfigParser.getint   s3    &&w7efeS#|LLr   c                    | j                  ||      \  }}t        |t              rt        |      }| j	                  |||t        t        d      S )Nza float)rY   r*   r   floatru   rX   s        r   getfloatzTomlConfigParser.getfloat   sF    &&w7eeS!%LEfeUE9MMr   N)r#   ra   returnNone)r;   zIterable[str]r   	list[str])rI   r,   r   z+tuple[str | None, TConfigSectionOut | None])rI   r,   rR   r,   r   ztuple[str, TConfigValueOut])rI   r,   rR   r,   r   r   )rI   r,   rR   r,   r   ra   )rI   r,   r   z
str | None)rI   r,   r   ra   )rI   r,   r   r   )rI   r,   r   r   )rI   r,   rR   r,   rT   r   rq   ztype[TWant]rr   zCallable[[Any], TWant] | Noners   r,   r   r   )rI   r,   rR   r,   r   r,   )rI   r,   rR   r,   r   ztuple[str, list[str]])rI   r,   rR   r,   r   r   )rI   r,   rR   r,   r   r   )rI   r,   rR   r,   r   r   )r   r   r   r   r&   r1   rO   rU   rY   r]   rL   rb   rg   ri   rl   ru   r{   r~   r   r   r   r   r   r   r   r   r    r    &   s    D'2":
	!

 
 	

 
 1
 
 

4b
0>MNr   r    )r   
__future__r   r-   r7   collections.abcr   r   typingr   r   coverager   r	   coverage.exceptionsr
   coverage.miscr   r   r   coverage.typesr   r   	PYVERSIONr4   r3   ro   r   r   r    r   r   r   <module>r      s~    1 " 	 	 .    + R R =B==**K .g6G[	i 	 	nN nNr   