Your IP : 13.58.191.60


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

o

6��f,
�@s�	ddlZddlZddlmZmZmZmZddlTddlm	Z	m
Z
ejjj
ejjjfZGdd�dejj�Zeeddd	�eed
dd	�eedd
d	�dd�Zdd�Zdd�Zdd�Zdd�ZGdd�de�ZGdd�de�Zeeddd	�eeddd	�eedd d	�Gd!d"�d"e�Zeed#d$d	�eZGd%d&�d&e�Zedd�ZGd'd(�d(e�Zeed)d*d	�eedd+d	�d,d-�ZGd.d/�d/�ZGd0d1�d1ee�Z Gd2d3�d3ee�Z!ee!d#d4d	�Gd5d6�d6e!�Z"ee"d7d8d	�ee"d9d:d	�d;d<�Z#d=d>�Z$Gd?d@�d@e!�Z%GdAdB�dBe"�Z&GdCdD�dDe�Z'ee'd#dEd	�GdFdG�dG�Z(GdHdI�dIe(ee�Z)GdJdK�dKe(e�Z*GdLdM�dMe(ee�Z+GdNdO�dOe	�Z,GdPdQ�dQe�Z-dRdS�Z.GdTdU�dUee
�Z/ee/dVdWd	�dXdY�Z0dZd[�Z1d\d]�Z2ddd^d_�Z3ded`da�Z4dedbdc�Z5dS)f�N)�EMPTY_NAMESPACE�EMPTY_PREFIX�XMLNS_NAMESPACE�domreg)�*)�DOMImplementationLS�
DocumentLSc@s�eZdZdZdZdZdZdZeZ	dd�Z
d2dd�Z		d3dd	�Zd
d�Z
dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Z dS)4�NodeNcC�dS)NT���selfrr�6/opt/alt/python310/lib64/python3.10/xml/dom/minidom.py�__bool__+�z
Node.__bool__cCs|�dd||�S�N�)�toprettyxml)r
�encoding�
standalonerrr�toxml.�z
Node.toxml�	�
cCsv|dur	t��}ntjt��|ddd�}|jtjkr%|�|d||||�n|�|d||�|dur5|��S|�	���S)N�xmlcharrefreplacer)r�errors�newliner)
�io�StringIO�
TextIOWrapper�BytesIO�nodeTyper	�
DOCUMENT_NODE�writexml�getvalue�detach)r
�indent�newlrr�writerrrrr1s

�zNode.toprettyxmlcC�
t|j�S�N)�bool�
childNodesrrrr�
hasChildNodesD�
zNode.hasChildNodescC�|jSr*�r,rrrr�_get_childNodesG�zNode._get_childNodescC�|jr|jdSdS�Nrr0rrrr�_get_firstChildJ�
�zNode._get_firstChildcCr3�N���r0rrrr�_get_lastChildNr6zNode._get_lastChildcCs|j|jkrt|j�D]}|�||�q|S|j|jvr*tj�dt	|�t	|�f��|j
dur5|j
�|�|dur@|�|�|Sz|j�
|�}WntyTtj���w|jtvr^t|�|j�||�||_||_|r{|j|d}||_||_nd|_||_
|S)N�%s cannot be child of %s�)r!�DOCUMENT_FRAGMENT_NODE�tupler,�insertBefore�_child_node_types�xml�dom�HierarchyRequestErr�repr�
parentNode�removeChild�appendChild�index�
ValueError�NotFoundErr�_nodeTypes_with_children�_clear_id_cache�insert�nextSibling�previousSibling)r
�newChild�refChild�crG�noderrrr>Rs<�

�
�
zNode.insertBeforecCs�|j|jkrt|j�D]}|�|�q|S|j|jvr)tj�dt	|�t	|�f��|jt
vr2t|�|jdur=|j�
|�t||�d|_|S�Nr:)r!r<r=r,rFr?r@rArBrCrJrKrDrE�
_append_childrM)r
rRrQrrrrFrs�


zNode.appendChildcCs
|j|jkr|j}|�|�|�||�S|j|jvr(tj�dt	|�t	|�f��||ur.dS|j
dur9|j
�|�z|j�|�}Wnt
yMtj���w||j|<||_
d|_
|jtvsc|jtvrgt|�|j|_|j|_d|_d|_|jr|||j_|jr�||j_|SrS)r!r<rMrEr>r?r@rArBrCrDr,rGrHrIrJrKrN)r
rO�oldChildrPrGrrr�replaceChild�s@
�

�


zNode.replaceChildcCszz|j�|�Wntytj���w|jdur|j|j_|jdur)|j|j_d|_|_|jt	vr8t
|�d|_|Sr*)r,�removerHr@rArIrMrNr!rJrKrD�r
rUrrrrE�s
�




zNode.removeChildcCs�g}|jD]Z}|jtjkrP|js%|r|j|d_|jr |j|j_|��q|rJ|dj|jkrJ|d}|j|j|_|j|_|jrE||j_|��q|�|�q|�|�|jtj	kr_|�
�q||jdd�<dSr7)r,r!r	�	TEXT_NODE�datarMrN�unlink�append�ELEMENT_NODE�	normalize)r
�L�childrRrrrr^�s,




�zNode.normalizecCst|||jp|�Sr*)�_clone_node�
ownerDocument)r
�deeprrr�	cloneNode��zNode.cloneNodecCs|jj�||�Sr*)rb�implementation�
hasFeature�r
�feature�versionrrr�isSupported�rzNode.isSupportedcC�dSr*rrrrr�_get_localName��zNode._get_localNamecCs||uSr*r�r
�otherrrr�
isSameNode��zNode.isSameNodecC�|�|d�r|SdSr*)rk�r
rirrr�getInterface��zNode.getInterfacec	Cs*z|j|dWSttfyYdSwr4)�
_user_data�AttributeError�KeyError�r
�keyrrr�getUserData�s
�zNode.getUserDatacCsnd}z|j}Wntyi}||_Ynw||vr ||d}|dur/d}|dur-||=|S||f||<|Sr4)rwrx)r
r{rZ�handler�old�drrr�setUserData�s 

��zNode.setUserDatacCsHt|d�r t|j���D]\}\}}|dur|�|||||�qdSdS)Nrw)�hasattr�listrw�itemsZhandle)r
�	operation�srcZdstr{rZr}rrr�_call_user_data_handler�s
��zNode._call_user_data_handlercCs>d|_|_|jr|jD]}|��qt�|_d|_d|_dSr*)rDrbr,r[�NodeListrNrM)r
r`rrrr[s


zNode.unlinkcCs|Sr*rrrrr�	__enter__rzNode.__enter__cCs|��dSr*)r[)r
ZetZev�tbrrr�__exit__�z
Node.__exit__�NN)rrNN)!�__name__�
__module__�__qualname__�namespaceURIrDrbrMrNr�prefixrrrr-r1r5r9r>rFrVrEr^rdrkrmrqrur|r�r�r[r�r�rrrrr	"s@

�  
r	�
firstChildzFirst child node, or None.)�doc�	lastChildzLast child node, or None.�	localNamez"Namespace-local name of this node.cCs2|j}|r|d}||_||_|�|�||_dSr7)r,rNrMr\rD)r
rRr,ZlastrrrrTs

rTcCs*|dur|jtjkrdS|j}|dusdS�NTF)r!r	r"rD�rRrrr�_in_document's�r�cCs<	|r|�dd��dd��dd��dd�}|�|�dSdS)	N�&z&amp;�<z&lt;�"z&quot;�>z&gt;)�replace�write)r(rZrrr�_write_data/s��r�cCsD|jD]}|jtjkr|dks|j|kr|�|�t|||�q|S�Nr)r,r!r	r]�tagNamer\�_get_elements_by_tagName_helper)�parent�name�rcrRrrrr�6s

r�cCsX|jD]&}|jtjkr)|dks|j|kr"|dks|j|kr"|�|�t||||�q|Sr�)r,r!r	r]r�r�r\�"_get_elements_by_tagName_ns_helper)r�ZnsURIr�r�rRrrrr�>s

�r�c@sJeZdZejZdZdZdZdZ	ej
ejejej
ejejejfZdd�ZdS)�DocumentFragmentz#document-fragmentNcCst�|_dSr*)r�r,rrrr�__init__Ur�zDocumentFragment.__init__)r�r�r�r	r<r!�nodeName�	nodeValue�
attributesrDr]rY�CDATA_SECTION_NODE�ENTITY_REFERENCE_NODE�PROCESSING_INSTRUCTION_NODE�COMMENT_NODE�
NOTATION_NODEr?r�rrrrr�Gs�r�c@s�eZdZdZejZdZdZdZ	ej
ejfZe
ddfdd�Zdd�Zdd	�Zd
d�Zdd
�Zeee�ZZdd�Zdd�Zeee�ZZdd�Zdd�Zeee�Zdd�Zdd�Zdd�ZdS)�Attr)�_name�_valuer��_prefixr,�
_localNamerb�ownerElementNFcCs@d|_||_||_||_|dur||_t�|_|j�t��dSr*)	r�r�r�r�r�r�r,r\�Text)r
�qNamer�r�r�rrrr�csz
Attr.__init__cC�.z|jWSty|j�dd�dYSw�N�:r;r8)r�rxr��splitrrrrrmr�
�zAttr._get_localNamecCr/r*)�	specifiedrrrr�_get_specifiedxr2zAttr._get_specifiedcCr/r*)r�rrrr�	_get_name{r2zAttr._get_namecCs"||_|jdurt|j�dSdSr*)r�r�rK�r
�valuerrr�	_set_name~s
�zAttr._set_namecCr/r*)r�rrrr�
_get_value�r2zAttr._get_valuecCs6||_||jd_|jdurt|j�||jd_dSr4)r�r,rZr�rKr�rrr�
_set_value�s


zAttr._set_valuecCr/r*)r�rrrr�_get_prefix�r2zAttr._get_prefixcCsd|j}|dkr|r|tkrtj�d��||_|dur|j}nd||jf}|jr-t|j�||_	dS)N�xmlnsz5illegal use of 'xmlns' prefix for the wrong namespacez%s:%s)
r�rr@rA�NamespaceErrr�r�r�rKr�)r
r�ZnsuriZnewNamerrr�_set_prefix�s�

zAttr._set_prefixcCsv|j}|dur)|j|j=|j|j|jf=|jr)d|_|jd8_|jj	d8_	|j
D]}|��q,|j
dd�=dS)NFr;)r��_attrsr��_attrsNSr�r��_is_id�_magic_id_nodesrb�_magic_id_countr,r[)r
�elemr`rrrr[�s


zAttr.unlinkcCsb|jrdS|j}|j}|dus|durdS|�|�}|dur dS|jr+|�|j|j�S|�|j�Sr�)	r�rbr��_get_elem_infor��isIdNSr��isIdr��r
r�r��inforrr�	_get_isId�s
zAttr._get_isIdcCsX|j}|j}|dus|durtS|�|�}|durtS|jr&|�|j|j�S|�|j�Sr*)	rbr��_no_typer�r��getAttributeTypeNSr��getAttributeTyper�r�rrr�_get_schemaType�s
zAttr._get_schemaType) r�r�r��	__slots__r	�ATTRIBUTE_NODEr!r�r�r�rYr�r?rr�rmr�r�r��propertyr�r�r�r�r�r�r�r�r�r[r�r�rrrrr�Ys0
�
r�r�z True if this attribute is an ID.z'Namespace-local name of this attribute.�
schemaTypezSchema type for this attribute.c@s�eZdZ	dZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zd9dd�Z
eZdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�ZdS):�NamedNodeMap�r�r��
_ownerElementcCs||_||_||_dSr*r�)r
�attrsZattrsNSr�rrrr��s
zNamedNodeMap.__init__cCr)r*)�lenr�rrrr�_get_length�r.zNamedNodeMap._get_lengthcCs.z|t|j���|WStyYdSwr*)r�r��keys�
IndexError�r
rGrrr�item�s
�zNamedNodeMap.itemcCs*g}|j��D]}|�|j|jf�q|Sr*)r��valuesr\r�r��r
r_rRrrrr��szNamedNodeMap.itemscCs0g}|j��D]}|�|j|jf|jf�q|Sr*)r�r�r\r�r�r�r�rrr�itemsNS�szNamedNodeMap.itemsNScCst|t�r
||jvS||jvSr*)�
isinstance�strr�r�rzrrr�__contains__��


zNamedNodeMap.__contains__cC�
|j��Sr*)r�r�rrrrr�r.zNamedNodeMap.keyscCr�r*)r�r�rrrr�keysNSr.zNamedNodeMap.keysNScCr�r*)r�r�rrrrr�
r.zNamedNodeMap.valuesNcC�|j�||�Sr*�r��get)r
r�r�rrrr�
�zNamedNodeMap.getcCs6|jt|dd�urdSt|�t|�kt|�t|�kS)Nr�r)r��getattr�idrorrr�_cmps zNamedNodeMap._cmpcCs|�|�dkSr4�r�rorrr�__eq__r�zNamedNodeMap.__eq__cCs|�|�dkSr4r�rorrr�__ge__r�zNamedNodeMap.__ge__cCs|�|�dkSr4r�rorrr�__gt__r�zNamedNodeMap.__gt__cCs|�|�dkSr4r�rorrr�__le__!r�zNamedNodeMap.__le__cCs|�|�dkSr4r�rorrr�__lt__$r�zNamedNodeMap.__lt__cCst|t�r
|j|S|j|Sr*)r�r=r�r�)r
�attname_or_tuplerrr�__getitem__'r�zNamedNodeMap.__getitem__cCsvt|t�r)z|j|}Wnty#t|�}|jj|_|�|�Ynw||_dSt|t�s2t	d��|}|�|�dS)Nz%value must be a string or Attr object)
r�r�r�ryr�r�rb�setNamedItemr��	TypeError)r
�attnamer�rRrrr�__setitem__.s

�

zNamedNodeMap.__setitem__cCs"z|j|WStyYdSwr*)r�ry�r
r�rrr�getNamedItem=s
�zNamedNodeMap.getNamedItemcCs&z|j||fWStyYdSwr*)r�ry�r
r�r�rrr�getNamedItemNSCs
�zNamedNodeMap.getNamedItemNScCsT|�|�}|dur%t|j�|j|j=|j|j|jf=t|d�r#d|_	|St
j����Nr�)
rrKr�r�r�r�r�r�r�r�r@rArI�r
r��nrrr�removeNamedItemIs




zNamedNodeMap.removeNamedItemcCsV|�||�}|dur&t|j�|j|j|jf=|j|j=t|d�r$d|_	|St
j���r)
rrKr�r�r�r�r�r�r�r�r@rArI�r
r�r�r
rrr�removeNamedItemNSUs



zNamedNodeMap.removeNamedItemNScCstt|t�stj�dt|�t|�f��|j�|j�}|r |�	�||j|j<||j
|j|jf<|j
|_t|j�|SrS)r�r�r@rArBrCr�r�r�r[r�r�r�r�r�rK)r
rRr~rrrras
�
zNamedNodeMap.setNamedItemcCs
|�|�Sr*)r�r
rRrrr�setNamedItemNSnr.zNamedNodeMap.setNamedItemNScCs||}t|j�|��dSr*)rKr�r[)r
r�rRrrr�__delitem__qs
zNamedNodeMap.__delitem__cCs|j|j|jfSr*r�rrrr�__getstate__vrzNamedNodeMap.__getstate__cCs|\|_|_|_dSr*r��r
�staterrr�__setstate__yszNamedNodeMap.__setstate__r*) r�r�r�r�r�r�r�r�r�r�r�r�r�r��__len__r�r�r�r�r�r�r�rrrrr
rrrrrrrrrr��s>

r�Zlengthz$Number of nodes in the NamedNodeMap.c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�TypeInfo��	namespacer�cC�||_||_dSr*r)r
rr�rrrr���
zTypeInfo.__init__cCs.|jrd|jj|j|jfSd|jj|jfS)Nz<%s %r (from %r)>z<%s %r>)r�	__class__r�r�rrrr�__repr__�s
�zTypeInfo.__repr__cCr/r*)r�rrrrr��r2zTypeInfo._get_namecCr/r*)rrrrr�_get_namespace�r2zTypeInfo._get_namespaceN)r�r�r�r�r�rr�rrrrrr�src@s eZdZdZejZdZeZ	dZ
ejejejej
ejejfZeddfdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZeZdd�Zdd�Z d d!�Z!e!Z"d"d#�Z#d$d%�Z$d&d'�Z%d(d)�Z&d*d+�Z'd9d-d.�Z(d/d0�Z)d1d2�Z*d3d4�Z+d5d6�Z,d7d8�Z-dS):�Element)rbrDr�r�r�r�r�r,r�r�rMrNNrcCsBd|_||_|_||_||_t�|_d|_|_d|_	d|_
dSr*)rDr�r�r�r�r�r,rMrNr�r�)r
r�r�r�r�rrrr��s

zElement.__init__cCs|jdur
i|_i|_dSdSr*)r�r�rrrr�_ensure_attributes�s

�zElement._ensure_attributescCr�r�)r�rxr�r�rrrrrm�r�zElement._get_localNamecCr/r*�r�rrrr�_get_tagName�r2zElement._get_tagNamecCs@|jdurt|j���D]}|��qd|_d|_t�|�dSr*)r�r�r�r[r�r	)r
�attrrrrr[�s

zElement.unlinkcCs4	|jdurdSz|j|jWStyYdSwr)r�r�ry)r
rrrr�getAttribute�s
�zElement.getAttributecCs6|jdurdSz	|j||fjWStyYdSwr)r�r�ryrrrr�getAttributeNS�s
�zElement.getAttributeNScCs`|�|�}|durt|�}||_|j|_|�|�dS||jkr,||_|jr.t|�dSdSdSr*)�getAttributeNoder�r�rb�setAttributeNoder�rK)r
rr�r"rrr�setAttribute�s

�zElement.setAttributecCs�t|�\}}|�||�}|dur%t||||�}||_|j|_|�|�dS||jkr4||_|jr4t|�|j|krA||_||_	dSdSr*)
�_nssplit�getAttributeNodeNSr�r�rbr&r�rKr�r�)r
r��
qualifiedNamer�r��	localnamer"rrr�setAttributeNS�s


�zElement.setAttributeNScCs|jdurdS|j�|�Sr*r�)r
�attrnamerrrr%s
zElement.getAttributeNodecCs|jdurdS|j�||f�Sr*)r�r�rrrrr)
s
zElement.getAttributeNodeNScCs�|jd|fvr
tj�d��|��|j�|jd�}|dur"|�|�|j	�|j
|jfd�}|dur:||ur:|�|�t||�||urE|S||urK|SdS)Nzattribute node already owned)
r�r@rAZInuseAttributeErrrr�r�r��removeAttributeNoder�r�r��_set_attribute_node)r
r"Zold1Zold2rrrr&s


�zElement.setAttributeNodecCsJ|jdur
tj���z|j|}Wntytj���w|�|�dSr*)r�r@rArIr�ryr.)r
r�r"rrr�removeAttribute's


�zElement.removeAttributecCsN|jdur
tj���z	|j||f}Wntytj���w|�|�dSr*)r�r@rArIryr.)r
r�r�r"rrr�removeAttributeNS0s


�zElement.removeAttributeNScCsX|dur	tj���z|j|jWntytj���wt|�|��|j|_|Sr*)	r@rArIr�r�ryrKr[rbrrrrr.9s

�zElement.removeAttributeNodecCs	|jdurdS||jvS�NF�r�rrrr�hasAttributeIs

zElement.hasAttributecCs|jdurdS||f|jvSr2)r�rrrr�hasAttributeNSSs
zElement.hasAttributeNScCs	t||t��Sr*�r�r�rrrr�getElementsByTagNameXszElement.getElementsByTagNamecC�t|||t��Sr*�r�r�rrrr�getElementsByTagNameNS`�
�zElement.getElementsByTagNameNScCsd|jt|�fS)Nz<DOM Element: %s at %#x>)r�r�rrrrrdrezElement.__repr__rcCs	|�|d|j�|��}|��D]}|�d|�t|||j�|�d�q|jrw|�d�t|j�dkrQ|jdjt	j
t	jfvrQ|jd�|ddd�n|�|�|jD]}|�|||||�qY|�|�|�d|j|f�dS|�d	|�dS)
Nr�z %s="r�r�r;rrz</%s>%sz/>%s)
r�r��_get_attributesr�r�r�r,r�r!r	rYr�r#)r
r(r&�	addindentr'r�Za_namerRrrrr#gs(

�


zElement.writexmlcCs|��t|j|j|�Sr*)rr�r�r�rrrrr<�szElement._get_attributescCs|jrdSdSr�r3rrrr�
hasAttributes�szElement.hasAttributescCs|�|�}|�|�dSr*)r%�setIdAttributeNode)r
r��idAttrrrr�setIdAttribute�s
zElement.setIdAttributecCs|�||�}|�|�dSr*)r)r?)r
r�r�r@rrr�setIdAttributeNS�szElement.setIdAttributeNScCsn|dus
|�|j�stj���t|�durtj���|js5d|_|jd7_|j	j
d7_
t|�dSdS)NTr;)rqr�r@rArI�_get_containing_entref�NoModificationAllowedErrr�r�rbr�rK)r
r@rrrr?�s

�zElement.setIdAttributeNode�rrr).r�r�r�r�r	r]r!r�r�r�r�r�r�rYr�r�r?rr�rrmr!r[r#r$r'r,r%r)r&ZsetAttributeNodeNSr0r1r.ZremoveAttributeNodeNSr4r5r7r:rr#r<r>rArBr?rrrrr�sV�
�		

 rr�z*NamedNodeMap of attributes on the element.z%Namespace-local name of this element.cCs8t|�|��||j|j<||j|j|jf<||_dSr*)rKrr�r�r�r�r�r�)�elementr"rrrr/�s

r/c@sdeZdZ	dZdZe�ZdZdZdd�Z	dd�Z
dd�Zd	d
�Zdd�Z
d
d�Zdd�Zdd�ZdS)�	ChildlessrNcCrlr*rrrrrr5�rzChildless._get_firstChildcCrlr*rrrrrr9�rzChildless._get_lastChildcC�tj�|jd��)Nz nodes cannot have children�r@rArBr�rrrrrF���zChildless.appendChildcCr
r2rrrrrr-�rzChildless.hasChildNodescCrH�Nz nodes do not have childrenrI�r
rOrPrrrr>�rJzChildless.insertBeforecCrHrK)r@rArIr�rXrrrrE�rJzChildless.removeChildcCrlr*rrrrrr^�rnzChildless.normalizecCrHrKrI�r
rOrUrrrrV�rJzChildless.replaceChild)r�r�r�r�r�Z
EmptyNodeListr,r�r�r5r9rFr-r>rEr^rVrrrrrG�srGc@s\eZdZejZdZdd�Zdd�Zdd�Z	e
ee	�Zdd	�Zd
d�Z
e
ee
�Zdd
d�ZdS)�ProcessingInstruction��targetrZcCrr*rO)r
rPrZrrrr��rzProcessingInstruction.__init__cCr/r*�rZrrrr�_get_nodeValue�r2z$ProcessingInstruction._get_nodeValuecC�
||_dSr*rQr�rrr�_set_nodeValue�r.z$ProcessingInstruction._set_nodeValuecCr/r*�rPrrrr�
_get_nodeName�r2z#ProcessingInstruction._get_nodeNamecCrSr*rUr�rrr�
_set_nodeName�r.z#ProcessingInstruction._set_nodeNamercCs|�d||j|j|f�dS)Nz
%s<?%s %s?>%s)r�rPrZ�r
r(r&r=r'rrrr#�szProcessingInstruction.writexmlNrE)r�r�r�r	r�r!r�r�rRrTr�r�rVrWr�r#rrrrrN�s

rNc@sreZdZdZdd�Zdd�ZeZdd�Zdd	�Ze	ee�Z
Zd
d�Zdd
�Z
dd�Zdd�Zdd�Zdd�ZdS)�
CharacterData)�_datarbrDrNrMcCs,d|_|_d|_|_d|_t�|�dSr)rbrDrNrMrZr	r�rrrrr��szCharacterData.__init__cCr)r*)r�rZrrrrr�r.zCharacterData._get_lengthcCr/r*�rZrrrr�	_get_datar2zCharacterData._get_datacCrSr*r[�r
rZrrr�	_set_data	r.zCharacterData._set_datacCs6|j}t|�dkrd}nd}d|jj|dd�|fS)N�
z...rz<DOM %s node "%r%s">r)rZr�rr�)r
rZZ	dotdotdotrrrrs�zCharacterData.__repr__cCsT|dkr
tj�d��|t|j�krtj�d��|dkr!tj�d��|j|||�S�Nr�offset cannot be negative�#offset cannot be beyond end of data�count cannot be negative�r@rA�IndexSizeErrr�rZ�r
�offset�countrrr�
substringDataszCharacterData.substringDatacCs|j||_dSr*rQ)r
�argrrr�
appendData rzCharacterData.appendDatacCs^|dkr
tj�d��|t|j�krtj�d��|r-d|jd|�||j|d�f|_dSdS)Nrrarb�%s%s%srd)r
rgrjrrr�
insertData#s��zCharacterData.insertDatacCsp|dkr
tj�d��|t|j�krtj�d��|dkr!tj�d��|r6|jd|�|j||d�|_dSdSr`rdrfrrr�
deleteData,s&�zCharacterData.deleteDatacCsv|dkr
tj�d��|t|j�krtj�d��|dkr!tj�d��|r9d|jd|�||j||d�f|_dSdS)Nrrarbrcrlrd)r
rgrhrjrrr�replaceData6s��zCharacterData.replaceDataN)r�r�r�r�r�r�rr\r^r�rZr�rrirkrmrnrorrrrrY�s			
rYzLength of the string data.c@sHeZdZdZejZdZdZdd�Z	ddd�Z
d	d
�Zdd�Zd
d�Z
dS)r�rz#textNcCs�|dks|t|j�krtj�d��|��}|j|d�|_|j|_|j}|jr?||jj	vr?|dur8|j�
|�n|j�||�|jd|�|_|S)Nrzillegal offset value)r�rZr@rArerrbrMrDr,rFr>)r
rgZnewText�nextrrr�	splitTextKszText.splitTextrcCst|d||j|f�dS)Nrl)r�rZrXrrrr#Zsz
Text.writexmlcCs�|jg}|j}|dur$|jtjtjfvr|�d|j�|j}nn|dus|j}|durC|jtjtjfvr>|�|j�|j}nn|dus+d�	|�S)Nrr)
rZrNr!r	rYr�rLrMr\�join)r
r_r
rrr�_get_wholeText_s ��
zText._get_wholeTextcCs�|j}|j}|dur#|jtjtjfvr|j}|�|�|}nn|dus
|j}|s-|�|�|durJ|jtjtjfvrE|j}|�|�|}nn|dus1|rQ||_|SdSr*)	rDrNr!r	rYr�rErMrZ)r
Zcontentr�r
rprrr�replaceWholeTextqs.
�

�zText.replaceWholeTextcCsB|j��rdSt|�}|durdS|j�|�}|durdS|��Sr2)rZ�strip�_get_containing_elementrbr��isElementContent)r
r�r�rrr�!_get_isWhitespaceInElementContent�s
z&Text._get_isWhitespaceInElementContentrE)r�r�r�r�r	rYr!r�r�rqr#rsrtrxrrrrr�Ds
r�ZisWhitespaceInElementContentzKTrue iff this text node contains only whitespace and is in element content.Z	wholeTextz.The text of all logically-adjacent text nodes.cC�0|j}|dur|jtjkr|S|j}|dusdSr*)rDr!r	r]�rRrQrrrrv���rvcCryr*)rDr!r	r�rzrrrrC�r{rCc@s(eZdZejZdZdd�Zddd�ZdS)	�Commentz#commentcCst�|�||_dSr*)rYr�rZr]rrrr��s

zComment.__init__rcCs,d|jvr	td��|�d||j|f�dS)Nz--z%'--' is not allowed in a comment nodez
%s<!--%s-->%s)rZrHr�rXrrrr#�s
zComment.writexmlNrE)	r�r�r�r	r�r!r�r�r#rrrrr|�s
r|c@s$eZdZdZejZdZddd�ZdS)�CDATASectionrz#cdata-sectionrcCs,|j�d�dkrtd��|�d|j�dS)Nz]]>rz$']]>' not allowed in a CDATA sectionz<![CDATA[%s]]>)rZ�findrHr�rXrrrr#�szCDATASection.writexmlNrE)	r�r�r�r�r	r�r!r�r#rrrrr}�s
r}c@szeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�ReadOnlySequentialNamedNodeMap��_seqrcCrSr*r�)r
�seqrrrr��s
z'ReadOnlySequentialNamedNodeMap.__init__cCr)r*�r�r�rrrrr�r.z&ReadOnlySequentialNamedNodeMap.__len__cCr)r*r�rrrrr��r.z*ReadOnlySequentialNamedNodeMap._get_lengthcCs"|jD]}|j|kr|SqdSr*)r�r�r	rrrr�s


��z+ReadOnlySequentialNamedNodeMap.getNamedItemcCs,|jD]}|j|kr|j|kr|SqdSr*)r�r�r�rrrrr�s

��z-ReadOnlySequentialNamedNodeMap.getNamedItemNScCs4t|t�r|j|�}n|�|�}|durt|��|Sr*)r�r=rrry)r
Z
name_or_tuplerRrrrr��s

z*ReadOnlySequentialNamedNodeMap.__getitem__cCs.|dkrdSz|j|WStyYdSwr4)r�r�r�rrrr��s�z#ReadOnlySequentialNamedNodeMap.itemcC�tj�d���Nz"NamedNodeMap instance is read-only�r@rArDrrrrr���z.ReadOnlySequentialNamedNodeMap.removeNamedItemcCr�r�r�rrrrr
�r�z0ReadOnlySequentialNamedNodeMap.removeNamedItemNScCr�r�r�rrrrr�r�z+ReadOnlySequentialNamedNodeMap.setNamedItemcCr�r�r�rrrrr�r�z-ReadOnlySequentialNamedNodeMap.setNamedItemNScCs|jgSr*r�rrrrrrrz+ReadOnlySequentialNamedNodeMap.__getstate__cCs|d|_dSr4r�rrrrrr�z+ReadOnlySequentialNamedNodeMap.__setstate__N)r)r�r�r�r�r�rr�rrr�r�rr
rrrrrrrrr�s
	rz&Number of entries in the NamedNodeMap.c@s*eZdZ	dZdd�Zdd�Zdd�ZdS)	�
Identified��publicId�systemIdcCrr*r�)r
r�r�rrr�_identified_mixin_initrz!Identified._identified_mixin_initcCr/r*)r�rrrr�
_get_publicIdr2zIdentified._get_publicIdcCr/r*)r�rrrr�
_get_systemIdr2zIdentified._get_systemIdN)r�r�r�r�r�r�r�rrrrr�
sr�c@sHeZdZejZdZdZdZdZ	dZ
dd�Zdd�Zdd�Z
dd	d
�ZdS)�DocumentTypeNcCs2t�|_t�|_|rt|�\}}||_|j|_dSr*)r�entities�	notationsr(r�r�)r
r*r�r+rrrr�$szDocumentType.__init__cCr/r*)�internalSubsetrrrr�_get_internalSubset,r2z DocumentType._get_internalSubsetcCs�|jdurstd�}|j|_|j|_tjjj}|rjg|j_	g|j
_	|j
j	D]}t|j|j|j
�}|j
j	�|�|�|||�q$|jj	D]'}t|j|j|j
|j�}|j|_|j|_|j|_|jj	�|�|�|||�qB|�|||�|SdSr*)rbr�r�r�r@rA�UserDataHandler�NODE_CLONEDr�r�r��Notationr�r�r\r��Entity�notationName�actualEncodingrrj)r
rc�cloner�r
�notation�e�entityrrrrd/s0

�zDocumentType.cloneNodercCs�|�d�|�|j�|jr|�d||j||jf�n
|jr)|�d||jf�|jdur>|�d�|�|j�|�d�|�d|�dS)Nz
<!DOCTYPE z%s  PUBLIC '%s'%s  '%s'z%s  SYSTEM '%s'z [�]r�)r�r�r�r�r�rXrrrr#Js
�


zDocumentType.writexmlrE)r�r�r�r	�DOCUMENT_TYPE_NODEr!r�r�r�r�r�r�r�rdr#rrrrr�sr�c@sfeZdZdZejZdZdZdZ	dZ
dd�Zdd�Zdd�Z
dd	�Zd
d�Zdd
�Zdd�Zdd�ZdS)r�NcCs$||_||_t�|_|�||�dSr*)r�r�r�r,r�)r
r�r�r�r�rrrr�aszEntity.__init__cCr/r*�r�rrrr�_get_actualEncodinggr2zEntity._get_actualEncodingcCr/r*�rrrrr�
_get_encodingjr2zEntity._get_encodingcCr/r*�rjrrrr�_get_versionmr2zEntity._get_versioncCr�)Nz(cannot append children to an entity node�r@rArB)r
rOrrrrFpr�zEntity.appendChildcCr�)Nz+cannot insert children below an entity noder�rLrrrr>tr�zEntity.insertBeforecCr�)Nz*cannot remove children from an entity noder�rXrrrrExr�zEntity.removeChildcCr�)Nz)cannot replace children of an entity noder�rMrrrrV|r�zEntity.replaceChild)r�r�r�r�r	ZENTITY_NODEr!r�r�rrjr�r�r�r�rFr>rErVrrrrr�Xsr�c@seZdZejZdZdd�ZdS)r�NcCs||_|�||�dSr*)r�r�)r
r�r�r�rrrr��szNotation.__init__)r�r�r�r	r�r!r�r�rrrrr��sr�c@s<eZdZgd�Zdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�DOMImplementation))�core�1.0)r��2.0)r�N)r@r�)r@r�)r@N)�ls-loadz3.0)r�NcCs|dkrd}|��|f|jvSr)�lower�	_featuresrhrrrrg�szDOMImplementation.hasFeaturec	Cs�|r
|jdur
tj�d��|��}|duo|duo|du}|s(|r(tj�d��|rZt|�\}}|dkr>|dkr>tj�d��|rH|sHtj�d��|�||�}|rU|�	|�|�	|�|rb||_|_
||_||_|S)Nz(doctype object owned by another DOM treezElement with no namer@z$http://www.w3.org/XML/1998/namespacezillegal use of 'xml' prefixz(illegal use of prefix without namespaces)
rDr@rA�WrongDocumentErr�_create_documentZInvalidCharacterErrr(r��createElementNSrFrb�doctyperf)	r
r�r*r�r�Zadd_root_elementr�r+rFrrr�createDocument�s<���
�

z DOMImplementation.createDocumentcCst|�}||_||_|Sr*)r�r�r�)r
r*r�r�r�rrr�createDocumentType��z$DOMImplementation.createDocumentTypecCrsr*)rgrtrrrru�rvzDOMImplementation.getInterfacecCst�Sr*)�Documentrrrrr��r2z"DOMImplementation._create_documentN)	r�r�r�r�rgr�r�rur�rrrrr��s
-r�c@sZeZdZ	dZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�ElementInfor cCrSr*r rrrrr��r.zElementInfo.__init__cC�tSr*�r��r
Zanamerrrr��rzElementInfo.getAttributeTypecCr�r*r�rrrrr��rzElementInfo.getAttributeTypeNScCr
r2rrrrrrw�rzElementInfo.isElementContentcC�	dSr2rrrrr�isEmpty�szElementInfo.isEmptycCr�r2rr�rrrr���zElementInfo.isIdcCr�r2rrrrrr��r�zElementInfo.isIdNScCr/r*r rrrrr�r2zElementInfo.__getstate__cCrSr*r rrrrr�r.zElementInfo.__setstate__N)
r�r�r�r�r�r�r�rwr�r�r�rrrrrrr��sr�cCsD|jtjkr|j��d|_dSt|�r |jj��d|j_dSdSr*)r!r	r"�	_id_cache�clear�_id_search_stackr�rbr�rrrrKs

�rKc@sveZdZdZejejejejfZ	e
�ZejZ
dZdZdZdZdZZdZdZdZdZdZdZdZdZdd�Zdd	�Zd
d�Zdd
�Zdd�Z dd�Z!dd�Z"dd�Z#dd�Z$dd�Z%dd�Z&dd�Z'dd�Z(d d!�Z)d"d#�Z*d$d%�Z+d&d'�Z,d(d)�Z-d*d+�Z.d,d-�Z/d.d/�Z0d0d1�Z1d2d3�Z2d4d5�Z3d6d7�Z4d8d9�Z5d:d;�Z6d<d=�Z7d>d?�Z8d@dA�Z9dBdC�Z:		dIdEdF�Z;dGdH�Z<dS)Jr�)�
_elem_infor�r�r,r�z	#documentNFrcCs$d|_t�|_i|_i|_d|_dSr*)r�r�r,r�r�r�rrrrr�%s

zDocument.__init__cCs&|jr
|j|jf}n|j}|j�|�Sr*)r�r�r�r�r�)r
rFr{rrrr�.szDocument._get_elem_infocCr/r*r�rrrrr�5r2zDocument._get_actualEncodingcCr/r*)r�rrrr�_get_doctype8r2zDocument._get_doctypecCr/r*)�documentURIrrrr�_get_documentURI;r2zDocument._get_documentURIcCr/r*r�rrrrr�>r2zDocument._get_encodingcCr/r*)�errorHandlerrrrr�_get_errorHandlerAr2zDocument._get_errorHandlercCr/r*)rrrrr�_get_standaloneDr2zDocument._get_standalonecCr/r*)�strictErrorCheckingrrrr�_get_strictErrorCheckingGr2z!Document._get_strictErrorCheckingcCr/r*r�rrrrr�Jr2zDocument._get_versioncCsj|j|jvrtj�dt|�t|�f��|jdur|j�|�|jtj	kr/|�
�r/tj�d��t�||�S)Nr:z two document elements disallowed)r!r?r@rArBrCrDrEr	r]�_get_documentElementrFrrrrrFMs�
��zDocument.appendChildcCsPz|j�|�Wntytj���wd|_|_d|_|j	|ur&d|_	|Sr*)
r,rWrHr@rArIrMrNrD�documentElementrXrrrrE]s
�
zDocument.removeChildcCs$|jD]}|jtjkr|SqdSr*)r,r!r	r]rrrrr�is

��zDocument._get_documentElementcCs(|jdur
|j��d|_t�|�dSr*)r�r[r	rrrrr[ns

zDocument.unlinkcCs�|sdS|j�ddd�}|j|_|j|_|j|_|jD]!}t|||�}|j�|�|jt	j
kr0n	|jt	jkr9||_||_
q|�tjjj||�|Sr*)rfr�rrrjr,rar\r!r	r"r�r�rDr�r@rAr�r�)r
rcr�r
Z
childclonerrrrdts"
�zDocument.cloneNodecCst�}||_|Sr*)r�rb)r
rrrr�createDocumentFragment�szDocument.createDocumentFragmentcC�t|�}||_|Sr*)rrb)r
r�r�rrr�
createElement��zDocument.createElementcC�(t|t�s	td��t�}||_||_|S�Nznode contents must be a string)r�r�rr�rZrb)r
rZ�trrr�createTextNode��
zDocument.createTextNodecCr�r�)r�r�rr}rZrb�r
rZrQrrr�createCDATASection�r�zDocument.createCDATASectioncCr�r*)r|rbr�rrr�
createComment�r�zDocument.createCommentcCst||�}||_|Sr*)rNrb)r
rPrZ�prrr�createProcessingInstruction�s
z$Document.createProcessingInstructioncCst|�}||_d|_|Sr)r�rbr�)r
r��arrr�createAttribute�r�zDocument.createAttributecCs"t|�\}}t|||�}||_|Sr*)r(rrb)r
r�r*r�r�r�rrrr��szDocument.createElementNScCs*t|�\}}t||||�}||_d|_|Sr)r(r�rbr�)r
r�r*r�r�r�rrr�createAttributeNS�s
zDocument.createAttributeNScCst||||�}||_|Sr*)r�rb)r
r�r�r�r�r�rrr�_create_entity�szDocument._create_entitycCst|||�}||_|Sr*)r�rb)r
r�r�r�r
rrr�_create_notation�szDocument._create_notationcCs~||jvr
|j|S|js|jsdS|j}|dur!|jg}||_n|s%dSd}|r�|��}|�dd�|jD��|�|�}|r�|j	�
�D]S}|jre|�|j|j
�rd||j|j<|j|kr_|}qD|jsdn4qD|�|j�r||j|j<|j|kry|}qD|js~nqD|jr�||j|j<|j|kr�|}qD|jdkr�nqDn|jr�|j	�
�D]}|jr�||j|j<|j|kr�|}q�|dur�	|S|s)|S)NcSsg|]	}|jtvr|�qSr)r!rJ)�.0r`rrr�
<listcomp>�s
�z+Document.getElementById.<locals>.<listcomp>r;)r�r�r�r�r��pop�extendr,r�r�r�r�r�r�r�r�r�r�r�)r
r��stack�resultrRr�r"rrr�getElementById�sf



�
�

�
��'zDocument.getElementByIdcCst||t��Sr*r6rrrrr7r�zDocument.getElementsByTagNamecCr8r*r9rrrrr:
r;zDocument.getElementsByTagNameNScCr�r*)rfrgrhrrrrkr�zDocument.isSupportedcCs<|jtjkrtj�d��|jtjkrtj�d��t|||�S)Nzcannot import document nodesz!cannot import document type nodes)r!r	r"r@rA�NotSupportedErrr�ra)r
rRrcrrr�
importNodes
zDocument.importNoderc	Csxg}|r
|�d|�d��|dur|�d|rdnd�d��|�dd�|��d|���|jD]
}|�||||�q/dS)	Nz
encoding="r�zstandalone="ZyesZnoz<?xml version="1.0" � z?>)r\r�rrr,r#)	r
r(r&r=r'rrZdeclarationsrRrrrr#s
�zDocument.writexmlcCsF|j|urtj�d||jf��|jtjtjfvrtj�d��|t	kr[d|vr@|�
dd�\}}|dkr?|tjjkr?tj�d��n|dkrV|tjjkrV|jtjkrVtj�d��d}|}nd}d}|jtjkru|j
}|durt|j}|�|�nd}||_||_||_||_|jtjkr�||_|S||_|dur�|�|�|r�|�|�|S)Nz?cannot rename nodes from other documents;
expected %s,
found %sz8renameNode() only applies to element and attribute nodesr�r;r�zillegal use of 'xmlns' prefixz$illegal use of the 'xmlns' attribute)rbr@rAr�r!r	r]r�r�rr�rr�r�r�r.r�r�r�r�r�r�r&r?)r
r
r�r�r�r�rFZis_idrrr�
renameNode(sb
������
�
�

zDocument.renameNode)rrrNN)=r�r�r�r�r	r]r�r�r�r?r�rfr"r!r�r�r�rDrNrMr�rrrjr�r�r�r�r�r�r�r�r�r�r�r�r�r�rFrEr�r[rdr�r�r�r�r�r�r�r�r�r�r�r�r7r:rkr�r#r�rrrrr�
sn�	
:
�r�r�z#Top-level element of this document.c
Cs�	|j�|�r
tjjj}ntjjj}|jtj	krR|�
|j|j�}|j
��D]}|�|j|j|j�|�|j|j�}|j|_q%|rQ|jD]
}t|||�}|�|�qCn�|jtjkrp|��}|ro|jD]
}t|||�}|�|�qan�|jtjkr}|�|j�}n�|jtjkr�|�|j�}n�|jtjkr�|�|j |j�}n�|jtj!kr�|�"|j�}n�|jtj#kr�|�$|j|j�}d|_|j|_n�|jtj%k�r?tjjj}|j&�'|j(|j)|j*�}||_|�r>g|j+_,g|j-_,|j-j,D]"}	t.|	j|	j)|	j*�}
||
_|j-j,�/|
�t0|	d��r|	�1||	|
�q�|j+j,D]1}t2|j|j)|j*|j3�}|j4|_4|j5|_5|j6|_6||_|j+j,�/|�t0|d��r<|�1|||��qn
tj�7dt8|���t0|d��rV|�1|||�|S)NTr�zCannot clone node %s)9rbrqr@rAr�r�Z
NODE_IMPORTEDr!r	r]r�r�r�r�r�r,r�r)r�r�r,rarFr<r�rYr�rZr�r�r�r�rPr�r�r�r�r�rfr�r�r�r�r�r�r�r�r\r�r�r�r�r�rrjr�rC)
rRrcZnewOwnerDocumentr�r�r"r�r`rQr
r�r�r�rrrraas�
�

�
���

����racCs(|�dd�}t|�dkr|Sd|dfS)Nr�r;�r)r�r�)r*Zfieldsrrrr(�sr(cCs0||i|��}|��\}}|�|�|��|Sr*)ZgetEventZ
expandNoder�)�func�args�kwargsZeventsZtoktypeZrootNoderrr�_do_pulldom_parse�s

r�cCsF	|dur|sddlm}|�|�Sddlm}t|j|f||d��S)Nr��expatbuilder��pulldom)�parser�bufsize)�xml.domr��parser�r�)�filer�r�r�r�rrrr��s

�r�cCs@	|durddlm}|�|�Sddlm}t|j|fd|i�S)Nrr�r�r�)r�r��parseStringr�r�)�stringr�r�r�rrrr��s

�r�cCs@|rt|t�rt�|�}|D]\}}tj�||�sdSqtjSr*)r�r�rZ_parse_feature_stringr�rfrg)Zfeatures�f�vrrr�getDOMImplementation�s

�r�r�r*)6rr�r@rrrrZxml.dom.minicompatZxml.dom.xmlbuilderrrrAr	r]r�rJZdefpropertyrTr�r�r�r�r�r��objectr�Z
AttributeListrr�rr/rGrNrYr�rvrCr|r}rr�r�r�r�r�r�rKr�rar(r�r�r�r�rrrr�<module>s��w
	{$�
��)GU��	>�<(	O*U�R




?>