
    iI                         S r SSKrSSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  / S	Qr
S
SKJr  S
SKJr  S
SKJr  S
SKJr  \" S5      r\" S5      r " S S5      r " S S5      rg)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                      \ rS rSr% \S   \S'   \\   \S'   SSS\SS4S jrS\S\S-  4S jr	\
S	\S\S-  4S
 j5       r\
S	\S\\/\4   S\S-  4S j5       r\
S	\SSS\\/\4   S\S-  4S j5       r\
SS	\S\SSS\\-  4S jj5       r\
S	\S\S\\/\4   S\\-  4S j5       r  SS	\S\S-  S\\/\4   S-  S\\-  \-  S-  4S jjrS	\S\4S jrS\\   4S jrS\\\\4      4S jrSrg)SectionWrapper   r	   confignamereturnNc                     Xl         X l        g Nr   r   )selfr   r   s      L/home/james-whalen/.local/lib/python3.13/site-packages/iniconfig/__init__.py__init__SectionWrapper.__init__   s    	    c                 N    U R                   R                  U R                  U5      $ r   r   lineofr   r   r   s     r   r!   SectionWrapper.lineof    s    {{!!$))T22r   keyc                     g r    r   r$   s     r   getSectionWrapper.get#   s    +.r   convertc                     g r   r&   )r   r$   r*   s      r   r(   r)   &   s    
 r   defaultc                     g r   r&   r   r$   r,   r*   s       r   r(   r)   -        r   c                     g r   r&   r.   s       r   r(   r)   5   s    LOr   c                     g r   r&   r.   s       r   r(   r)   8   s     r   c                 L    U R                   R                  U R                  XUS9$ )N)r*   r,   )r   r(   r   r.   s       r   r(   r)   A   s!     {{tyy#PPr   c                 N    U R                   R                  U R                     U   $ r   )r   sectionsr   r'   s     r   __getitem__SectionWrapper.__getitem__I   s     {{##DII.s33r   c              #      ^ #    T R                   R                  R                  T R                  0 5      nS[        S[
        4U 4S jjn[        XS9 S h  vN   g  N7f)Nr$   r   c                 P   > TR                   R                  TR                  U 5      $ r   r    )r$   r   s    r   r!   'SectionWrapper.__iter__.<locals>.lineofO   s    ;;%%dii55r   r$   )r   r4   r(   r   strintsorted)r   sectionr!   s   `  r   __iter__SectionWrapper.__iter__L   sI     %)[[%9%9%=%=dii%L	6 	6 	6 '...s   AAAAc              #   .   #    U  H  nXU   4v   M     g 7fr   r&   r"   s     r   itemsSectionWrapper.itemsT   s     DT
"" s   r   r   NN)__name__
__module____qualname____firstlineno__r   __annotations__r;   r   r<   r!   r   r(   r   r   r   r5   r   r?   tuplerB   __static_attributes__r&   r   r   r   r      s   +
*{ # $ 33 33: 3 .s.sTz. . 3%)$ 
d	    3%)$	
 
d  OsORO$O#(O O  3%)$	
 
b  ".2	QQ dQ 3%)$t+	Q
 
b3	Q4s 4s 4/(3- /#xc3h0 #r   r   c                      \ rS rSr% \\   \S'   \\\\\\4   4      \S'   \\\\\S-  4   \	4      \S'     S"SSS.S\\
R                  \   -  S\S-  S\S	\\\\\4   4   S-  S\\\\S-  4   \	4   S-  S
S4S jjjr\  S"SSS.S\\
R                  \   -  S\S-  S\S\S\S
S 4S jjj5       rS#S\S\S-  S
\	S-  4S jjr\S\S\S
\S-  4S j5       r\S\S\S\\/\4   S
\S-  4S j5       r\S\S\SSS\\/\4   S
\S-  4
S j5       r\ S#S\S\S\SSS
\\-  4
S jj5       r\S\S\S\S\\/\4   S
\\-  4
S j5       r  S$S\S\S\S-  S\\/\4   S-  S
\\-  \-  S-  4
S jjrS\S
\4S jrS
\\   4S jrS\S
\4S  jrS!rg)%r	   Y   pathr4   N_sources)	_sectionsrO   dataencodingrP   r   c                .   [         R                  " U5      U l        Ub  Ub  UnUnORUc-  [        U R                  US9 nUR	                  5       nS S S 5        [
        R                  " U R                  USS9u  pgXpl        X`l        g ! , (       d  f       N== f)NrR   F)strip_inline_comments)	osfspathrN   openreadr   parse_ini_datarO   r4   )	r   rN   rQ   rR   rP   rO   sections_datasourcesfps	            r   r   IniConfig.__init__^   s     IIdO	  X%9%MG |$))h72779D 8 &,%:%:		4u&"M
  % 87s   B
BTFrU   strip_section_whitespacerU   r`   c                    [         R                  " U5      nUc"  [        XcS9 nUR                  5       nSSS5        [        R
                  " UUUUS9u  pU " XhU	S9$ ! , (       d  f       N.= f)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
NrT   r_   )rN   rP   rO   )rV   rW   rX   rY   r   rZ   )
clsrN   rQ   rR   rU   r`   rW   r]   r[   r\   s
             r   parseIniConfig.parse}   sj    N 4<f0Bwwy 1 "(!6!6"7%=	"
 'JJ 10s   A
A*r>   r   c                 N    U R                   R                  X45      nUc  S $ US-   $ )Nr   )rO   r(   )r   r>   r   linenos       r   r!   IniConfig.lineof   s+    ""G?3~t56A:5r   c                     g r   r&   )r   r>   r   s      r   r(   IniConfig.get   s    
 r   r*   c                     g r   r&   )r   r>   r   r*   s       r   r(   ri      r/   r   r,   c                     g r   r&   r   r>   r   r,   r*   s        r   r(   ri      s     r   c                     g r   r&   rl   s        r   r(   ri      s     r   c                     g r   r&   rl   s        r   r(   ri      s     r   c                 f     U R                   U   U   nUb  U" U5      $ U$ ! [         a    Us $ f = fr   )r4   KeyError)r   r>   r   r,   r*   values         r   r(   ri      sG    	w/5E "u~%  	N	s   ! 00c                 L    XR                   ;  a  [        U5      e[        X5      $ r   )r4   rp   r   r"   s     r   r5   IniConfig.__getitem__   s!    }}$4. d))r   c              #   p   #    [        U R                  U R                  S9 H  n[        X5      v   M     g 7f)Nr:   )r=   r4   r!   r   r"   s     r   r?   IniConfig.__iter__   s)     4==dkk:D ,, ;s   46argc                     XR                   ;   $ r   )r4   )r   rv   s     r   __contains__IniConfig.__contains__   s    mm##r   )rO   rN   r4   )Nzutf-8r   rD   )rE   rF   rG   rH   r   r;   rI   r   rJ   r<   rV   PathLiker   classmethodboolrc   r!   r   r(   r   r   r   r   r5   r   r?   rx   rK   r&   r   r   r	   r	   Y   s   
*GCc!22344GE#sTz/2C7899
  	& =A@D&BKK$$& Dj& 	& 3S 112T9& %S4Z0#56=& 
&>   	4K '+).4KBKK$$4K Dj4K 	4K  $4K #'4K 
4K 4Kl6c 6t 6sTz 6   
t	    3%)$	
 
d    	
 3%)$ 
d  DH"%02=A	r    	
 3%)$ 
b  ".2  d	
 3%)$t+ 
b3	"* * *
-(>2 -$ $ $r   r	   )__doc__rV   collections.abcr   r   r   typingr   r   r   __all__ r   r   r   
exceptionsr
   r   r   r   r	   r&   r   r   <module>r      s[    
 $ $ #   
F    ! "T]T]># >#B`$ `$r   