Re9xdZddlmZmZmZddlZddlZddlZ ddlm Z n#e $r ddl m Z YnwxYwddl m Z ddlmZdd l mZdd l mZdd l mZddlmZdd lmZmZd ZejdZejdjZGddeZGddeZdZ dZ!Gdde j"Z"dS)aModule for supporting the lxml.etree library. The idea here is to use as much of the native library as possible, without using fragile hacks like custom element names that break between releases. The downside of this is that we cannot represent all possible trees; specifically the following are known to cause problems: Text or comments as siblings of the root element Docypes with no name When any of these things occur, we emit a DataLossWarning )absolute_importdivisionunicode_literalsN)MutableMapping)base)DataLossWarning) constants)etree) _ihatexml)PY3 binary_typeTz {([^}]*)}(.*)asdceZdZdZdS) DocumentTypec0||_||_||_dSN)namepublicIdsystemId)selfrrrs /builddir/build/BUILDROOT/alt-python311-pip-21.3.1-3.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.py__init__zDocumentType.__init__)s     N)__name__ __module__ __qualname__rrrrr(s#!!!!!rrc6eZdZdZdZdZeeZdS)Documentc"d|_g|_dSr) _elementTree _childNodesrs rrzDocument.__init__0s rc|j}|jD]}||jdSr)r#getroot itersiblingsaddnext_element)relementlasts r appendChildzDocument.appendChild4s^ ((**%--//<<>>  D  W%&&&&&rc|jSr)r$r%s r_getChildNodeszDocument._getChildNodes;s rN)rrrrr-r/property childNodesrrrr!r!/sL'''   .))JJJrr!cgtjddfd |ddS)NTpreventDoubleDashCommentsrc j t|dst|drd|jjrr|jjs|jjsd|jjz}n*d|jjd|jjd|jjd}d d |d zz||}|(|}|(|'||d z| }|%dSdSt|tst|trNt|tstjd d ksJd d |zd |d dSd|D]}||d zdS|jt kred d |zd|jdt|dr-|jr(d d |zd |jd dSdSdSt|t&jsJt*j|j}|r|d}|d }t2j|}d d |zd|d |dn7d d |zd |jdt|drg}|jD]\} } t,| }|F|\}} | } t2j|}|d | } n | } || | ft?|D])\} } d d |d zz| d| d *|jr'd d |d zzd |jd |d z }|D]} | |t|dr0|jr+d d |d z zd |jd dSdSdS)Ntagr'z #document z | r r"z#document-fragmentztailr<>attrib=") hasattrappenddocinfo internalDTD public_id system_url root_namer' getpreviousgetnext isinstancestrbytessys version_infor6 comment_typetextr;r _Elementetree_builders tag_regexpmatchgroupr prefixes fromXmlNamer>itemsgroupssorted)r+indentdtd_str next_elementnsmatchnsr6prefix attributesrvalue attr_stringchild infosetFilterrvserializeElements rrfz(testSerializer..serializeElementEsw&&D Lw ** ? +&&&?. G#O58#O68"1GO4M"M$O555#O555#O666#8III ););WWEFFF&00 "..00<#/#;#;#=#=L#..00<".$$\6A:>>>#/#7#7#9#9L#.....GS)) ?Z-G-G ?!'3//K33CA3F!3K3K3K3K vwww?@@@@@ .///$+??L$$\6A:>>>>?? [L ( ( III#,,, E F F Fw'' FGL F vw|||DEEEEE F F F Fgu~66 6 6 6$/55gkBBG"]]1%%mmA&&"+B/ #,,,*7*C*CC*H*H*H*HJKKKK sV|||'4'@'@'M'M'M'MOPPPw)) P #*>#7#7#9#9 < >#3#3D,88>>!*!3B!717&> &3&?&?&E&E %%{E&:;;;;#)*#5#5PPKD%IIIcVaZ.@.@$$$NOOOO| L  );););W\\\JKKK aKF  0 0  ////w'' LGL L  );););W\\\JKKKKK L L L Lr )r)r InfosetFilterjoin)r+rdrerfs @@@rtestSerializerrjAs{ B+dKKKMELELELELELELELELLWa   99R==rcVgfd|dS)z4Serialize an element and its child nodes to a stringcVt|dsg|jjr=|jjr |jj}nd|jjz}||n|jtkrd|j dn|j sd|jdnWd d|j D}d|jd|d|j r|j |D] }|d |jdt|d r#|j r|j dSdSdS) Nr6r7zr<r=r9c$g|] \}}|d|dS)r?r:r).0rras r z6tostring..serializeElement..s?!L!L!L%0T515eee!<!L!L!LrzrirWr;)r+r[attrrcrerfs rrfz"tostring..serializeElementsw&& 0* #?*J%o5GG-0IIG '"""  W__.. / / / / [L ( ( IIIW\\\3 4 4 4 4> ; GKKK12222xx!L!L4;N4H4H4J4J!L!L!LMM w{{{DDD9:::| ( ','''  ( (  '''' III. / / / 7F # # $  $ IIgl # # # # # $ $ $ $r)ri)r+rerfs @@rtostringrssK B$$$$$$@W 772;;rcleZdZeZeZdZdZeZ e Z d dZ dZ dZdZdZdZd d Zd fd Zd ZxZS) TreeBuilderNFchtjt|tjdx|_||_GfddtGfddj}Gfdd j }||_ ||_ tj ||dS) N)fullTreeTr3cDeZdZdZfdZdZdZdZdZdZ dZ d S) (TreeBuilder.__init__..Attributesc||_dSr)r*rr+s rrz1TreeBuilder.__init__..Attributes.__init__s ' rct|tr(d|dd|d}n|}|S)N{r }r)rItuplecoerceAttribute)rkeyrrds r _coerceKeyz3TreeBuilder.__init__..Attributes._coerceKeys\c5))>>'*1vvv}/L/LSQRV/T/T/TUDD(88==D rc|jjj||}ts*t |t r|d}|S)Nascii)r*r>rrrIrdecoderrras r __getitem__z4TreeBuilder.__init__..Attributes.__getitem__sO .5dooc6J6JK2z%==2!LL11E rcT||jjj||<dSrr*r>rrs r __setitem__z4TreeBuilder.__init__..Attributes.__setitem__s&FK &-dooc.B.BCCCrcP|jjj||=dSrr)rrs r __delitem__z4TreeBuilder.__init__..Attributes.__delitem__s$M*1$//#2F2FGGGrc>t|jjjSr)iterr*r>r%s r__iter__z1TreeBuilder.__init__..Attributes.__iter__sDM29:::rc>t|jjjSr)lenr*r>r%s r__len__z0TreeBuilder.__init__..Attributes.__len__s4=18999rcH|jjjSr)r*r>clearr%s rrz.TreeBuilder.__init__..Attributes.clears}-4::<<.Elementc|}j|||||_dS)N) namespace) coerceElementElementr _attributes)rrrrbuilderrds rrz.TreeBuilder.__init__..Element.__init__sK$22488((ty(III#-:d#3#3   rc||_||j|j|j_dSr)r_name _getETreeTag _namespacer*r6)rrrds r_setNamez.TreeBuilder.__init__..Element._setNamesA*88>> $($5$5J%1%1 !!!rc8|jSr)rVr)rrds r_getNamez.TreeBuilder.__init__..Element._getNames$00<<.Element._getAttributess ''rcf|j}|||dSr)r`rupdate)rrar`s r_setAttributesz4TreeBuilder.__init__..Element._setAttributess5!_   """!!%(((((rNcj|}j|||dSr)coerceCharactersr insertText)rdata insertBeforerrds rrz0TreeBuilder.__init__..Element.insertTexts6$55d;;**4|DDDDDrct||j|j}|jjr)|jj|jj|Sr)typerrr*r>rr{s r cloneNodez/TreeBuilder.__init__..Element.cloneNodesO$$t**TY??='I$+224=3GHHHrr) rrrrrrr0rrrr`rr)rrrdsrrrs 4 4 4 4 4 4 4  1 1 1 1 1  = = = = =8Hh//D ( ( ( ) ) ) "..AAJ E E E E E E E     rrcDeZdZfdZfdZdZeeeZdS)%TreeBuilder.__init__..Commentch|}j||dSr) coerceCommentCommentr)rrrrds rrz.TreeBuilder.__init__..Comment.__init__ s4$22488((t44444rcJ|}||j_dSr)rr*rO)rrrds r_setDataz.TreeBuilder.__init__..Comment._setDatas&$22488%) """rc|jjSr)r*rOr%s r_getDataz.TreeBuilder.__init__..Comment._getDatas }))rN)rrrrrrr0r)rrdsrrr sh 5 5 5 5 5 5 * * * * * * * *8Hh//DDDrr)rQgetETreeModuler r rhrdnamespaceHTMLElementsrrr elementClass commentClassrrur)rrrwrrrrrds @@@rrzTreeBuilder.__init__s! /III-6-D_c-d-d-dd *%:" = = = = = = = = = =@" " " " " " " " " go" " " H 0 0 0 0 0 0 0 0go 0 0 0$# !!$(=>>>>>rcxtj||j|_g|_d|_dSr)rruresetinsertCommentInitial insertCommentinitial_commentsrpr%s rrzTreeBuilder.resets7 t$$$!6 " rc t|Sr)rjr{s rrjzTreeBuilder.testSerializer#sg&&&rcdtr |jjS|jjSr)rwdocumentr#r'r%s r getDocumentzTreeBuilder.getDocument&s,  8=- -=-5577 7rcg}|jdj}|jr||j|t ||jr||j|S)Nr) openElementsr*rOrAextendlistr;)rfragmentr+s r getFragmentzTreeBuilder.getFragment,sp#A&/ < * OOGL ) ) )W &&& < * OOGL ) ) )rc0|d}|d}|d}|s#tjdtd|_dS|j|}||krtjdt||||}||_dS)Nrrrz#lxml cannot represent empty doctypez%lxml cannot represent non-xml doctype)warningswarnr rprdr doctypeClass)rtokenrrr coercedNamerps r insertDoctypezTreeBuilder.insertDoctype6sV}$$ # M? Q Q QDLLL,::4@@Kd"" EWWW'' XxHHG"DLLLrcp| ||jusJ|jjJ|j|dSr)rr#rrA)rrparents rrz TreeBuilder.insertCommentInitialFsG~4=!8!8!8!8})111 $$T*****rc||jkrL|jjdjtkrt jdttt| ||dS)Nz@lxml cannot represent adjacent comments beyond the root elements) rr#r'r6rNrrr superrur)rrr __class__s rinsertCommentMainzTreeBuilder.insertCommentMainKsn dm # # *2244R8< LL M\^m n n n k4  ..tV<<<<rrr}r~)rprrrrd coercePubidfindrrr replacer fromstringrr addpreviousr* documentClassr getroottreer#getdefaultNamespacer6rr$rArrr) rrdocStrsysidroot comment_tokencommentrr etree_tag root_elements r insertRootzTreeBuilder.insertRootQs  < z<$ $ $ $ nt|'88 8F %1L)5? .::4<;P;VTVWWYZ<( # L1Ezz#!++ 310D0D &^`oppp % c8 < <zz#!++&5.0&5.0dNF cMF| E&M11 gixyyy88''"2 / /M'' f(=>>G   W- . . . .**,, %)%5%5%7%7 "V}IIk4+@AA  II %.IItt4I((y99 $  !((666   ..."3r)Fr)rrrr!rrrrr fragmentClassr implementationrrrjrrrrrr __classcell__)rs@rrurusMLLLMNZ?Z?Z?Z?x '''888 ### ++++ ====== 74747474747474rru)#__doc__ __future__rrrrrerLcollections.abcr ImportError collectionsrrrr r r rQr lxml.etreepip._vendor.sixrrrwcompilerRrr6rNobjectrr!rjrsrurrrrs  CBBBBBBBBB +.......+++********+''''''%%%%%%,,,,,,,,  RZ ( ( u}U##' !!!!!6!!!*****v***$LLL^&&&RO4O4O4O4O4$"O4O4O4O4O4s ! //