U e5d.@sddlZddlZdZdZdZdZdZdZdZ d Z Gd d d ej j Z Gd d d ZGdddZGddde ZdZdddZdddZdS)N START_ELEMENT END_ELEMENTCOMMENTSTART_DOCUMENT END_DOCUMENTPROCESSING_INSTRUCTIONIGNORABLE_WHITESPACE CHARACTERSc@seZdZdZdZd$ddZddZddZdd Zd d Z d d Z ddZ ddZ ddZ ddZddZddZddZddZddZd d!Zd"d#ZdS)%PullDOMNcCszddlm}||_ddg|_|j|_g|_|jj|_z|jj|_Wnt k rVYnX|dig|_ |j d|_ g|_ dS)Nr) XML_NAMESPACExml) Zxml.domr documentFactory firstEvent lastEvent elementStackappendpushpopAttributeError _ns_contexts_current_contextpending_events)selfrr r'/usr/lib64/python3.8/xml/dom/pulldom.py__init__s     zPullDOM.__init__cCs|jd}|jd=|SNr )r)rresultrrrr!s z PullDOM.popcCs ||_dSN)_locator)rZlocatorrrrsetDocumentLocator&szPullDOM.setDocumentLocatorcCsHt|dsg|_|j|pd|f|j|j|pr?r@rDrHrLrMrOr/rUrVrrrrr s& 9  r c@s$eZdZddZddZddZdS) ErrorHandlercCs t|dSr)printrZ exceptionrrrwarningszErrorHandler.warningcCs|dSrrr\rrrerrorszErrorHandler.errorcCs|dSrrr\rrr fatalErrorszErrorHandler.fatalErrorN)rWrXrYr]r^r_rrrrrZsrZc@s\eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ dS)DOMEventStreamcCs2||_||_||_t|jds&|j|_|dS)Nfeed)streamparserbufsizer$_slurpgetEventreset)rrbrcrdrrrrs  zDOMEventStream.__init__cCs.t|_|jtjjjd|j|jdSr<) r pulldomrcZ setFeaturer saxZhandlerZfeature_namespacesZsetContentHandlerrTrrrrgszDOMEventStream.resetcCs0ddl}|jdtdd|}|r(|StdS)Nrz[DOMEventStream's __getitem__ method ignores 'pos' parameter. Use iterator protocol instead.) stacklevel)warningswarnDeprecationWarningrf IndexError)rposrlrcrrr __getitem__szDOMEventStream.__getitem__cCs|}|r|StdSr)rf StopIterationrrqrrr__next__szDOMEventStream.__next__cCs|SrrrTrrr__iter__szDOMEventStream.__iter__cCsl|}|g}|rh|\}}||kr&dS|tkr<|d||tkrP||n|tkr^|d=|}qdSr)rfr appendChildrr)rr9rCparentstokenZcur_noderrr expandNodes zDOMEventStream.expandNodecCs~|jjds|jj|j_|jjdsR|j|j}|sD|jdS|j|q|jjdd}|jjdd|jjd<|SNr+r) rhrrrbreadrdrcclosera)rbufrqrrrrfs    zDOMEventStream.getEventcCs|j|j|j|_|Sr)rcparserb_emitrfrTrrrreszDOMEventStream._slurpcCs,|jjdd}|jjdd|jjd<|Sr{)rhrrtrrrrszDOMEventStream._emitcCs|j|`d|_d|_dSr)rhrVrcrbrTrrrrV!s zDOMEventStream.clearN) rWrXrYrrgrrrurvrzrfrerrVrrrrr`s  r`c@s4eZdZddZddZddZddZd d Zd S) SAX2DOMcCs2t|||||jd}|jd}||dSNr )r r;rrw)rr5r6r7curNode parentNoderrrr;*s  zSAX2DOM.startElementNScCs0t||||jd}|jd}||dSr)r r?rrw)rr5r7rrrrrr?0s  zSAX2DOM.startElementcCs4t||||jdd}|jd}||dSNrr+r )r rHrrrw)rrFrGr9rrrrrH6s zSAX2DOM.processingInstructioncCs2t|||jdd}|jd}||dSr)r rLrrrwrrKr9rrrrrL<s  zSAX2DOM.ignorableWhitespacecCs2t|||jdd}|jd}||dSr)r rMrrrwrrrrrMBs  zSAX2DOM.charactersN)rWrXrYr;r?rHrLrMrrrrr(s ri?cCs@|dkr t}t|tr"t|d}n|}|s4tj}t|||S)Nrb)default_bufsize isinstancestropenr ri make_parserr`)Zstream_or_stringrcrdrbrrrrKs   rcCs6ddlm}t|}||}|s*tj}t|||S)Nr)StringIO)iorlenr rirr`)stringrcrrdr~rrr parseStringVs   r)NN)N)Zxml.saxr Zxml.sax.handlerrrrrrrrr riZContentHandlerr rZr`rrrrrrrrs"8\!