o
    Õ­jI  ã                   @   s¼   d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 g d	¢Z
d
dlmZ d
dlmZ d
dlmZ d
dlmZ edƒZedƒZG dd„ dƒZG dd„ dƒZdS )zdbrain-dead simple parser for ini-style files.
(C) Ronny Pfannschmidt, Holger Krekel -- MIT licensed
é    N)ÚCallable)ÚIterator)ÚMapping)ÚFinal)ÚTypeVar)Úoverload)Ú	IniConfigÚ
ParseErrorÚCOMMENTCHARSÚiscommentlineé   )Ú_parse)r
   )r   )r	   Ú_DÚ_Tc                   @   sŒ  e Zd ZU ed ed< ee ed< dddeddfdd„ZdededB fdd	„Ze	d
ededB fdd„ƒZ
e	d
edeegef dedB fdd„ƒZ
e	d
edddeegef dedB fdd„ƒZ
e	dd
ededddeeB fdd„ƒZ
e	d
ededeegef deeB fdd„ƒZ
		dd
ededB deegef dB deeB eB dB fdd„Z
d
edefdd„Zdee fdd„Zdeeeef  fdd„ZdS )ÚSectionWrapperr   ÚconfigÚnameÚreturnNc                 C   s   || _ || _d S ©N)r   r   )Úselfr   r   © r   úO/var/www/html/CropPilot/venv/lib/python3.10/site-packages/iniconfig/__init__.pyÚ__init__   s   
zSectionWrapper.__init__c                 C   s   | j  | j|¡S r   ©r   Úlineofr   ©r   r   r   r   r   r       ó   zSectionWrapper.lineofÚkeyc                 C   ó   d S r   r   ©r   r   r   r   r   Úget#   ó   zSectionWrapper.getÚconvertc                 C   r   r   r   )r   r   r"   r   r   r   r    &   ó   Údefaultc                 C   r   r   r   ©r   r   r$   r"   r   r   r   r    -   ó   c                 C   r   r   r   r%   r   r   r   r    5   r!   c                 C   r   r   r   r%   r   r   r   r    8   r&   c                 C   s   | j j| j|||d�S )N)r"   r$   )r   r    r   r%   r   r   r   r    A   s   c                 C   s   | j j| j | S r   )r   Úsectionsr   r   r   r   r   Ú__getitem__I   s   zSectionWrapper.__getitem__c                 #   s@   � ˆ j j ˆ ji ¡}dtdtf‡ fdd„}t||d�E d H  d S )Nr   r   c                    s   ˆ j  ˆ j| ¡S r   r   ©r   ©r   r   r   r   O   r   z'SectionWrapper.__iter__.<locals>.lineofr)   )r   r'   r    r   ÚstrÚintÚsorted)r   Úsectionr   r   r*   r   Ú__iter__L   s   €zSectionWrapper.__iter__c                 c   s   � | D ]	}|| | fV  qd S r   r   r   r   r   r   ÚitemsT   s   €ÿzSectionWrapper.itemsr   ©NN)Ú__name__Ú
__module__Ú__qualname__r   Ú__annotations__r+   r   r,   r   r   r    r   r   r   r(   r   r/   Útupler0   r   r   r   r   r      sf   
 þýüþýüû"þýüûüþýü
ûr   c                   @   sn  e Zd ZU ee ed< eeeeeef f  ed< eeeeedB f ef  ed< 		d(dddœdee	j
e B dedB ded	eeeeef f dB deeeedB f ef dB d
dfdd„Ze		d(dddœdee	j
e B dedB dededed
d fdd„ƒZd)dededB d
edB fdd„Zededed
edB fdd„ƒZedededeegef d
edB fdd„ƒZedededddeegef d
edB f
dd„ƒZe	d)dedededdd
eeB f
dd„ƒZededededeegef d
eeB f
dd„ƒZ		d*dedededB deegef dB d
eeB eB dB f
d d„Zded
efd!d"„Zd
ee fd#d$„Zd%ed
efd&d'„ZdS )+r   Úpathr'   NÚ_sourcesúutf-8)Ú	_sectionsr8   ÚdataÚencodingr:   r   c          	      C   sŠ   t  |¡| _|d ur|d ur|}|}n*|d u r2t| j|d��}| ¡ }W d   ƒ n1 s-w   Y  tj| j|dd�\}}|| _|| _d S )N©r<   F)Ústrip_inline_comments)	ÚosÚfspathr7   ÚopenÚreadr   Úparse_ini_datar8   r'   )	r   r7   r;   r<   r:   r8   Úsections_dataÚsourcesÚfpr   r   r   r   ^   s   	
ÿ
ÿ
zIniConfig.__init__TF©r>   Ústrip_section_whitespacer>   rH   c          
      C   sj   t  |¡}|du r#t||d��}| ¡ }W d  ƒ n1 sw   Y  tj||||d�\}}	| |||	d�S )a™  Parse an INI file.

        Args:
            path: Path to the INI file (used for error messages)
            data: Optional INI content as string. If None, reads from path.
            encoding: Encoding to use when reading the file (default: utf-8)
            strip_inline_comments: Whether to strip inline comments from values
                (default: True). When True, comments starting with # or ; are
                removed from values, matching the behavior for section comments.
            strip_section_whitespace: Whether to strip whitespace from section and key names
                (default: False). When True, strips Unicode whitespace from section and key names,
                addressing issue #4. When False, preserves existing behavior for backward compatibility.

        Returns:
            IniConfig instance with parsed configuration

        Example:
            # With comment stripping (default):
            config = IniConfig.parse("setup.cfg")
            # value = "foo" instead of "foo # comment"

            # Without comment stripping (old behavior):
            config = IniConfig.parse("setup.cfg", strip_inline_comments=False)
            # value = "foo # comment"

            # With section name stripping (opt-in for issue #4):
            config = IniConfig.parse("setup.cfg", strip_section_whitespace=True)
            # section names and keys have Unicode whitespace stripped
        Nr=   rG   )r7   r:   r8   )r?   r@   rA   rB   r   rC   )
Úclsr7   r;   r<   r>   rH   r@   rF   rD   rE   r   r   r   Úparse}   s   
'
ÿ
üzIniConfig.parser.   r   c                 C   s$   | j  ||f¡}|d u rd S |d S )Nr   )r8   r    )r   r.   r   Úlinenor   r   r   r   ´   s   zIniConfig.lineofc                 C   r   r   r   )r   r.   r   r   r   r   r    ¸   r#   zIniConfig.getr"   c                 C   r   r   r   )r   r.   r   r"   r   r   r   r    ¿   r&   r$   c                 C   r   r   r   ©r   r.   r   r$   r"   r   r   r   r    Ç   ó   c                 C   r   r   r   rL   r   r   r   r    Ð   s   c                 C   r   r   r   rL   r   r   r   r    Õ   rM   c                 C   s>   z	| j | | }W n ty   | Y S w |d ur||ƒS |S r   )r'   ÚKeyError)r   r.   r   r$   r"   Úvaluer   r   r   r    Þ   s   ÿc                 C   s   || j vr	t|ƒ‚t| |ƒS r   )r'   rN   r   r   r   r   r   r(   ï   s   

zIniConfig.__getitem__c                 c   s(   � t | j| jd�D ]}t| |ƒV  q	d S )Nr)   )r-   r'   r   r   r   r   r   r   r/   ô   s   €ÿzIniConfig.__iter__Úargc                 C   s
   || j v S r   )r'   )r   rP   r   r   r   Ú__contains__ø   s   
zIniConfig.__contains__)Nr9   r   r1   )r2   r3   r4   r   r+   r5   r   r6   r,   r?   ÚPathLiker   ÚclassmethodÚboolrJ   r   r   r    r   r   r   r   r(   r   r/   rQ   r   r   r   r   r   Y   sâ   
  üùþýüúù
øüùþýüúùø 6þýüþýüûþýüûúÿÿÿÿÿþþýüûúûþýüû
úr   )Ú__doc__r?   Úcollections.abcr   r   r   Útypingr   r   r   Ú__all__Ú r   r
   r   Ú
exceptionsr	   r   r   r   r   r   r   r   r   Ú<module>   s"    A