Your IP : 18.191.72.220


Current Path : /opt/alt/python310/lib64/python3.10/xml/dom/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/xml/dom/__pycache__/pulldom.cpython-310.pyc

o

6��f�.�@s�ddlZddlZdZdZdZdZdZdZdZ	d	Z
Gd
d�dejj�Z
Gdd
�d
�ZGdd�d�ZGdd�de
�ZdZddd�Zddd�ZdS)�N�
START_ELEMENT�END_ELEMENT�COMMENT�START_DOCUMENT�END_DOCUMENT�PROCESSING_INSTRUCTION�IGNORABLE_WHITESPACE�
CHARACTERSc@s�eZdZdZdZd$dd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�ZdS)%�PullDOMNcCsxddlm}||_ddg|_|j|_g|_|jj|_z|jj|_Wn	t	y*Ynw|dig|_
|j
d|_g|_dS)Nr)�
XML_NAMESPACE�xml���)
Zxml.domr�documentFactory�
firstEvent�	lastEvent�elementStack�append�push�pop�AttributeError�_ns_contexts�_current_context�pending_events)�selfrr�r�6/opt/alt/python310/lib64/python3.10/xml/dom/pulldom.py�__init__s

�
zPullDOM.__init__cCs|jd}|jd=|S�Nr
)r)r�resultrrrr!s
zPullDOM.popcCs
||_dS�N)�_locator)rZlocatorrrr�setDocumentLocator&s
zPullDOM.setDocumentLocatorcCsHt|d�sg|_|j�|pd|f�|j�|j���|pd|j|<dS)N�_xmlns_attrs�xmlns)�hasattrr"rrr�copy)r�prefix�urirrr�startPrefixMapping)s

zPullDOM.startPrefixMappingcCs|j��|_dSr)rrr)rr&rrr�endPrefixMapping0szPullDOM.endPrefixMappingcCs�d}t|dd�}|dur|D]\}}||j||f<qg|_|\}}	|rI|dur7|j|}
|
r5|
d|	}n|	}|jrB|j�||�}n|�||�}n|jrS|j�|	�}n|�d|	�}|��D]Q\}}|\}}
||kr�|
dkrp|
}nd|
}|j�	||�}|�
|�n*|r�|j|}
|
r�|
d|
}n|
}|j�	||�}|�
|�n|j�|
�}|�|�||_
q]t|fdg|jd<|jd|_|�|�dS)Nzhttp://www.w3.org/2000/xmlns/r"�:r#zxmlns:�)�getattrZ_attrsr"r�documentZcreateElementNS�
buildDocument�
createElement�itemsZcreateAttributeNSZsetAttributeNodeNS�createAttribute�setAttributeNode�valuerrr)r�name�tagName�attrsZ	xmlns_uriZxmlns_attrs�anamer3r'Z	localnamer&�nodeZa_uriZa_localnameZqname�attrrrr�startElementNS3sP


zPullDOM.startElementNScC�&t|��fdg|jd<|jd|_dS�Nr+�rrr)rr4r5rrr�endElementNSl�zPullDOM.endElementNScCsz|jr
|j�|�}n|�d|�}|��D]\}}|j�|�}||_|�|�qt|fdg|jd<|jd|_|�	|�dSr<)
r-r/r.r0r1r3r2rrr)rr4r6r8r7r3r9rrr�startElementpszPullDOM.startElementcCr;r<r=)rr4rrr�
endElementr?zPullDOM.endElementcCsP|jr|j�|�}t|fdg|jd<|jd|_dSt|fdg}|j�|�dSr<)r-�
createCommentrrrr)r�sr8�eventrrr�comment�szPullDOM.commentcCsT|jr|j�||�}t|fdg|jd<|jd|_dSt||fdg}|j�|�dSr<)r-�createProcessingInstructionrrrr)r�target�datar8rDrrr�processingInstruction�szPullDOM.processingInstructioncC�.|j�|�}t|fdg|jd<|jd|_dSr<)r-�createTextNoderr�r�charsr8rrr�ignorableWhitespace��zPullDOM.ignorableWhitespacecCrJr<)r-rKr	rrLrrr�
characters�rOzPullDOM.characterscCs(|jdurddl}|jjjj|_dSdS)Nr)rZxml.dom.minidomZdomZminidomZDocument�implementation)rrrrr�
startDocument�s
�zPullDOM.startDocumentc	Cs�|j�||d�}||_t|fdg|jd<|jd|_|�|�|jD]I}|ddtkrA|d\}}}|j�||�}t|f|d<n"|ddt	krZ|j�
|dd�}t	|f|d<n	td|dd��||jd<||_q"d|_|jS)Nr+rzUnknown pending event )
rZcreateDocumentr-rrrrrrFrrB�AssertionErrorZ
firstChild)	rr'Ztagnamer8�e�_rGrH�nrrrr.�s$


zPullDOM.buildDocumentcCs t|jfdg|jd<|��dSr<)rr-rr�rrrr�endDocument�szPullDOM.endDocumentcCs
d|_dS)z.clear(): Explicitly release parsing structuresN)r-rWrrr�clear�s
z
PullDOM.clearr)�__name__�
__module__�__qualname__r r-rrr!r(r)r:r>r@rArErIrNrPrRr.rXrYrrrrr

s(
9		r
c@s$eZdZdd�Zdd�Zdd�ZdS)�ErrorHandlercCst|�dSr)�print�rZ	exceptionrrr�warning�szErrorHandler.warningcC�|�rrr_rrr�error��zErrorHandler.errorcCrarrr_rrr�
fatalError�rczErrorHandler.fatalErrorN)rZr[r\r`rbrdrrrrr]�sr]c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�DOMEventStreamcCs2||_||_||_t|jd�s|j|_|��dS)N�feed)�stream�parser�bufsizer$�_slurp�getEvent�reset)rrgrhrirrrr�szDOMEventStream.__init__cCs.t�|_|j�tjjjd�|j�|j�dSr<)	r
�pulldomrhZ
setFeaturer�saxZhandlerZfeature_namespacesZsetContentHandlerrWrrrrl�szDOMEventStream.resetcCs,ddl}|jdtdd�|��}|r|St�)Nrz[DOMEventStream's __getitem__ method ignores 'pos' parameter. Use iterator protocol instead.�)�
stacklevel)�warnings�warn�DeprecationWarningrk�
IndexError)r�posrq�rcrrr�__getitem__�s�zDOMEventStream.__getitem__cCs|��}|r|St�r)rk�
StopIteration�rrvrrr�__next__�szDOMEventStream.__next__cCs|SrrrWrrr�__iter__�rczDOMEventStream.__iter__cCsr|��}|g}|r7|\}}||urdS|tkr|d�|�|tkr(|�|�n|tkr/|d=|��}|s	dSdSr)rkr�appendChildrr)rr8rD�parents�tokenZcur_noderrr�
expandNode�s�zDOMEventStream.expandNodecCs�|jjds|jj|j_|jjds.|j�|j�}|s"|j��dS|j�|�|jjdr|jjdd}|jjdd|jjd<|S)Nr+r)	rmrrrg�readrirh�closerf)r�bufrvrrrrks
�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).
        )rh�parserg�_emitrkrWrrrrjszDOMEventStream._slurpcCs,|jjdd}|jjdd|jjd<|S)zn Fallback replacement for getEvent() that emits
            the events that _slurp() read previously.
        r+r)rmrryrrrr�szDOMEventStream._emitcCs|j��|`d|_d|_dS)z+clear(): Explicitly release parsing objectsN)rmrYrhrgrWrrrrY!s

zDOMEventStream.clearN)
rZr[r\rrlrwrzr{rrkrjr�rYrrrrre�s

rec@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�SAX2DOMcCs2t�||||�|jd}|jd}|�|�dS�Nr
���)r
r:rr|)rr4r5r6�curNode�
parentNoderrrr:*s

zSAX2DOM.startElementNScCs0t�|||�|jd}|jd}|�|�dSr�)r
r@rr|)rr4r6r�r�rrrr@0s

zSAX2DOM.startElementcCs4t�|||�|jdd}|jd}|�|�dS�Nrr+r
)r
rIrrr|)rrGrHr8r�rrrrI6s
zSAX2DOM.processingInstructioncC�2t�||�|jdd}|jd}|�|�dSr�)r
rNrrr|�rrMr8r�rrrrN<�
zSAX2DOM.ignorableWhitespacecCr�r�)r
rPrrr|r�rrrrPBr�zSAX2DOM.charactersN)rZr[r\r:r@rIrNrPrrrrr�(sr�i�?cCs@|durt}t|t�rt|d�}n|}|stj��}t|||�S)N�rb)�default_bufsize�
isinstance�str�openrrn�make_parserre)Zstream_or_stringrhrirgrrrr�Ks

r�cCs6ddlm}t|�}||�}|stj��}t|||�S)Nr)�StringIO)�ior��lenrrnr�re)�stringrhr�rir�rrr�parseStringVs
r�)NNr)Zxml.saxrZxml.sax.handlerrrrrrrrr	rnZContentHandlerr
r]rer�r�r�r�rrrr�<module>s$8\!


?>