U if@sdddddddddd d d d d dddddddddddgZdZddlZddlZddlZddlZddlZddlZddlZddl m Z Gdd d e Z ddZ Gd ddZifd!d Zd\d"dZd]d#d ZeZGd$d d ZGd%ddZejd&d'Zd^d(d)Zd*d+Zd,Zz eeZWnek r*YnXd-d.Zd/d0Zeeed1Zd2dZd3d4d5d6d7d8d9d:Z e e_ d;d<Z!d=d>Z"d?d@Z#dAdBZ$d_dddCdDdEdZ%GdFdGdGej&Z'd`dddCdDdHdZ(dIdZ)dadJdZ*dbdKdZ+GdLddZ,dcdMdZ-dddNdZ.e-Z/dedOdZ0GdPddZ1GdQddZ2dfdddRdSdZ3e4dTej5j6Z7GdUddZ8dVdWZ9dXdYZ:zeZ;ddZlk rYn Xe=eedS)gCommentdumpElement ElementTree fromstringfromstringlist iselement iterparseparse ParseErrorPIProcessingInstructionQName SubElementtostring tostringlist TreeBuilderVERSIONXMLXMLID XMLParser XMLPullParserregister_namespace canonicalizeC14NWriterTargetz1.3.0N) ElementPathc@s eZdZdS)r N)__name__ __module__ __qualname__r r :/opt/alt/python38/lib64/python3.8/xml/etree/ElementTree.pyr js cCs t|dS)Ntag)hasattr)elementr r r!rxsc@seZdZdZdZdZdZifddZddZddZ dd Z d d Z d d Z ddZ ddZddZddZddZddZddZddZddZd8d d!Zd9d"d#Zd:d$d%Zd;d&d'Zd(d)Zdd4d5Z d6d7Z!dS)?rNcKs6t|tstd|jjf||_|||_g|_dS)Nzattrib must be dict, not %s) isinstancedict TypeError __class__rr"attrib _children)selfr"r)extrar r r!__init__s  zElement.__init__cCsd|jj|jt|fS)Nz<%s %r at %#x>)r(rr"idr+r r r!__repr__szElement.__repr__cCs |||SN)r()r+r"r)r r r! makeelements zElement.makeelementcCs0||j|j}|j|_|j|_||dd<|Sr1)r2r"r)texttail)r+elemr r r!copys  z Element.copycCs t|jSr1)lenr*r/r r r!__len__szElement.__len__cCstjdtddt|jdkS)NzyThe behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead. stacklevelr)warningswarn FutureWarningr7r*r/r r r!__bool__s zElement.__bool__cCs |j|Sr1r*r+indexr r r! __getitem__szElement.__getitem__cCs8t|tr |D]}||qn ||||j|<dSr1)r%slice_assert_is_elementr*)r+rBr$Zeltr r r! __setitem__s   zElement.__setitem__cCs |j|=dSr1r@rAr r r! __delitem__szElement.__delitem__cCs|||j|dSr1rEr*appendr+ subelementr r r!rIs zElement.appendcCs$|D]}|||j|qdSr1rH)r+elementsr$r r r!extends zElement.extendcCs|||j||dSr1)rEr*insert)r+rBrKr r r!rNs zElement.insertcCs t|tstdt|jdS)Nzexpected an Element, not %s)r% _Element_Pyr'typer)r+er r r!rEs zElement._assert_is_elementcCs|j|dSr1)r*removerJr r r!rRs zElement.removecCstjdtdd|jS)NzaThis method will be removed in future versions. Use 'list(elem)' or iteration over elem instead.r9r:)r<r=DeprecationWarningr*r/r r r! getchildrens zElement.getchildrencCst|||Sr1)rfindr+path namespacesr r r!rU!s z Element.findcCst||||Sr1)rfindtextr+rWdefaultrXr r r!rY,s zElement.findtextcCst|||Sr1)rfindallrVr r r!r\:s zElement.findallcCst|||Sr1)riterfindrVr r r!r]Es zElement.iterfindcCs |jg|_d|_|_dSr1)r)clearr*r3r4r/r r r!r^Ps z Element.clearcCs|j||Sr1)r)get)r+keyr[r r r!r_[s z Element.getcCs||j|<dSr1)r))r+r`valuer r r!sethsz Element.setcCs |jSr1)r)keysr/r r r!rcrsz Element.keyscCs |jSr1)r)itemsr/r r r!rd{s z Element.itemsccsD|dkr d}|dks|j|kr$|V|jD]}||EdHq*dS)N*)r"r*iter)r+r"rQr r r!rfs  z Element.itercCstjdtddt||S)NzbThis method will be removed in future versions. Use 'elem.iter()' or 'list(elem.iter())' instead.r9r:r<r=rSlistrfr+r"r r r! getiterators zElement.getiteratorccsX|j}t|ts|dk rdS|j}|r,|V|D]"}|EdH|j}|r0|Vq0dSr1)r"r%strr3itertextr4)r+r"trQr r r!rlszElement.itertext)N)NN)N)N)N)N)N)"rrrr"r)r3r4r-r0r2r6r8r?rCrFrGrIrMrNrErRrTrUrYr\r]r^r_rbrcrdrfrjrlr r r r!r}s>            cKs"||}|||}|||Sr1)r2rI)parentr"r)r,r$r r r!rs   cCstt}||_|Sr1)rrr3)r3r$r r r!rs cCs&tt}||_|r"|jd||_|S)N )rr r3)targetr3r$r r r!r s c@sVeZdZdddZddZddZdd Zd d Zd d ZddZ ddZ ddZ dS)r NcCs|rd||f}||_dS)Nz{%s}%sr3)r+Z text_or_urir"r r r!r-s zQName.__init__cCs|jSr1rqr/r r r!__str__sz QName.__str__cCsd|jj|jfS)Nz<%s %r>)r(rr3r/r r r!r0szQName.__repr__cCs t|jSr1)hashr3r/r r r!__hash__szQName.__hash__cCs t|tr|j|jkS|j|kSr1r%r r3r+otherr r r!__le__s  z QName.__le__cCs t|tr|j|jkS|j|kSr1rurvr r r!__lt__s  z QName.__lt__cCs t|tr|j|jkS|j|kSr1rurvr r r!__ge__ s  z QName.__ge__cCs t|tr|j|jkS|j|kSr1rurvr r r!__gt__s  z QName.__gt__cCs t|tr|j|jkS|j|kSr1rurvr r r!__eq__s  z QName.__eq__)N) rrrr-rrr0rtrxryrzr{r|r r r r!r s c@seZdZdddZddZddZddd Zdd d Zdd d Zd ddZ d!ddZ d"ddZ d#ddZ d$ddddZ ddZdS)%rNcCs||_|r||dSr1)_rootr )r+r$filer r r!r-'szElementTree.__init__cCs|jSr1r}r/r r r!getroot-szElementTree.getrootcCs ||_dSr1r)r+r$r r r!_setroot1szElementTree._setrootcCsd}t|dst|d}d}z^|dkrLt}t|drL|||_|jW2S|d}|s\qh||qL||_|jWS|r|XdS)NFreadrbT _parse_wholei)r#opencloserrr}rfeed)r+sourceparser close_sourcedatar r r!r ;s$          zElementTree.parsecCs |j|Sr1)r}rfrir r r!rf`s zElementTree.itercCstjdtddt||S)NzbThis method will be removed in future versions. Use 'tree.iter()' or 'list(tree.iter())' instead.r9r:rgrir r r!rjms zElementTree.getiteratorcCs:|dddkr,d|}tjd|tdd|j||SNr/.zThis search is broken in 1.3 and earlier, and will be fixed in a future version. If you rely on the current behaviour, change it to %rr9r:)r<r=r>r}rUrVr r r!rUus zElementTree.findcCs<|dddkr,d|}tjd|tdd|j|||Sr)r<r=r>r}rYrZr r r!rYs zElementTree.findtextcCs:|dddkr,d|}tjd|tdd|j||Sr)r<r=r>r}r\rVr r r!r\s zElementTree.findallcCs:|dddkr,d|}tjd|tdd|j||Sr)r<r=r>r}r]rVr r r!r]s zElementTree.iterfindTshort_empty_elementsc Cs|s d}n|tkrtd||s4|dkr0d}nd}|}t||}|dkr|sd|dkr|dkr|} |dkrddl} | } |d | f|d krt||jn,t|j|\} } t|} | ||j| | |d W5QRXdS) Nxmlzunknown method %rc14nutf-8us-ascii)rrunicoderrz$ r3r) _serialize ValueErrorlower _get_writerlocaleZgetpreferredencoding_serialize_textr} _namespaces)r+file_or_filenameencodingxml_declarationdefault_namespacemethodrZ enc_lowerwriteZdeclared_encodingrqnamesrXZ serializer r r!rs:    zElementTree.writecCs|j|ddS)Nr)r)r)r+r~r r r! write_c14nszElementTree.write_c14n)NN)N)N)N)N)NN)N)N)NNNN)rrrr-rrr rfrjrUrYr\r]rrr r r r!rs$  %      :c cs"z |j}WnPtk rZ|dkr.t|d}nt|d|dd}||jVW5QRXYnX|dkrl|Vnt}t|tjr|}nft|tjrt |}| |j nBt}dd|_ ||_z|j |_ |j|_Wntk rYnXtj||ddd}| |j |jVW5QRXdS) Nrwxmlcharrefreplace)rerrorscSsdSNTr r r r r!0z_get_writer.. )rrnewline)rAttributeErrorr contextlib ExitStackr%ioBufferedIOBase RawIOBaseBufferedWritercallbackdetachwritableseekabletell TextIOWrapper)rrrr~stackr r r!rsB         rcsddiird<fdd}|D]}|j}t|trZ|jkr||jn.add_qname) rfr"r%r r3rkrr rrd)r5rrr"r`rar3r rr!rBs4         rc Ks|j}|j}|tkr$|d|nv|tkr<|d|n^||}|dkr||r\|t||D]}t|||d|dq`n|d|t|} | s|r2|rt|dddD](\} } | rd| } |d | t | fq| D]L\} } t | t r| j} t | t r|| j} nt | } |d || | fq|sHt |sH|s|d |rb|t||D]}t|||d|dqf|d |d n|d |j r|t|j dS)N r.r`: xmlns%s="%s" %s="%s">)r"r3rr _escape_cdata_serialize_xmlrhrdsorted_escape_attribr%r r7r4) rr5rrXrkwargsr"r3rQrdvkr r r!rs\              r) ZareabaseZbasefontbrcolframeZhrZimginputZisindexlinkmetaZparamc Ks|j}|j}|tkr(|dt|n|tkrD|dt|nh||}|dkr|rd|t||D]}t|||dqhn,|d|t|}|s|r8|rt|dddD](\} } | rd| } |d| t | fq|D]N\} } t | t r| j} t | t r|| j} nt | } |d || | fq|d | } |rx| d ksb| d krl||n |t||D]}t|||dq|| tkr|d |d |jr|t|jdS)NrrrcSs|dSrr rr r r!rrz!_serialize_html..rrrrrZscriptZstyler)r"r3rrr _serialize_htmlrhrdrrr%r _escape_attrib_htmlr HTML_EMPTYr4) rr5rrXrr"r3rQrdrrZltagr r r!rsX            rcCs*|D] }||q|jr&||jdSr1)rlr4)rr5partr r r!rs  r)rhtmlr3cCsLtd|rtdttD]\}}||ks8||kr t|=q |t|<dS)Nzns\d+$z'Prefix format reserved for internal use)rematchrrhrrd)rrrrr r r!rs rrZrdfZwsdlZxsZxsiZdc)$http://www.w3.org/XML/1998/namespacezhttp://www.w3.org/1999/xhtmlz+http://www.w3.org/1999/02/22-rdf-syntax-ns#z http://schemas.xmlsoap.org/wsdl/z http://www.w3.org/2001/XMLSchemaz)http://www.w3.org/2001/XMLSchema-instancez http://purl.org/dc/elements/1.1/cCstd|t|jfdS)Nzcannot serialize %r (type %s))r'rPrrqr r r!rsrc CshzBd|kr|dd}d|kr*|dd}d|kr>|dd}|WSttfk rbt|YnXdS)N&&r<r>replacer'rrrqr r r!r!s   rc Cszd|kr|dd}d|kr*|dd}d|kr>|dd}d|krR|dd}d |krf|d d }d |krz|d d }d |kr|d d }d |kr|d d}|WSttfk rt|YnXdS)Nrrrrrr""z r z  z rrqr r r!r1s(        rc CshzBd|kr|dd}d|kr*|dd}d|kr>|dd}|WSttfk rbt|YnXdS)Nrrrrrrrrqr r r!rMs   rT)rrrcCs:|dkrtnt}t|j||||||d|S)Nrrrrr)rStringIOBytesIOrrgetvalue)r$rrrrrstreamr r r!r\s c@s4eZdZddZddZddZddZd d Zd S) _ListDataStreamcCs ||_dSr1)lst)r+rr r r!r-vsz_ListDataStream.__init__cCsdSrr r/r r r!rysz_ListDataStream.writablecCsdSrr r/r r r!r|sz_ListDataStream.seekablecCs|j|dSr1)rrI)r+br r r!rsz_ListDataStream.writecCs t|jSr1)r7rr/r r r!rsz_ListDataStream.tellN)rrrr-rrrrr r r r!rts rcCs*g}t|}t|j||||||d|S)Nr)rrr)r$rrrrrrrr r r!rs cCsLt|tst|}|jtjdd|j}|r<|ddkrHtjddS)Nr)rr)r%rrsysstdoutrr4)r5r4r r r!rs  cCst}||||Sr1)rr )rrtreer r r!r s  csft||dfddGfdddtjj}|d_~dtdsbtdd S) N)events_parserc3s^zJEdHd}|s q,|q}EdH|_W5rXXdS)Ni@)r read_eventsrr_close_and_return_rootroot)rr)rit pullparserrr r!iterators   ziterparse..iteratorcseZdZjZdS)z$iterparse..IterParseIteratorN)rrr__next__r )rr r!IterParseIteratorsrFrrT)r collectionsabcIteratorrr#r)rrrrr )rrrrrr!rs   c@sDeZdZdddddZddZddZd d Zd d Zd dZdS)rN)rcCs<t|_|pttd|_|dkr(d}|j|j|dS)Nrp)end)rdeque _events_queuerrr _setevents)r+rrr r r!r-s  zXMLPullParser.__init__c CsZ|jdkrtd|rVz|j|Wn.tk rT}z|j|W5d}~XYnXdS)Nz!feed() called after end of stream)rrr SyntaxErrorrrI)r+rexcr r r!rs zXMLPullParser.feedcCs|j}d|_|Sr1)rr)r+rr r r!rs z$XMLPullParser._close_and_return_rootcCs |dSr1)rr/r r r!rszXMLPullParser.closeccs.|j}|r*|}t|tr"|q|VqdSr1)rpopleftr% Exception)r+reventr r r!r s  zXMLPullParser.read_eventscCs |jdkrtd|jdS)Nz"flush() called after end of stream)rrflushr/r r r!rs zXMLPullParser.flush)N) rrrr-rrrrrr r r r!rs   cCs"|sttd}|||SNr rrrr)r3rr r r!r s   cCsR|sttd}|||}i}|D]}|d}|r.|||<q.||fS)Nr r.)rrrrrfr_)r3rrZidsr5r.r r r!r1s      cCs,|sttd}|D]}||q|Srr)Zsequencerr3r r r!rIs   c@sdeZdZddddddddZddZdd Zd d Zd d ZddZddZ dddZ ddZ dS)rNF)comment_factory pi_factoryinsert_comments insert_piscCsdg|_g|_d|_d|_d|_|dkr*t}||_||_|dkrBt}||_ ||_ |dkrZt }||_ dSr1) _data_elem_lastr}_tailr_comment_factoryrr _pi_factoryrr_factory)r+Zelement_factoryrrrrr r r!r-os zTreeBuilder.__init__cCs|jSr1rr/r r r!rszTreeBuilder.closecCs>|jr:|jdk r4d|j}|jr,||j_n||j_g|_dSNr)rrjoinrr4r3r+r3r r r!_flushs   zTreeBuilder._flushcCs|j|dSr1)rrIr+rr r r!rszTreeBuilder.datacCsX|||||_}|jr2|jd|n|jdkrB||_|j|d|_|S)Nrr)r&r"rrrIr}r)r+r"attrsr5r r r!starts  zTreeBuilder.startcCs ||j|_d|_|jSr)r&rpoprrrir r r!r s zTreeBuilder.endcCs||j|j|Sr1)_handle_singler rr%r r r!comments zTreeBuilder.commentcCs||j|j||Sr1)r+r!r)r+rpr3r r r!pis zTreeBuilder.picGs:||}|r6|||_|jr0|jd|d|_|S)Nrr)r&rrrIr)r+factoryrNargsr5r r r!r+szTreeBuilder._handle_single)N)N) rrrr-rr&rr)r r,r-r+r r r r!r[s   c@steZdZdddddZddZddZd d Zd d Zd dZddZ ddZ ddZ ddZ ddZ ddZdS)rN)rprc Csdzddlm}Wn>tk rNz ddl}Wntk rHtdYnXYnX||d}|dkrjt}||_|_||_|_ |j |_ i|_ |j |_t|dr|j|_t|dr|j|_t|dr|j|_t|dr|j|_t|d r|j|_t|d r|j|_t|d r|j|_d |_d |_d |_ d|_!i|_"zd |j#|_$Wnt%k r^YnXdS)Nrexpatz7No module named expat; use SimpleXMLTreeBuilder insteadrr)r start_nsend_nsrr,r-rzExpat %d.%d.%d)& xml.parsersr1 ImportErrorZpyexpatZ ParserCreaterrrrp_targeterror_error_names_defaultZDefaultHandlerExpandr#_startStartElementHandler_endEndElementHandler _start_nsStartNamespaceDeclHandler_end_nsEndNamespaceDeclHandlerrZCharacterDataHandlerr,CommentHandlerr-ProcessingInstructionHandlerZ buffer_textordered_attributesspecified_attributes_doctypeentity version_infoversionr)r+rprr1rr r r!r-sP           zXMLParser.__init__cCs8|j}|j}|D] }|dkrDd|_d|_|||jfdd}||_q|dkrf|||jfdd}||_q|dkrt|j dr|||j fd d}n||fd d}||_ q|d krt|j d r|||j fd d}n||fdd}||_ q|dkr|||fdd}||_q|dkr&|||fdd}||_qtd|qdS)Nr)rcSs|||||fdSr1r )r"Z attrib_inrrIr)r r r!handlersz%XMLParser._setevents..handlerr cSs||||fdSr1r )r"rrIr r r r!rKszstart-nsr2cSs|||||fdSr1r )rrrrIr2r r r!rK&scSs|||p d|pdffdSr#r )rrrrIr r r!rK*szend-nsr3cSs||||fdSr1r )rrrIr3r r r!rK0scSs||dfdSr1r )rrrIr r r!rK4sr,cSs|||j|fdSr1)rpr,)r3rrIr+r r r!rK8sr-cSs|||j||fdSr1)rpr-)Z pi_targetrrrIr+r r r!rK<szunknown event %r)rrIrErFr;r<r=r>r#rpr?r@rArBrCrDr)r+Z events_queueZevents_to_reportrrIZ event_namerKr r r!r sL          zXMLParser._seteventscCs&t|}|j|_|j|jf|_|dSr1)r codelinenooffsetZposition)r+raerrr r r! _raiseerrorCszXMLParser._raiseerrorcCsFz|j|}Wn2tk r@|}d|kr2d|}||j|<YnX|S)Nrr)r9KeyError)r+r`namer r r!_fixnameIszXMLParser._fixnamecCs|j|p d|pdSr#)rpr2r+rrr r r!r?TszXMLParser._start_nscCs|j|p dSr#)rpr3)r+rr r r!rAWszXMLParser._end_nscCsR|j}||}i}|rDtdt|dD]}||d||||<q&|j||S)Nrr9r)rSranger7rpr))r+r" attr_listZfixnamer)ir r r!r;ZszXMLParser._startcCs|j||Sr1)rpr rSrir r r!r=fszXMLParser._endc Cs|dd}|dkrz |jj}Wntk r6YdSXz||j|ddWnZtk rddlm}|d||jj |jj f}d|_ |jj |_ |jj |_ |YnXn"|dkr|dd d krg|_n|jdk r|d krd|_dS|}|sdS|j|t|j}|d kr|jd}|d krd|dkrd|j\}}} } | r| dd} n*|dkr|dkr|j\}}} d} ndSt|jdr|j|| | ddnt|drtdtd|_dS)Nrrrrr0z'undefined entity %s: line %d, column %d r z ~s z+C14NWriterTarget._start..csi|]}||qSr r )rr_) parse_qnamer r!rscSs |ddS)Nrr)r~)r_r r r!rrz)C14NWriterTarget._start..rcSs$g|]\}}|rd|nd|fqS)zxmlns:Zxmlnsr )rrrr r r! sz+C14NWriterTarget._start..rz+{http://www.w3.org/XML/1998/namespace}spaceZpreserverrrcSs&g|]\}}d|dt|dqS)roz="r)_escape_attrib_c14nrr r r!rsrT)rnrdrrrsrrrsortrIr_rwrkr$rryru)r+r"r(rrrZresolved_namesrZqattrsZ attr_nameraZ parsed_qnamesrVrrZ attr_qnamerZspace_behaviourrr )rr+r!r;|s`        zC14NWriterTarget._startcCst|jr|jd8_dS|jr&||d||dd|jt|jdk|_|j |j dS)Nrrrr) r{rr&rkrrwr*r7rzrtrurir r r!r s  zC14NWriterTarget.endcCsd|js dS|jrdS|jr&|dn|jr:|jr:||dt|d|js`|ddS)Nrz)rlr{rzrkryrr&rr%r r r!r,s  zC14NWriterTarget.commentcCsp|jr dS|jr|dn|jr0|jr0|||rNd|dt|dn d|d|jsl|ddS)Nrz)r{rzrkryrr&r)r+rprr r r!r-s  $zC14NWriterTarget.pi)N)N)rrrr-reversedr|rrrr$r&r2r)r;r r,r-r r r r!rs& %  % E  c Cs|zVd|kr|dd}d|kr*|dd}d|kr>|dd}d|krR|dd}|WSttfk rvt|YnXdS) Nrrrrrrr rrqr r r!rs    rc Csz~d|kr|dd}d|kr*|dd}d|kr>|dd}d|krR|dd}d |krf|d d }d |krz|d d }|WSttfk rt|YnXdS) Nrrrrrrrz rz rrrrqr r r!rs       r)re)_set_factories)N)N)N)NN)NN)N)NN)N)N)N)N)?__all__rrrr<rrZcollections.abcrrrrr rrrrr r r rcontextmanagerrrrrrb NameErrorrrrrrrrrrrrrrrr rrrrrrrrrcompileUNICODErrrrrrOZ _elementtreerr5r r r r!Ks >   0s 3 =2 2      0:   zp