o
    v&ig                     @   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   V/var/www/html/karishye-ai-python/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  sz|dd\}}	d	|v rWt W n% ty}   z
|d	d\}}	W n tyz   t| |d
|d w Y nw | }
|	 }	|rtD ]}|	|d  }	q|
|	fS | }|rtD ]}||d  }qd |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
&
;