o
    Õ­jg  ã                   @   sþ   d dl mZ d dlmZ ddlmZ dZG dd„ deƒZdd	œd
edede	de	de
eeeeef f ee
eedB f ef f f
dd„Zdddœd
edee de	de	dee f
dd„Zd
ededede	de	de
edB edB f fdd„Zdede	fdd„ZdS )é    )ÚMapping)Ú
NamedTupleé   )Ú
ParseErrorz#;c                   @   s:   e Zd ZU eed< edB ed< edB ed< edB ed< dS )Ú
ParsedLineÚlinenoNÚsectionÚnameÚvalue)Ú__name__Ú
__module__Ú__qualname__ÚintÚ__annotations__Ústr© r   r   úM/var/www/html/CropPilot/venv/lib/python3.10/site-packages/iniconfig/_parse.pyr   	   s
   
 r   F)Ústrip_section_whitespaceÚpathÚdataÚstrip_inline_commentsr   ÚreturnNc                C   sº   t | | d¡||d�}i }i }|D ]G\}}}	}
|du r!t| |dƒ‚||||	f< |	du r=||v r8t| |d|›�ƒ‚i ||< q|	|| v rLt| |d|	›�ƒ‚|
dusRJ ‚|
|| |	< q||fS )aO  Parse INI data and return sections and sources mappings.

    Args:
        path: Path for error messages
        data: INI content as string
        strip_inline_comments: Whether to strip inline comments from values
        strip_section_whitespace: Whether to strip whitespace from section and key names
            (default: False). When True, addresses issue #4 by stripping Unicode whitespace.

    Returns:
        Tuple of (sections_data, sources) where:
        - sections_data: mapping of section -> {name -> value}
        - sources: mapping of (section, name) -> line number
    T©r   r   Nzno section header definedzduplicate section zduplicate name )Úparse_linesÚ
splitlinesr   )r   r   r   r   ÚtokensÚsourcesÚsections_datar   r   r	   r
   r   r   r   Úparse_ini_data   s*   ü
r   r   Ú	line_iterc                C   s  g }d }t |ƒD ]x\}}t| ||||ƒ\}}	|d ur)|	d ur)| t||||	ƒ¡ q|d urF|	d u rF|s9t| |dƒ‚|}| t||d d ƒ¡ q|d u r€|	d ur€|sVt| |dƒ‚| ¡ }
|
jd u ret| |dƒ‚|
jru|
j|
j› d|	› �d�}
n|
j|	d�}
| |
¡ q|S )Nzempty section namezunexpected value continuationÚ
)r
   )	Ú	enumerateÚ
_parselineÚappendr   r   Úpopr	   r
   Ú_replace)r   r   r   r   Úresultr   r   Úliner	   r   Úlastr   r   r   r   @   s2   
ÿ

€r   r'   r   c                 C   sd  t |ƒrd}n| ¡ }|sdS |d dkrA|}tD ]}| |¡d  ¡ }q|d dkr;|dd… }|r7| ¡ }|d fS d | ¡ fS |d  ¡ sšz| dd¡\}}	d	|v rWtƒ ‚W n% ty}   z
| d	d¡\}}	W n tyz   t| |d
|›�ƒd ‚w Y nw | ¡ }
|	 ¡ }	|r–tD ]}|	 |¡d  ¡ }	qŠ|
|	fS | ¡ }|r®tD ]}| |¡d  ¡ }q¢d |fS )NÚ )NNr   ú[éÿÿÿÿú]r   ú=ú:zunexpected line: )ÚiscommentlineÚrstripÚCOMMENTCHARSÚsplitÚstripÚisspaceÚ
ValueErrorr   )r   r'   r   r   r   ÚreallineÚcÚsection_namer	   r
   Úkey_namer   r   r   r"   f   sP   ÿÿÿþr"   c                 C   s   |   ¡ d d… }|tv S )Nr   )Úlstripr1   )r'   r7   r   r   r   r/   ¡   s   r/   )Úcollections.abcr   Útypingr   Ú
exceptionsr   r1   r   r   ÚboolÚtupler   r   Úlistr   r"   r/   r   r   r   r   Ú<module>   sX    ûÿþüû.
ú4ûÿþüû
ú&ÿþýüû
ú;