Ë
    äš¾j³D  ã                   óö  — d dl Z d dlZd dlZd dlmZmZmZmZmZm	Z	m
Z
mZmZ d dlmZmZmZ ddlmZ ddlmZ ddlmZmZmZ di d	œd
ededeeef   deeef   fd„Zdeeef   deeef   ddfd„Zd e«       dœdeeef   dedee   defd„Zd%dedefd„Z dede!e   fd„Z"dedeeef   de!e   fd„Z#dedefd„Z$	 d&deeef   deeef   deddfd„Z%g dœdeeef   dedee   defd „Z& G d!„ d"e«      Z'd#d$gZ(y)'é    N)	ÚMAX_INTERPOLATION_DEPTHÚConfigParserÚExtendedInterpolationÚInterpolationDepthErrorÚInterpolationMissingOptionErrorÚInterpolationSyntaxErrorÚNoOptionErrorÚNoSectionErrorÚParsingError)ÚAnyÚDictÚListé   ©ÚSECTION_PREFIX)ÚConfigValidationError)ÚVARIABLE_REÚtry_dump_jsonÚtry_load_jsonT)ÚinterpolateÚ	overridesÚtextr   r   Úreturnc                óÖ  — t        |xr | ¬«      }	 |j                  | «       t	        |«      }|r|d   ‚t        ||«      }|r|d   ‚i }|j                  «       D �cg c]  }|j                  d«      ‘Œ }	}|	D ]?  }
|}|
dd D ]  }|dk(  r|j                  |i «      n||   }Œ  |j                  |
d   i «       ŒA t        |j                  «       d	„ ¬
«      D ]O  \  }}|dk(  rŒ|j                  d«      }
|}|
D ]  }||   }Œ	 |D ]   }t        |j                  ||«      «      ||<   Œ" ŒQ t        ||«       t        ||«       |S # t        $ r}d|› �}t        |¬«      d‚d}~ww xY wc c}w )aO  Parse a config string into a nested dict.

    Handles the full pipeline: parse with ConfigParser, validate structure,
    apply overrides, interpret values, and resolve section references.

    Returns the nested dict and whether a second interpolation pass is needed
    (when overrides were applied with interpolation enabled).
    ©r   z<Make sure the sections and values are formatted correctly.

)ÚdescNr   ú.éÿÿÿÿÚ*c                 ó<   — t        | d   j                  d«      «      S )Nr   r   )ÚlenÚsplit)Úxs    ú\/home/spazio/kingdom_calls/work5/transenv/lib/python3.12/site-packages/confection/_parser.pyú<lambda>zparse_config.<locals>.<lambda>:   s   € ¬S°°1±·±¸C³Ó-A€ ó    )ÚkeyÚDEFAULT)Ú_get_configparserÚread_stringr   r   Ú_validate_configparserÚ_validate_overridesÚsectionsr"   Ú
setdefaultÚsortedÚitemsÚ_interpret_valueÚgetÚ_apply_overridesÚ_replace_section_refs)r   r   r   Úconfig_parserÚer   ÚerrorsÚresultÚsectionÚsection_partsÚpartsÚnodeÚpartÚvaluesr'   s                  r$   Úparse_configr?      s·  € ô &°+Ò2OÀiÀ-ÔP€Mð9Ø×!Ñ! $Ô'ô $ MÓ2€FÙØ�Q‰iˆÜ  °	Ó:€FÙØ�Q‰iˆØ€FØ7D×7MÑ7MÓ7OÖP¨G�W—]‘] 3Õ'ÐP€MÐPàò 'ˆØˆØ˜#˜2�Jò 	LˆDØ04¸²�4—?‘? 4¨Ô,ÀÀdÁ‰Dð	Là�‰˜˜b™	 2Õ&ð	'ô "Ø×ÑÓÑ#Aôò 
J‰ˆ�ð �iÒØØ—‘˜cÓ"ˆØˆØò 	ˆDØ˜‘:‰Dð	àò 	JˆCÜ(¨×):Ñ):¸7ÀCÓ)HÓIˆD�ŠIñ	Jð
Jô �V˜YÔ'ä˜& &Ô)Ø€MøôC ò 9ØOÐPQÈsÐSˆÜ#¨Ô.°DÐ8ûð9üò Qs   “E ÁE&Å	E#ÅEÅE#r8   c                 óˆ   — |j                  «       D ]/  \  }}|j                  d«      }| }|dd D ]  }||   }Œ	 |||d   <   Œ1 y)z{Apply dot-notation overrides to a nested dict.

    Override paths have already been validated by _validate_overrides.
    r   Nr   )r0   r"   )r8   r   r'   ÚvalueÚpathr<   r=   s          r$   r3   r3   K   s[   € ð
  —o‘oÓ'ò ‰
ˆˆUØ�y‰y˜‹~ˆØˆØ˜˜"�Iò 	ˆDØ˜‘:‰Dð	àˆˆT�"‰XŠñr&   )r   Úinline_pathsÚdatarC   c          
      ó®  — t        |¬«      }t        «       | fg}|D ]õ  \  }}dj                  |«      }|xr |d   dk7  }t        d„ |j	                  «       D «       «      }	|r%|	r#|j                  |«      s|j                  |«       n$|r"|j                  |«      s|j                  |«       |j                  «       D ]U  \  }
}|r|› d|
› �n|
}t        |d«      r||vr|j                  ||
fz   |f«       Œ9|j                  ||
t        ||«      «       ŒW Œ÷ t        j                  «       }|j                  |«       |j                  «       j!                  «       S )aP  Serialize a nested config dict to a config string.

    inline_paths: dotted paths whose values should be serialized as inline
        JSON rather than expanded into subsections. For example, if "a.b" is
        in inline_paths, data["a"]["b"] (even if it's a dict) will be
        serialized as ``b = {"key": "value"}`` under [a].
    r   r   r   r   c              3   ó6   K  — | ]  }t        |d «       –— Œ y­w)r0   N)Úhasattr)Ú.0Úvs     r$   ú	<genexpr>z#serialize_config.<locals>.<genexpr>j   s   è ø€ ÒH°QœW Q¨Ó0Ô0ÑHùs   ‚r0   )r)   ÚtupleÚjoinÚanyr>   Úhas_sectionÚadd_sectionr0   rG   ÚappendÚsetr   ÚioÚStringIOÚwriteÚgetvalueÚstrip)rD   r   rC   Ú	flattenedÚqueuerB   r<   Úsection_nameÚis_kwargÚ
has_leavesr'   rA   Ú
child_pathÚ	string_ios                 r$   Úserialize_configr^   X   sC  € ô "¨kÔ:€IÜ27³'¸4°Ð0A€EØò M‰
ˆˆdØ—x‘x “~ˆØÒ+˜D ™H¨™OˆÜÑH¸$¿+¹+»-ÔHÓHˆ
Ù‘J y×'<Ñ'<¸\Ô'Jà×!Ñ! ,Õ/Ù˜i×3Ñ3°LÔAØ×!Ñ! ,Ô/ØŸ*™*›,ò 	M‰JˆC�Ù4@˜L˜>¨¨3¨%Ñ0ÀcˆJÜ�u˜gÔ&¨:¸\Ñ+IØ—‘˜d c V™m¨UÐ3Õ4à—‘˜l¨C´¸uÀdÓ1KÕLñ	MðMô —‘“€IØ‡O�O�IÔØ×ÑÓ×%Ñ%Ó'Ð'r&   c                 óL   — t        | r
t        «       nd ¬«      }t        |_        |S )N)Úinterpolation)r   Ú_CustomInterpolationÚstrÚoptionxform)r   Úconfigs     r$   r)   r)   {   s"   € ÜÁ+Ô(<Ô(>ÐSWÔX€Fä€FÔØ€Mr&   r5   c                 ó@  — g }| j                  «       }|r3d}d}|D �cg c]  }|g|dœ‘Œ
 }}|j                  t        ||¬«      «       t        | j	                  «       «      }| j	                  «       D �]$  }|j                  d«      }	t        dt        |	«      «      D ]j  }
|	|
dz
     dk(  rŒdj                  |	d|
 «      }||vsŒ(d|j                  d«      vsŒ<d	}|	d
|	|
dz
     › d�dœg}|j                  t        ||¬«      «        n t        | j                  |«      «      }|D ]o  }|j                  |dz   «      sŒ|t        |«      dz   d j                  d«      d   }||v sŒ@|j                  d«      ddœg}|j                  t        |¬«      «       Œq �Œ' |S c c}w )al  Validate a configparser's structure before interpreting it into a Config.

    Checks that:
    - No values leak into the DEFAULT section (top-level values without a section)
    - All parent sections exist for dotted section names (e.g. "a.b" requires "a")
    - No key in a section conflicts with a child section name
    - No interpolation errors in values
    z/Found config values without a top-level sectionznot part of a section©ÚlocÚmsg©r7   Útitler   r   r   Nz>Error parsing config section. Perhaps a section name is wrong?z	Section 'z' is not definedr   zfound conflicting values)r7   )ÚdefaultsrP   r   rQ   r-   r"   Úranger!   rL   ÚoptionsÚ
startswith)r5   r7   Údefault_sectionÚ	err_titleÚerr_msgÚkÚerrÚsection_namesr9   rB   ÚiÚparentÚkeysÚotherÚchilds                  r$   r+   r+   ‚   sÇ  € ð €FØ#×,Ñ,Ó.€OÙØEˆ	Ø)ˆØ5DÖE°˜�s 7Ó+ÐEˆÐEØ�‰Ô+°3¸iÔHÔIÜ˜×.Ñ.Ó0Ó1€MØ ×)Ñ)Ó+ó EˆØ�}‰}˜SÓ!ˆÜ�qœ#˜d›)Ó$ò 	ˆAð �A˜‘E‰{˜cÒ!ØØ—X‘X˜d 2 A˜hÓ'ˆFð ˜]Ò*¨s¸&¿,¹,ÀsÓ:KÒ/KàTð ð  $¨i¸¸QÀ¹U¹°}ÐDTÐ,UÑVÐW�Ø—‘Ô3¸3ÀiÔPÔQÙð	ô �=×(Ñ(¨Ó1Ó2ˆØ"ò 	EˆEØ×Ñ ¨#¡Õ.Øœc '›l¨QÑ.Ð0Ð1×7Ñ7¸Ó<¸QÑ?�Ø˜D’=Ø#(§;¡;¨sÓ#3Ð<VÑWÐX�CØ—M‘MÔ"7¸sÔ"CÕDò	Eð%Eð0 €Mùò7 Fs   �Fc                 óø   — g }d}|D ]p  }d}|j                  d«      |dœg}d|vr|j                  t        ||¬«      «       Œ;|j                  dd«      \  }}|| vsŒU|j                  t        ||¬«      «       Œr |S )NzError parsing config overridesz*not a section value that can be overriddenr   rf   ri   r   )r"   rP   r   Úrsplit)	r5   r   r7   rp   r'   rq   rs   r9   Ú_s	            r$   r,   r,   ®   sŽ   € ð €FØ0€IØò 	NˆØ>ˆØ—y‘y “~¨gÑ6Ð7ˆØ�c‰>Ø�M‰MÔ/°sÀ)ÔLÔMØØ—Z‘Z  QÓ'‰
ˆ�à˜-Ò'Ø�M‰MÔ/°sÀ)ÔLÕMð	Nð €Mr&   rA   c                 ój   — t        | «      }t        |t        «      rt        j                  | «      r| }|S )z Interpret a single config value.)r   Ú
isinstancerb   r   Úsearch)rA   r8   s     r$   r1   r1   Á   s/   € ä˜5Ó!€Fô �&œ#Ô¤;×#5Ñ#5°eÔ#<ØˆØ€Mr&   Úrootr<   rv   c           
      ó2  — |j                  «       D ]  \  }}|› d|› �j                  d«      }t        |t        «      rt	        | ||¬«       Œ;t        |t
        «      r"|D �cg c]  }t        | |||g¬«      ‘Œ c}||<   Œmt        | |||g¬«      ||<   Œ� yc c}w )z9Replace section reference placeholders with actual dicts.r   ©rv   N)r0   rV   r~   Údictr4   ÚlistÚ_get_section_ref)r€   r<   rv   r'   rA   Ú
key_parentrI   s          r$   r4   r4   Î   s˜   € ð —j‘j“lò L‰
ˆˆUØ�x˜q  Ð&×,Ñ,¨SÓ1ˆ
Ü�eœTÔ"Ü! $¨°jÖAÜ˜œtÔ$ØRWÖXÈQÔ)¨$°¸6À3¸-ÖHÒXˆD�ŠIä(¨¨u¸fÀc¸]ÔKˆD�ŠIñLùò
 Ys   Á Br‚   c                ó   — t        |t        «      r#|j                  dt        › �«      rt	        |«      }t        |t        «      rT|j                  t        «      r?|t        k7  r6|j                  t        dd«      j                  d«      }| }|D ]  }||   }Œ	 |S t        |t        «      r&t        |v r|t        k7  rd}|ddœg}t        ||¬«      ‚|S )	zFResolve a single section reference placeholder, or return value as-is.ú"Ú r   r   ab  Can't reference whole sections or return values of function blocks inside a string or list

You can change your variable to reference a value instead. Keep in mind that it's not possible to interpolate the return value of a registered function, since variables are interpolated when the config is loaded, and registered functions are resolved afterwards.z'uses section variable in string or listrf   )r7   r   )r~   rb   rn   r   r   Úreplacer"   r   )r€   rA   rv   r;   r8   ÚitemÚerr_descrs   s           r$   r…   r…   Ü   sÖ   € ô �%œÔ %×"2Ñ"2Ø
ŒNÐÐô#ô ˜eÓ$ˆä�5œ#ÔØ×Ñœ^Ô,Ø”^Ò#à—‘œn¨b°!Ó4×:Ñ:¸3Ó?ˆØˆØò 	"ˆDØ˜D‘\‰Fð	"àˆÜ	�Eœ3Ô	¤N°eÑ$;ÀÌÒ@WðKð 	ð Ð&OÑPÐQˆÜ#¨3°XÔ>Ð>Ø€Lr&   c                   ó¶   ‡ — e Zd Zdededededef
ˆ fd„Zdedefd„Zdedededed	eeef   defd
„Zdedede	e   dededeeef   de
ddfd„Zdedefd„Zˆ xZS )ra   Úparserr9   ÚoptionrA   r   c                 ó†   •— |r-|d   |d   cxk(  rdk(  rn nt        j                  d|› d�«       t        ‰| �  ||||«      S )Nr   r   ú'zThe value [zZ] seems to be single-quoted, but values use JSON formatting, which requires double quotes.)ÚwarningsÚwarnÚsuperÚbefore_read)ÚselfrŽ   r9   r�   rA   Ú	__class__s        €r$   r•   z _CustomInterpolation.before_readý   sS   ø€ ñ �U˜1‘X  r¡Ô1¨cÕ1Ü�M‰MØ˜e˜Wð %Eð Eôô ‰wÑ" 6¨7°F¸EÓBÐBr&   rI   c                 óæ   — t         |v r|S 	 t        j                  |«      }t	        |t
        «      r|S t        j                  |«      j                  dd«      S # t        j                  $ r |cY S w xY w)zBCoerce a raw config value for use in a compound string expression.rˆ   z\")r   ÚjsonÚloadsÚJSONDecodeErrorr~   rb   ÚdumpsrŠ   )r–   rI   Úparseds      r$   Ú_coerce_for_string_contextz/_CustomInterpolation._coerce_for_string_context  sn   € ô ˜QÑØˆHð	Ü—Z‘Z “]ˆFô �fœcÔ"ØˆMô �z‰z˜&Ó!×)Ñ)¨#¨uÓ5Ð5øô ×#Ñ#ò 	ØŠHð	ús   ŒA ÁA0Á/A0rk   c           	      ó�   ‡ — g }‰ j                  ||||||d«       t        |«      dk(  r|d   S dj                  ˆ fd„|D «       «      S )Nr   r   r‰   c              3   ó@   •K  — | ]  }‰j                  |«      –— Œ y ­w)N)rž   )rH   Úpiecer–   s     €r$   rJ   z2_CustomInterpolation.before_get.<locals>.<genexpr>)  s   øè ø€ ÒMÀ%�t×6Ñ6°u×=ÑMùs   ƒ)r   r!   rL   )r–   rŽ   r9   r�   rA   rk   ÚLs   `      r$   Ú
before_getz_CustomInterpolation.before_get  sM   ø€ ð ˆØ×Ñ˜ ¨¨E°7¸HÀaÔHÜˆq‹6�QŠ;Ø�Q‘4ˆKØ�w‰wÓMÈ1ÔMÓMÐMr&   ÚaccumÚrestÚmapÚdepthNc           
      óJ  — |j                  ||d|¬«      }|t        kD  rt        |||«      ‚|�rN|j                  d«      }	|	dk  r|j	                  |«       y|	dkD  r|j	                  |d|	 «       ||	d }|dd }
|
dk(  r|j	                  d«       |dd }�ná|
dk(  �rÉ| j
                  j                  |«      }|€d	|› �}t        |||«      ‚|j                  d«      }|j                  d
d«      j                  dd«      }||j                  «       d }|}|}	 t        |«      dk(  r{|j                  |d   «      }||v}|s&||   }|j                  «       |j                  «       k(  }|s||   }n¬||j                  |d   «         j                  }| j!                  |«      }nyt        |«      dk(  rY|d   }|j                  |d   «      }d}|j                  ||d|¬«      }||k(  r6| j!                  ||› d|› �   j                  «      }nd|› �}t        |||«      ‚d|v r7t+        |j-                  |d¬«      «      }| j/                  |||||||dz   «       n$|j	                  |«       nd|›�}t        |||«      ‚|r�ŒMyy# t"        t$        t&        f$ r t)        ||||«      d‚w xY w)z+Resolve variable references like ${foo.bar}T)ÚrawÚfallbackú$r   Nr   é   ú{z%bad interpolation variable reference ú:r   Ú__FALLBACK__zMore than one ':' found: )r©   z+'$' must be followed by '$' or '{', found: )r2   r   r   ÚfindrP   Ú_KEYCREÚmatchr   ÚgrouprŠ   r{   Úendr!   rc   rV   ÚnameÚ_get_section_nameÚKeyErrorr
   r	   r   rƒ   r0   r   )r–   rŽ   r�   r¤   r¥   r9   r¦   r§   ÚrawvalÚpÚcÚmrs   Úorig_varrB   ÚsectÚoptÚis_section_refr©   rI   rY   rª   Únew_maps                          r$   r   z _CustomInterpolation.interpolate+  sç  € ð" —‘˜G V°À�ÓEˆØÔ*Ò*Ü)¨&°'¸6ÓBÐBÚØ—	‘	˜#“ˆAØ�1ŠuØ—‘˜TÔ"ØØ�1ŠuØ—‘˜T " 1˜XÔ&Ø˜A˜B�x�à�Q�q�	ˆAØ�CŠxØ—‘˜SÔ!Ø˜A˜B�x’Ø�c“à—L‘L×&Ñ& tÓ,�Ø�9ØAÀ$ÀÐH�CÜ2°6¸7ÀCÓHÐHØŸ7™7 1›:�Ø×'Ñ'¨¨SÓ1×8Ñ8¸¸aÓ@�Ø˜AŸE™E›G˜I��Ø�Ø�ð# Ü˜4“y A’~Ø$×0Ñ0°°a±Ó9˜ð *-°C¨˜Ù-Ø"% c¡(˜CØ-0¯Y©Y«[¸F¿L¹L»NÑ-J˜NÙ-Ø # C¡™Að ,2°&×2DÑ2DÀTÈ!ÁWÓ2MÑ+N×+SÑ+S˜LØ $× 6Ñ 6°|Ó D™AÜ˜T› ašØ# A™w˜Ø$×0Ñ0°°a±Ó9˜Ø#1˜Ø"ŸJ™J t¨S°dÀX˜JÓN˜ð  š=Ø $× 6Ñ 6°vÀÀÀaÈÀu¸oÑ7N×7SÑ7SÓ T™Að !:¸$¸Ð@˜Ü6°v¸wÈÓLÐLð
 ˜!‘8Ü" 6§<¡<°¸$ <Ó#?Ó@�GØ×$Ñ$ V¨S°%¸¸DÀ'È5ÐSTÉ9ÕUà—L‘L •Oðg ñj JNÐO�Ü.¨v°wÀÓDÐDõG øôp !¤.´-Ð@ò  Ü9Ø ¨°óàð ð ús   ÄDI> É>$J"rµ   c                 ó   — dt         › |› d�S )at  Generate the name of a section. Note that we use a quoted string here
        so we can use section references within lists and load the list as
        JSON. Since section references can't be used within strings, we don't
        need the quoted vs. unquoted distinction like we do for variables.

        Examples (assuming section = {"foo": 1}):
            - value: ${section.foo} -> value: 1
            - value: "hello ${section.foo}" -> value: "hello 1"
            - value: ${section} -> value: {"foo": 1}
            - value: "${section}" -> value: {"foo": 1}
            - value: "hello ${section}" -> invalid
        rˆ   r   )r–   rµ   s     r$   r¶   z&_CustomInterpolation._get_section_name„  s   € ð ”>Ð" 4 &¨Ð*Ð*r&   )Ú__name__Ú
__module__Ú__qualname__r   rb   r•   rž   r   r£   r   Úintr   r¶   Ú__classcell__)r—   s   @r$   ra   ra   ü   s  ø„ ð	CØ"ð	CØ-0ð	CØ:=ð	CØFIð	Cà	õ	Cð6¨Cð 6°Có 6ðNàðNð ðNð ð	Nð
 ðNð �s˜C�x‘.ðNð 
óNð(WEàðWEð ðWEð �C‰yð	WEð
 ðWEð ðWEð �#�s�(‰^ðWEð ðWEð 
óWEðr+ cð +¨c÷ +r&   ra   r?   r^   )T)r‰   ))rR   r™   r’   Úconfigparserr   r   r   r   r   r   r	   r
   r   Útypingr   r   r   Ú
_constantsr   Ú_errorsr   Úutilr   r   r   rb   Úboolrƒ   r?   r3   Ú	frozensetr^   r)   r„   r+   r,   r1   r4   r…   ra   Ú__all__© r&   r$   ú<module>rÐ      sá  ðÛ 	Û Û ÷
÷ 
õ 
÷ #Ñ "å &Ý *ß ;Ñ ;ð Ø "ò	2Ø
ð2ð ð2ð �C˜�H‰~ð	2ð
 
ˆ#ˆsˆ(�^ó2ðj
˜T # s (™^ð 
¸¸SÀ#¸X¹ð 
È4ó 
ð  Ù#,£;ò	 (Ø
ˆs�Cˆx‰.ð (ð ð (ð ˜C‘.ð	 (ð
 	ó (ñF 4ð °<ó ð)¨,ð )¸4Ð@UÑ;Vó )ðXØðØ,0°°c°©Nðà	Ð
Ñ óð&
˜Cð 
 Có 
ð ?AñLØ
ˆs�Cˆx‰.ðLØ $ S¨# X¡ðLØ8;ðLà	óLð >@òØ
ˆs�Cˆx‰.ðØ!$ðØ15°c±ðàóô@U+Ð0ô U+ðp Ð-Ð
.�r&   