Your IP : 3.139.86.58


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-1.pyc

o

6��f,
�@s�dZddlZddlZddlmZmZmZmZddlTddl	m
Z
mZejj
jejj
jfZGdd�dejj
�Z
ee
dd	d
�ee
ddd
�ee
d
dd
�dd�Zdd�Zdd�Zdd�Zdd�ZGdd�de
�ZGdd�de
�Zeeddd
�eed
dd
�eed d!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/d0�d0�Z Gd1d2�d2e e
�Z!Gd3d4�d4e e
�Z"ee"d$d5d
�Gd6d7�d7e"�Z#ee#d8d9d
�ee#d:d;d
�d<d=�Z$d>d?�Z%Gd@dA�dAe"�Z&GdBdC�dCe#�Z'GdDdE�dEe�Z(ee(d$dFd
�GdGdH�dH�Z)GdIdJ�dJe)e e
�Z*GdKdL�dLe)e
�Z+GdMdN�dNe)e e
�Z,GdOdP�dPe
�Z-GdQdR�dRe�Z.dSdT�Z/GdUdV�dVe
e�Z0ee0dWdXd
�dYdZ�Z1d[d\�Z2d]d^�Z3ded_d`�Z4dfdadb�Z5dfdcdd�Z6dS)gacSimple implementation of the Level 1 DOM.

Namespaces and other minor Level 2 features are also supported.

parse("foo.xml")

parseString("<foo><bar/></foo>")

Todo:
=====
 * convenience methods for getting elements and text.
 * more testing
 * bring some of the writer and linearizer code into conformance with this
        interface
 * SAX 2 namespaces
�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�}|�|�d	Sd	S)
zWrites datachars to writer.�&z&amp;�<z&lt;�"z&quot;�>z&gt;N)�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�eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
d:dd�ZeZdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Z dS);�NamedNodeMapaThe attribute list is a transient interface to the underlying
    dictionaries.  Mutations here will change the underlying element's
    dictionary.

    Ordering is imposed artificially and does not reflect the order of
    attributes as found in an input document.
    �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��__doc__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.unlinkcCs2|jdurdSz|j|jWStyYdSw)a�Returns the value of the specified attribute.

        Returns the value of the element's attribute named attname as
        a string. An empty string is returned if the element does not
        have such an attribute. Note that an empty string may also be
        returned as an explicitly given attribute value, use the
        hasAttribute method to distinguish these two cases.
        Nr)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@rAZInuseAttributeErrr r�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)z�Checks whether the element has an attribute with the specified name.

        Returns True if the element has an attribute with the specified name.
        Otherwise, returns False.
        NF�r�rrrr�hasAttributeIs

zElement.hasAttributecCs|jdurdS||f|jvS�NF)r�rrrr�hasAttributeNSSs
zElement.hasAttributeNScC�t||t��S)z�Returns all descendant elements with the given tag name.

        Returns the list of all descendant elements (not direct children
        only) with the specified tag name.
        �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|jrv|�d�t|j�dkrP|jdjt	j
t	jfvrP|jd�|ddd�n|�|�|jD]}|�|||||�qX|�|�|�d|j|f�d
S|�d	|�d
S)z�Write an XML element to a file-like object

        Write the element to the writer object that must provide
        a write method (e.g. a file or StringIO object).
        r�z %s="r�r�r;rrz</%s>%sz/>%sN)
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*)r r�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*rA)r
r�r�rBrrr�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
rBrrrrA�s

�zElement.setIdAttributeNode�rrr).r�r�r�r�r	r]r!r�r�r�r�r�r�rYr�r�r?rr�r rmr"r[r$r%r(r-r&r*r'ZsetAttributeNodeNSr1r2r/ZremoveAttributeNodeNSr4r6r9r<rr#r>r@rCrDrArrrrr�sV�
�		

 rr�z*NamedNodeMap of attributes on the element.z%Namespace-local name of this element.cCs8t|�|��||j|j<||j|j|jf<||_dSr*)rKr r�r�r�r�r�r�)�elementr#rrrr0�s

r0c@sfeZdZdZdZdZe�ZdZdZ	dd�Z
dd�Zdd	�Zd
d�Z
dd
�Zdd�Zdd�Zdd�ZdS)�	Childlessz�Mixin that makes childless-ness easy to implement and avoids
    the complexity of the Node methods that deal with children.
    rNcCrlr*rrrrrr5�rzChildless._get_firstChildcCrlr*rrrrrr9�rzChildless._get_lastChildcC�tj�|jd��)Nz nodes cannot have children�r@rArBr�rrrrrF���zChildless.appendChildcCr
r5rrrrrr-�rzChildless.hasChildNodescCrJ�Nz nodes do not have childrenrK�r
rOrPrrrr>�rLzChildless.insertBeforecCrJrM)r@rArIr�rXrrrrE�rLzChildless.removeChildcCrlr*rrrrrr^�rnzChildless.normalizecCrJrMrK�r
rOrUrrrrV�rLzChildless.replaceChild)r�r�r�rr�r�Z
EmptyNodeListr,r�r�r5r9rFr-r>rEr^rVrrrrrI�srIc@s\eZdZejZdZdd�Zdd�Zdd�Z	e
ee	�Zdd	�Zd
d�Z
e
ee
�Zdd
d�ZdS)�ProcessingInstruction��targetrZcCrr*rQ)r
rRrZrrrr��rzProcessingInstruction.__init__cCr/r*�rZrrrr�_get_nodeValue�r2z$ProcessingInstruction._get_nodeValuecC�
||_dSr*rSr�rrr�_set_nodeValue�r.z$ProcessingInstruction._set_nodeValuecCr/r*�rRrrrr�
_get_nodeName�r2z#ProcessingInstruction._get_nodeNamecCrUr*rWr�rrr�
_set_nodeName�r.z#ProcessingInstruction._set_nodeNamercCs|�d||j|j|f�dS)Nz
%s<?%s %s?>%s)r�rRrZ�r
r(r&r?r'rrrr#�szProcessingInstruction.writexmlNrG)r�r�r�r	r�r!r�r�rTrVr�r�rXrYr�r#rrrrrP�s

rPc@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)rbrDrNrMr\r	r�rrrrr��szCharacterData.__init__cCr)r*)r�rZrrrrr�r.zCharacterData._get_lengthcCr/r*�r\rrrr�	_get_datar2zCharacterData._get_datacCrUr*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*rS)r
�argrrr�
appendData rzCharacterData.appendDatacCs^|dkr
tj�d��|t|j�krtj�d��|r-d|jd|�||j|d�f|_dSdS)Nrrcrd�%s%s%srf)r
rirlrrr�
insertData#s��zCharacterData.insertDatacCsp|dkr
tj�d��|t|j�krtj�d��|dkr!tj�d��|r6|jd|�|j||d�|_dSdSrbrfrhrrr�
deleteData,s&�zCharacterData.deleteDatacCsv|dkr
tj�d��|t|j�krtj�d��|dkr!tj�d��|r9d|jd|�||j||d�f|_dSdS)Nrrcrdrernrf)r
rirjrlrrr�replaceData6s��zCharacterData.replaceDataN)r�r�r�r�r�r�rr^r`r�rZr�rrkrmrorprqrrrrr[�s			
r[zLength 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@rArgrrbrMrDr,rFr>)r
riZnewText�nextrrr�	splitTextKszText.splitTextrcCst|d||j|f�dS)Nrn)r�rZrZrrrr#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
rrrrr�replaceWholeTextqs.
�

�zText.replaceWholeTextcCsB|j��rdSt|�}|durdS|j�|�}|durdS|��Sr5)rZ�strip�_get_containing_elementrbr��isElementContent)r
r�r�rrr�!_get_isWhitespaceInElementContent�s
z&Text._get_isWhitespaceInElementContentrG)r�r�r�r�r	rYr!r�r�rsr#rurvrzrrrrr�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]�rRrQrrrrx���rxcCr{r*)rDr!r	r�r|rrrrE�r}rEc@s(eZdZejZdZdd�Zddd�ZdS)	�Commentz#commentcCst�|�||_dSr*)r[r�r\r_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�rZrrrr#�s
zComment.writexmlNrG)	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�rZrrrr#�szCDATASection.writexmlNrG)	r�r�r�r�r	r�r!r�r#rrrrr�s
rc@szeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�ReadOnlySequentialNamedNodeMap��_seqrcCrUr*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@rArFrrrrr���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
	r�z&Number of entries in the NamedNodeMap.c@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
�
Identifiedz@Mix-in class that supports the publicId and systemId attributes.��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�rr�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�rZrrrr#Js
�


zDocumentType.writexmlrG)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�rNrrrr>tr�zEntity.insertBeforecCr�)Nz*cannot remove children from an entity noder�rXrrrrExr�zEntity.removeChildcCr�)Nz)cannot replace children of an entity noder�rOrrrrV|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,rHrrr�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@s\eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dS)�ElementInfoz�Object that represents content-model information for an element.

    This implementation is not expected to be used in practice; DOM
    builders should provide implementations which do the right thing
    using information available to it.

    r!cCrUr*r!rrrrr��r.zElementInfo.__init__cC�tSr*�r��r
Zanamerrrr��rzElementInfo.getAttributeTypecCr�r*r�rrrrr��rzElementInfo.getAttributeTypeNScCr
r5rrrrrry�rzElementInfo.isElementContentcCr
)zQReturns true iff this element is declared to have an EMPTY
        content model.Frrrrr�isEmpty�szElementInfo.isEmptycCr
)z7Returns true iff the named attribute is a DTD-style ID.Frr�rrrr��rnzElementInfo.isIdcCr
)z<Returns true iff the identified attribute is a DTD-style ID.Frrrrrr��rnzElementInfo.isIdNScCr/r*r!rrrrr�r2zElementInfo.__getstate__cCrUr*r!rrrrr�r.zElementInfo.__setstate__N)r�r�r�rr�r�r�r�ryr�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
rHr{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�rrrZrb�r
rZrQrrr�createCDATASection�r�zDocument.createCDATASectioncCr�r*)r~rbr�rrr�
createComment�r�zDocument.createCommentcCst||�}||_|Sr*)rPrb)r
rRrZ�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.getElementByIdcCr7r*r8rrrrr9r�zDocument.getElementsByTagNamecCr:r*r;rrrrr<
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�rtr,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'rA)r
r
r�r�r�r�rHZis_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�r9r<rkr�r#r�rrrrr�
sn�	
:
�r�r�z#Top-level element of this document.c
Cs�|j�|�rtjjj}ntjjj}|jtj	krQ|�
|j|j�}|j
��D]}|�|j|j|j�|�|j|j�}|j|_q$|rP|jD]
}t|||�}|�|�qBn�|jtjkro|��}|rn|jD]
}t|||�}|�|�q`n�|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|||��qn
tj�7dt8|���t0|d��rU|�1|||�|S)zo
    Clone a node and give it the new owner document.
    Called by Node.cloneNode and Document.importNode
    Tr�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�rRr�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�cCsD|dur|sddlm}|�|�Sddlm}t|j|f||d��S)z3Parse a file into a DOM by filename or file object.Nr��expatbuilder��pulldom)�parser�bufsize)�xml.domr��parser�r�)�filer�r�r�r�rrrr��s

�r�cCs>|durddlm}|�|�Sddlm}t|j|fd|i�S)z&Parse a file into a DOM from a string.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*)7rrr�r@rrrrZxml.dom.minicompatZxml.dom.xmlbuilderrrrAr	r]r�rJZdefpropertyrTr�r�r�r�r�r��objectr�Z
AttributeListrr�rr0rIrPr[r�rxrEr~rr�r�r�r�r�r�r�rKr�rar)r�r�r�r�rrrr�<module>s��w
	{$�
��)GU��	>�<(	O*U�R




?>