
    fiA                         d dl Z d dlZd dlmZ d dlmZ d Zd Z G d de j                  Z	 G d d	e j                  Z
 G d
 de j                  Z G d de          ZdS )    N)defaultdict)string_typesc                 f    |                                  } | dv rdS | dv rdS t          d|           )a'  
    Based on strtobools from distutils.util.

    Convert a string representation of truth to true (1) or false (0).

    True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
    are 'n', 'no', 'f', 'false', 'off', and '0'.  Raises ValueError if
    'val' is anything else.
    )yyesttrueon1T)nnoffalseoff0FzInvalid truth value )lower
ValueError)vals    T/var/www/html/Pagina-Ingenieria-Requisitos/venv/lib/python3.11/site-packages/tini.py	strtoboolr      sJ     ))++C
222t	5	5	5u777888    c                 d   t          | t                    s| S t          j        d|           rt	          |           S t          j        d|           r"	 t          |           S # t          $ r | cY S w xY wt          j        d| t          j                  rt          t          |                     S | S )z5
    Try coercing values to numbers or booleans.
    z^[0-9]+$z	^[.0-9]+$z^(true|false|yes|no)$)flags)

isinstancer   rematchintfloatr   
IGNORECASEboolr   )values    r   coerce_valuer"      s     e\** 	xU## 5zz	xe$$ 	<< 	 	 	LLL	 
x(%r}EEE &Ie$$%%%Ls   A! !A0/A0c                       e Zd ZdZd ZdS )CoerceInterpolationz6
    Coerce values and strip quotes from strings.
    c                     t          |t                    s|S t          |          }t          |t                    r|                    d          S |S Nz"')r   r   r"   strip)selfparsersectionoptionr!   coerced_values         r   before_readzCoerceInterpolation.before_read:   sR    %.. 	L$U++m\22 	. &&u---r   N__name__
__module____qualname____doc__r-    r   r   r$   r$   5   s-         	 	 	 	 	r   r$   c                       e Zd ZdZd ZdS )StripQuotesInterpolationz$
    Strip quotes from strings.
    c                 Z    t          |t                    s|S |                    d          S r&   )r   r   r'   )r(   r)   r*   r+   r!   s        r   r-   z$StripQuotesInterpolation.before_readK   s+    %.. 	L{{5!!!r   Nr.   r3   r   r   r5   r5   F   s-         " " " " "r   r5   c                   (     e Zd ZdZ fdZd Z xZS )SimpleConfigParseru0  
    A ConfigParser that:

    - strips quotes from strings ('"value"' becomes 'value')
    - doesn't transform option strings ('OPTION' remains upper-case)
    - doesn't support weird '%' interpolation
    - allows empty values ('value =' is ok)
    - coerces numbers and booleans ('true' → True)
    c                     |                     dd           |                     dt                                  t          t          |           j        |i | d S )Nallow_no_valueTinterpolation)
setdefaultr$   superr8   __init__)r(   argskwargs	__class__s      r   r>   zSimpleConfigParser.__init__]   s`    *D111/+>+@+@AAA0 $''0$A&AAAAAr   c                     |S Nr3   )r(   option_strings     r   optionxformzSimpleConfigParser.optionxformc   s    r   )r/   r0   r1   r2   r>   rE   __classcell__)rA   s   @r   r8   r8   R   sV         B B B B B      r   r8   c                        e Zd ZdZddZd ZdS )Tiniz(
    Easily parse simple ini files.
    Nc           	         t          t          fi |r|ni | _        t          di || _        |r|rt          d          |r3t          |t                    r|g}| j                            |           n,|r| j        	                    |           nt          d          t          t          | j        j                                                            t          | j                                                  z   }i | _        |D ]c}|| j        j        v r>t          | j        |         fi t          | j        j        |                   | j        |<   N| j        |         | j        |<   dd S )Nz)filenames and f may not both be specifiedz'either filenames or f must be specifiedr3   )r   dictdefaultsr8   r)   r   r   r   read	read_filelist	_sectionskeysitems)r(   	filenamesr   rK   r@   sectionsr*   s          r   r>   zTini.__init__l   s   #DKK-IXXrKK(22622 	J 	JHIII 	H)\22 (&K	KY'''' 	HK!!!$$$$FGGG T[23388::;;d4=CUCUCWCW>X>XX
 	= 	=G$+///&*M'*' '.24;3H3Q.R.R' '
7## '+mG&<
7##	= 	=r   c                     | j         |         S rC   )rQ   )r(   names     r   __getattr__zTini.__getattr__   s    z$r   )NNN)r/   r0   r1   r2   r>   rV   r3   r   r   rH   rH   g   sB         = = = =@         r   rH   )configparserr   collectionsr   sixr   r   r"   Interpolationr$   r5   ConfigParserr8   objectrH   r3   r   r   <module>r]      s       				 # # # # # #      9 9 9(  ,    ,4   "	" 	" 	" 	" 	"|9 	" 	" 	"    2   *&  &  &  &  & 6 &  &  &  &  & r   