QfgX HddlmZddlmZddlZddlmZddlmZm Z m Z ddl m Z m Z mZmZmZmZddlmZmZmZed ed Deed zZeed z Zeed z ZeZeZeZedZeedzZ eejBejDzdzZ#e#edzZ$eejJZ&edd ddddddZ'Gdde(Z)e*ddd#Z0 d?d$Z1d@d%Z2d@d&Z3dAd'Z4dAd(Z5 dBd)Z6 dCd*Z7dDd+Z8dEd,Z9dEd-Z:dFd.Z;dGd/ZdId4Z?dEd5Z@dJd6ZAdHd7ZB dKd8ZCdLd9ZDdMd:ZEdNd;ZFy)O) annotations)IterableN)MappingProxyType)AnyBinaryIO NamedTuple) RE_DATETIME RE_LOCALTIME RE_NUMBERmatch_to_datetimematch_to_localtimematch_to_number)Key ParseFloatPosc#2K|]}t|ywN)chr).0is 6/opt/alt/python312/lib64/python3.12/tomllib/_parser.py rs1y!s1vys  z z  z-_z"'  "\)z\bz\tz\nz\fz\rz\"z\\ceZdZdZy)TOMLDecodeErrorz0An error raised if a document is not valid TOML.N)__name__ __module__ __qualname____doc__rr$r$5s:r*r$ parse_floatc|j} |j}t ||S#t$r tddwxYw)z%Parse TOML from a binary file object.zEFile must be opened in binary mode, e.g. use `open('foo.toml', 'rb')`Nr+)readdecodeAttributeError TypeErrorloads)fpr,bss rloadr69sP  A HHJ  ,,  S  s /Ac|jdd}d}ttt}d}t |} t ||t } ||}|dk(r|dz }#|tvr!t|||||}t ||t }nr|dk(r[ ||dz}|jj|dk(rt|||\}}nt|||\}}t ||t }n|dk7r t||d t||} ||}|dk7r t||d |dz }#t$rY|j j"SwxYw#t$rd}YwxYw#t$rY|j j"SwxYw) zParse TOML from a string.z rrr)r [N#zInvalid statementz5Expected newline or end of document after a statement)replaceOutput NestedDictFlagsmake_safe_parse_float skip_charsTOML_WS IndexErrorKEY_INITIAL_CHARSkey_value_ruleflagsfinalize_pendingcreate_list_rulecreate_dict_rule suffixed_err skip_commentdatadict)r5r,srcposoutheaderchar second_chars rr2r2Es ))FD !C C uw 'CF' 4K c7+ s8D 4< 1HC  $ $ c3 DCS#w/C S[ #*-cAg,  II & & (c!.sC= V.sC= VS#w/C S[sC)<= =3$ s8D 4<SQ  qa   F 88==I  #"  #"   88== s6D&E E& EE EE E<;E<cHeZdZdZdZdZd dZd dZd dZd dZ ddZ dd Z y )r=z)Flags that map to parsed keys/namespaces.rr c0i|_t|_yr)_flagsset_pending_flagsselfs r__init__zFlags.__init__s') 47Er*c>|jj||fyr)rVaddrXkeyflags r add_pendingzFlags.add_pendings d ,r*c|jD]\}}|j||d|jjy)NF recursive)rVrUclearr\s rrEzFlags.finalize_pendings:,,IC HHS$%H 0- !!#r*cv|j}|ddD]}||vry||d}|j|ddy)Nnested)rTpop)rXr]contks r unset_allzFlags.unset_allsG{{SbA}78$D R$r*c|j}|dd|d}}|D]'}||vrttid||<||d})||vrttid||<|||rdndj|y)Nre)rDrecursive_flagsrfrfrlrD)rTrUr[)rXr]r^rbrh key_parentkey_stemris rrUz Flags.sets{{"3BxRH A}$'EcerRQ78$D 4 '*uRTUDN XI(7CGGMr*c|sy|j}|ddD]}||vry||}||dvry|d}|d}||vr||}||dvxs||dvSy)NFrerlTrfrD)rT)rXr]r^rhri inner_contrns ris_z Flags.is_s{{SbA}aJz"344h'D r7 t >D4=(KDD9J4K,K Kr*NreturnNone)r]rr^intrsrtr]rrsrt)r]rr^rurbboolrsrt)r]rr^rursrw) r%r&r'r(FROZEN EXPLICIT_NESTrYr_rErjrUrqr)r*rr=r=s23FM:-$   Nr*r=c4eZdZddZdd ddZd dZy) r<ci|_yr)rKrWs rrYzNestedDict.__init__s $& r*T access_listsc|j}|D]B}||vri||<||}|rt|tr|d}t|tr9td|S)Nrez There is no nest behind this key)rK isinstancelistKeyError)rXr]r}rhris rget_or_create_nestzNestedDict.get_or_create_nestsb IIA}Q7D 4 6BxdD)ABB r*c|j|dd}|d}||vr2||}t|ts td|j iyig||<y)Nrez/An object other than list found behind this key)rrrrappend)rXr]rhlast_keylist_s rappend_nest_to_listzNestedDict.append_nest_to_lists_&&s3Bx0r7 t NEeT*PQQ LL  TDNr*Nrr)r]rr}rwrsrKrv)r%r&r'rYrrr)r*rr<r<s2'"     " "r*r<c"eZdZUded<ded<y)r;r<rJr=rDN)r%r&r'__annotations__r)r*rr;r;s  Lr*r;cP |||vr |dz }|||vr |S#t$rY|SwxYw)Nr )rA)rLrMcharss rr?r?sJ #h% 1HC#h% J   J s  %%c |j||}|j |||s'|||vr |dz }|||vr t||d|||S#t$r!t|}|rt||d|dYfwxYw)Nz Expected r zFound invalid character )index ValueErrorlenrH isdisjoint)rLrMexpecterror_on error_on_eofnew_poss r skip_untilrsO))FC(   s3w/ 0#hh& 1HC#hh&3'?C|%LMM N Oc( sGy -CD$ N OsA'A;:A;cl ||}|dk(rt||dzdtdS|S#t$rd}Y+wxYw)Nr9r rFrr)rArILLEGAL_COMMENT_CHARS)rLrMrPs rrIrIsSs8 s{ q$)>U   J s % 33cR |}t||t}t||}||k(r|S'r)r?TOML_WS_AND_NEWLINErI)rLrMpos_before_skips rskip_comments_and_array_wsrs7 c#673$ / !J r*c(|dz }t||t}t||\}}|jj |t j s*|jj |t jrt||d|d|jj|t j d |jj||jd|s t||d|dz|fS#t$rt||ddwxYw) Nr zCannot declare z twiceFraCannot overwrite a value]z.Expected ']' at the end of a table declaration)r?r@ parse_keyrDrqr=ryrxrHrUrJrr startswithrLrMrNr]s rrGrGs1HC S#w 'Cc"HC yy}}S%--.#))--U\\2R3se6%BCCIIMM#u**eM<K ##C( >>#s #3%UVV 7C< K3%?@dJKs 8C99Dc|dz }t||t}t||\}}|jj |t j rt||d||jj||jj|t jd |jj||jd|s t||d|dz|fS#t$rt||ddwxYw)N"Cannot mutate immutable namespace Frarz]]z0Expected ']]' at the end of an array declaration)r?r@rrDrqr=rxrHrjrUryrJrrrrs rrFrF.s1HC S#w 'Cc"HC yy}}S%,,'3'I#%OPPIIIIMM#u**eM<K $$S) >>$ $3%WXX 7C< K3%?@dJKs (C))Dc t|||\} } dd d}}|z} fdtdt D} | D]f} |jj | t j rt||d| |jj| t j h|jj |t jrt||d| |jj|} || vr t||dt|ttfr/|jj! zt jd|| |<|S#t$rt||ddwxYw) Nrec3.K|] }d|zywrr))rrrOr]s rrz!key_value_rule..JsL9KAvBQ/9Ksr zCannot redefine namespace rrTra)parse_key_value_pairrangerrDrqr=ryrHr_rxrJrrrrKrrU) rLrMrNrOr,valuermrnabs_key_parentrelative_path_cont_keyscont_keynestr]s ` @rrCrCCsi+3[AOCes8SWJj(NLq#c(9KL+ 99==5#6#6 7sC+EhZ)PQ Q h(;(;< , yy}}^U\\2 :>:JK  Kxx**>:43%?@@%$& fslELLD ADN J K3%?@dJKs (E E8ct||\}} ||}|dk7r t||d|dz }t||t}t |||\}}|||fS#t$rd}YJwxYw)N=z,Expected '=' after a key in a key/value pairr )rrArHr?r@ parse_value)rLrMr,r]rPrs rrresc"HCs8 s{3%STT1HC S#w 'CS#{3JC U? sA A! A!ct||\}}|f}t||t} ||}|dk7r||fS|dz }t||t}t||\}}||fz }t||t}L#t$rd}YSwxYw)N.r )parse_key_partr?r@rA)rLrMkey_partr]rPs rrrus"3,MC{C S#w 'C  "3xD 3;8O qc7+&sC0 X {c7+  D sA11 A?>A?c ||}|tvr|}t||t}||||fS|dk(r t||S|dk(r t ||St ||d#t$rd}Y^wxYw)N'r!z(Invalid initial character for a key part)rABARE_KEY_CHARSr?parse_literal_strparse_one_line_basic_strrH)rLrMrP start_poss rrrss8 ~ c>2C #&&& s{ c** s{'S11 sC!K LL sA A&%A&c(|dz }t||dS)Nr F multiline)parse_basic_strrLrMs rrrs1HC 3u 55r*cX|dz }g}t||}|jd|r|dz|fS t|||\}}|j|t||}|||dz}|dk(r|dz|fS|dk7r t ||d|dz }t||}|jd|r|dz|fS~)Nr r,zUnclosed array)rrrrrH)rLrMr,arrayvalcs r parse_arrayrs1HCE $S# .C ~~c3Qw~ sC5S S(c2 cAg  87E> ! 8sC)9: : q(c2 >>#s #7E> ! r*c|dz }t}t}t||t}|j d|r|dz|j fS t |||\}}}|dd|d}}|j|tjrt||d| |j|d} || vrt||d ||| |<t||t}|||dz} | dk(r|dz|j fS| d k7r t||d t|t tfr"|j|tjd |dz }t||t} #t$rt||ddwxYw) Nr }TrerFr|rzDuplicate inline table key rzUnclosed inline tablera)r<r=r?r@rrKrrqrxrHrrrrrU) rLrMr, nested_dictrDr]rrmrnrrs rparse_inline_tablers1HC,K GE S#w 'C ~~c3Qw (((( .sCES%"3BxRH 99S%,, 'sC+McU)ST T O11*51QD t sC+Fxl)ST TXc7+ cAg  87K,,, , 8sC)@A A edD\ * IIc5<<4I 8 qc7++  OsC)CD$ N Os EE0Frct|||dz}|dz }|rL|dvrH|dk7r.t||t} ||}|dk7r t||d|dz }t||t}|dfS|dk(r t ||d S|d k(r t ||d S |t |fS#t$r|dfcYSwxYw#t$rt||ddwxYw) Nr>\ \ \ rrzUnescaped '\' in a stringr z\uz\U)r?r@rArHrparse_hex_charBASIC_STR_ESCAPE_REPLACEMENTSr)rLrMr escape_idrPs rparse_basic_str_escapers C#'"I1HCY"99  S#w/C 3xt|"3-IJJ 1HCc#67BwEc3**Ec3**M1)<<< Bw  M3%ABLMsB  B BBB7ct||dS)NTr)rrs r parse_basic_str_escape_multiliners !#sd ;;r*c||||z}t||k7stj|s t||d||z }t |d}t |s t||d|t |fS)NzInvalid hex valuez/Escaped character is not a Unicode scalar value)rHEXDIGIT_CHARS issupersetrHruis_unicode_scalar_valuer)rLrMhex_lenhex_strhex_ints rrrsw#g &G 7|wn&?&?&H3%8997NC'2G "7 +3%VWW G r*cL|dz }|}t||dtd}|dz|||fS)Nr rTr)rILLEGAL_LITERAL_STR_CHARS)rLrMrs rrrs>1HCI  S# 9 C 7C #& &&r*c,|dz }|jd|r|dz }|r!d}t||dtd}|||}|dz}nd}t||d \}}|j||s||fS|dz }|j||s|||zfS|dz }|||d zzfS) Nrr r'''Trr!rr)rr#ILLEGAL_MULTILINE_LITERAL_STR_CHARSr)rLrMliteraldelimend_posresults rparse_multiline_strr s1HC ~~dC  q   8  S!k%c3$? V >>% %F{1HC >>% %FUN""1HC %!)$ $$r*cl|r t}t}n t}t}d}|} ||}|dk(r4|s |dz||||zfS|j d|r |dz||||zfS|dz }@|dk(r||||z }|||\}}||z }|}a||vrt ||d||dz }z#t$rt ||ddwxYw) NrzUnterminated stringr!r """rr"zIllegal character )!ILLEGAL_MULTILINE_BASIC_STR_CHARSrILLEGAL_BASIC_STR_CHARSrrArHr) rLrMrr parse_escapesrrrP parsed_escapes rrr(s48 *. FI  Js8D 3;QwYs); ;;;~~eS)QwYs); ;;; 1HC  4< c)C( (F!.sC!8 C m #FI  8 sC+=dX)FG G q)  JsC)>?T I Js BB3c ||}|dk(r,|jd|rt||dSt||S|dk(r,|jd|rt||dSt ||S|dk(r|jd |r|d zdfS|d k(r|jd |r|d zdfS|dk(r t |||S|dk(r t |||Stj||}|r t|}|j|fStj||}|r|jt|fStj||}|r|jt!||fS|||dz} | dvr |dz|| fS|||d z} | dvr |d z|| fSt||d#t$rd}YwxYw#t$r}t||d|d}~wwxYw)Nr!rF)rrrTttruerffalser8{zInvalid date or datetimer>infnan>+inf+nan-inf-nanz Invalid value)rArrrrrrr matchr rrHendr rr r) rLrMr,rPdatetime_match datetime_objelocaltime_match number_match first_three first_fours rrrHs1s8 s{ >>% %&sC? ?'S11 s{ >>% %&sC> > c** s{ >>&# &7D=  s{ >>'3 '7E> ! s{3[11 s{!#sK88!&&sC0N L,^.coord_reprsa #c(?$yyq#&* 191WF3::dAs33FtfIfX..r*z (at ))rLstrrMrrsr)r$)rLrMmsgr s rrHrHs)/ cU% 3(<'=Q? @@r*cFd|cxkxrdkncxsd|cxkxrdkScS)Nriiir)) codepoints rrrs'  #e # G))Fw)FG)FGr*c0turtSdfd }|S)a%A decorator to make `parse_float` safe. `parse_float` must not return dicts or lists, because these types would be mixed with parsed TOML tables and arrays, thus confusing the parser. The returned decorated callable raises `ValueError` instead of returning illegal types. cZ|}t|ttfr td|S)Nz*parse_float must not return dicts or lists)rrKrr) float_str float_valuer,s rsafe_parse_floatz/make_safe_parse_float..safe_parse_floats-!), kD$< 0IJ Jr*)rrrsr)float)r,rs` rr>r>se  r*)r3rr,rrsdict[str, Any])r5rr,rrsr)rLrrMrrz Iterable[str]rsr) rLrrMrrrrzfrozenset[str]rrwrsr)rLrrMrrsr)rLrrMrrNr;rstuple[Pos, Key]) rLrrMrrNr;rOrr,rrsr)rLrrMrr,rrsztuple[Pos, Key, Any])rLrrMrrsr)rLrrMrrstuple[Pos, str])rLrrMrr,rrsztuple[Pos, list])rLrrMrr,rrsztuple[Pos, dict])rLrrMrrrwrsr)rLrrMrrrursr)rLrrMrrrwrsr)rLrrMrr,rrsztuple[Pos, Any])rLrrMrrrrsr$)rrursrw)r,rrsr)G __future__rcollections.abcrstringtypesrtypingrrr_rer r r r rr_typesrrr frozensetrr ASCII_CTRLrrrrrr@r ascii_lettersdigitsrrB hexdigitsrrrr$rr6r2r=r<r;r?rrIrrGrFrCrrrrrrrrrrrrrrHrr>r)r*rr(s #$ ",,)( 1uRy1 1Ic#h4G G %y6$.61B$B!3&G#/ E  $/6//&--?$FG"Yu%556++, 0 !;j;8= -38?D77t""DZ         , $* #-0?ID    %/   ,$ M 6 "0,B.3M MM&*MM:<'%>@A2 A2A2%/A2A2HA"Hr*