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<|S)Nr+r) rhrrrbreadrdrcclosera)rbufrqrrrrfs    zDOMEventStream.getEventcCs|j|j|j|_|S)z Fallback replacement for getEvent() using the standard SAX2 interface, which means we slurp the SAX events into memory (no performance gain, but we are compatible to all SAX parsers). )rcparserb_emitrfrTrrrreszDOMEventStream._slurpcCs,|jjdd}|jjdd|jjd<|S)zn Fallback replacement for getEvent() that emits the events that _slurp() read previously. r+r)rhrrtrrrrszDOMEventStream._emitcCs|j|`d|_d|_dS)z+clear(): Explicitly release parsing objectsN)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_stringrcrdrbrrrr~Ks   r~cCs6ddlm}t|}||}|s*tj}t|||S)Nr)StringIO)iorlenr rirr`)stringrcrrdr}rrr parseStringVs   r)NN)N)Zxml.saxr Zxml.sax.handlerrrrrrrrr riZContentHandlerr rZr`rrr~rrrrrs"8\!