Your IP : 3.133.124.80


Current Path : /usr/lib64/python3.8/xml/dom/__pycache__/
Upload File :
Current File : //usr/lib64/python3.8/xml/dom/__pycache__/minidom.cpython-38.opt-2.pyc

U

e5d)�@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�Z4dfdbdc�Z5dS)g�N)�EMPTY_NAMESPACE�EMPTY_PREFIX�XMLNS_NAMESPACE�domreg)�*)�DOMImplementationLS�
DocumentLSc@s�eZdZdZdZdZdZdZeZ	dd�Z
d2dd�Zd3dd	�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�NodeNcCsdS)NT���selfr
r
�'/usr/lib64/python3.8/xml/dom/minidom.py�__bool__+sz
Node.__bool__cCs|�dd|�S�N�)�toprettyxml)r�encodingr
r
r
�toxml.sz
Node.toxml�	�
cCsx|dkrt��}ntjt��|ddd�}|jtjkrH|�|d|||�n|�|d||�|dkrh|��S|�	���SdS)N�xmlcharrefreplacer)r�errors�newliner)
�io�StringIO�
TextIOWrapper�BytesIO�nodeTyper	�
DOCUMENT_NODE�writexml�getvalue�detach)r�indent�newlr�writerr
r
r
r1s

�zNode.toprettyxmlcCs
t|j�S�N)�bool�
childNodesrr
r
r
�
hasChildNodesCszNode.hasChildNodescCs|jSr%�r'rr
r
r
�_get_childNodesFszNode._get_childNodescCs|jr|jdSdS�Nrr)rr
r
r
�_get_firstChildIszNode._get_firstChildcCs|jr|jdSdS�N���r)rr
r
r
�_get_lastChildMszNode._get_lastChildcCs
|j|jkr,t|j�D]}|�||�q|S|j|jkrTtj�dt	|�t	|�f��|j
dk	rj|j
�|�|dkr~|�|�n�z|j�
|�}Wntk
r�tj���YnX|jtkr�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�cr=�noder
r
r
r4Qs8�

zNode.insertBeforecCs�|j|jkr*t|j�D]}|�|�q|S|j|jkrTtj�dt	|�t	|�f��n|jt
krft|�|jdk	r||j�
|�t||�d|_|S�Nr0)rr2r3r'r<r5r6r7r8r9r@rAr:r;�
_append_childrC)rrHrGr
r
r
r<qs�


zNode.appendChildcCs|j|jkr(|j}|�|�|�||�S|j|jkrPtj�dt	|�t	|�f��||kr\dS|j
dk	rr|j
�|�z|j�|�}Wnt
k
r�tj���YnX||j|<||_
d|_
|jtks�|jtkr�t|�|j|_|j|_d|_d|_|jr�||j_|j�r||j_|SrI)rr2rCr;r4r5r6r7r8r9r:r'r=r>r?r@rArD)rrE�oldChildrFr=r
r
r
�replaceChild�s@
�


�zNode.replaceChildcCs�z|j�|�Wntk
r.tj���YnX|jdk	rD|j|j_|jdk	rX|j|j_d|_|_|jt	krvt
|�d|_|Sr%)r'�remover>r6r7r?rCrDrr@rAr:�rrKr
r
r
r;�s




zNode.removeChildcCs�g}|jD]�}|jtjkr�|jsJ|r0|j|d_|jr@|j|j_|��q�|r�|dj|jkr�|d}|j|j|_|j|_|jr�||j_|��q�|�|�q
|�|�|jtj	kr
|�
�q
||jdd�<dSr-)r'rr	�	TEXT_NODE�datarCrD�unlink�append�ELEMENT_NODE�	normalize)r�L�childrHr
r
r
rT�s*





zNode.normalizecCst|||jp|�Sr%)�_clone_node�
ownerDocument)r�deepr
r
r
�	cloneNode�szNode.cloneNodecCs|jj�||�Sr%)rX�implementation�
hasFeature�r�feature�versionr
r
r
�isSupported�szNode.isSupportedcCsdSr%r
rr
r
r
�_get_localName�szNode._get_localNamecCs||kSr%r
�r�otherr
r
r
�
isSameNode�szNode.isSameNodecCs|�|d�r|SdSdSr%)r`�rr^r
r
r
�getInterface�szNode.getInterfacec	Cs0z|j|dWSttfk
r*YdSXdSr+)�
_user_data�AttributeError�KeyError�r�keyr
r
r
�getUserData�szNode.getUserDatacCsnd}z
|j}Wntk
r,i}||_YnX||krB||d}|dkr^d}|dk	rj||=n||f||<|Sr+)rgrh)rrkrP�handler�old�dr
r
r
�setUserData�s
zNode.setUserDatacCsDt|d�r@t|j���D]&\}\}}|dk	r|�|||||�qdS)Nrg)�hasattr�listrg�itemsZhandle)r�	operation�srcZdstrkrPrmr
r
r
�_call_user_data_handler�s
zNode._call_user_data_handlercCs>d|_|_|jr.|jD]}|��qt�|_d|_d|_dSr%)r:rXr'rQ�NodeListrDrC)rrVr
r
r
rQs

zNode.unlinkcCs|Sr%r
rr
r
r
�	__enter__szNode.__enter__cCs|��dSr%)rQ)rZetZev�tbr
r
r
�__exit__sz
Node.__exit__)N)rrN)!�__name__�
__module__�__qualname__�namespaceURIr:rXrCrDr�prefixrrrr(r*r,r/r4r<rLr;rTrZr`rardrfrlrprvrQrxrzr
r
r
r
r	"s:

  
r	�
firstChildzFirst child node, or None.)�doc�	lastChildzLast child node, or None.�	localNamez"Namespace-local name of this node.cCs2|j}|r|d}||_||_|�|�||_dSr-)r'rDrCrRr:)rrHr'Zlastr
r
r
rJs
rJcCs$|dk	r |jtjkrdS|j}qdS�NTF)rr	rr:�rHr
r
r
�_in_document&s
r�cCs6|r2|�dd��dd��dd��dd�}|�|�dS)	N�&z&amp;�<z&lt;�"z&quot;�>z&gt;)�replace�write)r$rPr
r
r
�_write_data.s��r�cCsD|jD]8}|jtjkr2|dks(|j|kr2|�|�t|||�q|S�Nr)r'rr	rS�tagNamerR�_get_elements_by_tagName_helper)�parent�name�rcrHr
r
r
r�5s
��
r�cCsX|jD]L}|jtjkr|dks(|j|krD|dks:|j|krD|�|�t||||�q|Sr�)r'rr	rSr�r~rR�"_get_elements_by_tagName_ns_helper)r�ZnsURIr�r�rHr
r
r
r�=s
��
r�c@sJeZdZejZdZdZdZdZ	ej
ejejej
ejejejfZdd�ZdS)�DocumentFragmentz#document-fragmentNcCst�|_dSr%)rwr'rr
r
r
�__init__TszDocumentFragment.__init__)r{r|r}r	r2r�nodeName�	nodeValue�
attributesr:rSrO�CDATA_SECTION_NODE�ENTITY_REFERENCE_NODE�PROCESSING_INSTRUCTION_NODE�COMMENT_NODE�
NOTATION_NODEr5r�r
r
r
r
r�Fs�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'�
_localNamerX�ownerElementNFcCs2d|_||_||_||_t�|_|j�t��dSr%)r�r�r~r�rwr'rR�Text)r�qNamer~r�rr
r
r
r�bsz
Attr.__init__cCs4z|jWStk
r.|j�dd�dYSXdS�N�:r1r.)r�rhr��splitrr
r
r
raoszAttr._get_localNamecCs|jSr%)�	specifiedrr
r
r
�_get_specifieduszAttr._get_specifiedcCs|jSr%)r�rr
r
r
�	_get_namexszAttr._get_namecCs||_|jdk	rt|j�dSr%)r�r�rA�r�valuer
r
r
�	_set_name{s
zAttr._set_namecCs|jSr%)r�rr
r
r
�
_get_value�szAttr._get_valuecCs6||_||jd_|jdk	r&t|j�||jd_dSr+)r�r'rPr�rAr�r
r
r
�
_set_value�s


zAttr._set_valuecCs|jSr%)r�rr
r
r
�_get_prefix�szAttr._get_prefixcCsd|j}|dkr&|r&|tkr&tj�d��||_|dkr<|j}nd||jf}|jrZt|j�||_	dS)N�xmlnsz5illegal use of 'xmlns' prefix for the wrong namespacez%s:%s)
r~rr6r7�NamespaceErrr�r�r�rAr�)rrZnsuriZnewNamer
r
r
�_set_prefix�s�
zAttr._set_prefixcCsv|j}|dk	rR|j|j=|j|j|jf=|jrRd|_|jd8_|jj	d8_	|j
D]}|��qX|j
dd�=dS)NFr1)r��_attrsr��_attrsNSr~r��_is_id�_magic_id_nodesrX�_magic_id_countr'rQ)r�elemrVr
r
r
rQ�s


zAttr.unlinkcCsf|jr
dS|j}|j}|dks&|dkr*dS|�|�}|dkr@dS|jrV|�|j|j�S|�|j�SdSr�)	r�rXr��_get_elem_infor~�isIdNSr��isIdr��rr�r��infor
r
r
�	_get_isId�s
zAttr._get_isIdcCs\|j}|j}|dks|dkr tS|�|�}|dkr6tS|jrL|�|j|j�S|�|j�SdSr%)	rXr��_no_typer�r~�getAttributeTypeNSr��getAttributeTyper�r�r
r
r
�_get_schemaType�s
zAttr._get_schemaType) r{r|r}�	__slots__r	�ATTRIBUTE_NODErr�r�r�rOr�r5rr�rar�r�r��propertyr�r�r�r�r�r�r�r�rrQr�r�r
r
r
r
r�Xs.�


r�r�z True if this attribute is an ID.z'Namespace-local name of this attribute.�
schemaTypezSchema type for this attribute.c@s�eZdZdZdd�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�r
r
r
r��szNamedNodeMap.__init__cCs
t|j�Sr%)�lenr�rr
r
r
�_get_length�szNamedNodeMap._get_lengthcCs4z|t|j���|WStk
r.YdSXdSr%)rrr��keys�
IndexError�rr=r
r
r
�item�szNamedNodeMap.itemcCs*g}|j��D]}|�|j|jf�q|Sr%)r��valuesrRr�r��rrUrHr
r
r
rs�szNamedNodeMap.itemscCs0g}|j��D]}|�|j|jf|jf�q|Sr%)r�r�rRr~r�r�r�r
r
r
�itemsNS�szNamedNodeMap.itemsNScCs"t|t�r||jkS||jkSdSr%)�
isinstance�strr�r�rjr
r
r
�__contains__�s

zNamedNodeMap.__contains__cCs
|j��Sr%)r�r�rr
r
r
r�szNamedNodeMap.keyscCs
|j��Sr%)r�r�rr
r
r
�keysNSszNamedNodeMap.keysNScCs
|j��Sr%)r�r�rr
r
r
r�szNamedNodeMap.valuesNcCs|j�||�Sr%�r��get)rr�r�r
r
r
r�
szNamedNodeMap.getcCs:|jt|dd�krdSt|�t|�kt|�t|�kSdS)Nr�r)r��getattr�idrbr
r
r
�_cmpszNamedNodeMap._cmpcCs|�|�dkSr+�r�rbr
r
r
�__eq__szNamedNodeMap.__eq__cCs|�|�dkSr+r�rbr
r
r
�__ge__szNamedNodeMap.__ge__cCs|�|�dkSr+r�rbr
r
r
�__gt__szNamedNodeMap.__gt__cCs|�|�dkSr+r�rbr
r
r
�__le__szNamedNodeMap.__le__cCs|�|�dkSr+r�rbr
r
r
�__lt__!szNamedNodeMap.__lt__cCs"t|t�r|j|S|j|SdSr%)r�r3r�r�)r�attname_or_tupler
r
r
�__getitem__$s

zNamedNodeMap.__getitem__cCsvt|t�rRz|j|}Wn0tk
rHt|�}|jj|_|�|�YnX||_n t|t�sdt	d��|}|�|�dS)Nz%value must be a string or Attr object)
r�r�r�rir�r�rX�setNamedItemr��	TypeError)r�attnamer�rHr
r
r
�__setitem__+s


zNamedNodeMap.__setitem__cCs(z|j|WStk
r"YdSXdSr%)r�ri�rr�r
r
r
�getNamedItem:szNamedNodeMap.getNamedItemcCs,z|j||fWStk
r&YdSXdSr%)r�ri�rr~r�r
r
r
�getNamedItemNS@szNamedNodeMap.getNamedItemNScCsX|�|�}|dk	rJt|j�|j|j=|j|j|jf=t|d�rFd|_	|St
j���dS�Nr�)
r�rAr�r�r�r�r~r�rqr�r6r7r?�rr��nr
r
r
�removeNamedItemFs



zNamedNodeMap.removeNamedItemcCsZ|�||�}|dk	rLt|j�|j|j|jf=|j|j=t|d�rHd|_	|St
j���dSr�)
r�rAr�r�r~r�r�r�rqr�r6r7r?�rr~r�r�r
r
r
�removeNamedItemNSRs


zNamedNodeMap.removeNamedItemNScCstt|t�s&tj�dt|�t|�f��|j�|j�}|r@|�	�||j|j<||j
|j|jf<|j
|_t|j�|SrI)r�r�r6r7r8r9r�r�r�rQr�r~r�r�r�rA)rrHrnr
r
r
r�^s
�
zNamedNodeMap.setNamedItemcCs
|�|�Sr%)r��rrHr
r
r
�setNamedItemNSkszNamedNodeMap.setNamedItemNScCs||}t|j�|��dSr%)rAr�rQ)rr�rHr
r
r
�__delitem__ns
zNamedNodeMap.__delitem__cCs|j|j|jfSr%r�rr
r
r
�__getstate__sszNamedNodeMap.__getstate__cCs|\|_|_|_dSr%r��r�stater
r
r
�__setstate__vszNamedNodeMap.__setstate__)N) r{r|r}r�r�r�r�rsr�r�r�r�r�r��__len__r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r
r
r
r
r��s:	

r�Zlengthz$Number of nodes in the NamedNodeMap.c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�TypeInfo��	namespacer�cCs||_||_dSr%r�)rrr�r
r
r
r��szTypeInfo.__init__cCs2|jrd|jj|j|jfSd|jj|jfSdS)Nz<%s %r (from %r)>z<%s %r>)r�	__class__r{r�rr
r
r
�__repr__�s
�zTypeInfo.__repr__cCs|jSr%)r�rr
r
r
r��szTypeInfo._get_namecCs|jSr%)rrr
r
r
�_get_namespace�szTypeInfo._get_namespaceN)r{r|r}r�r�rr�rr
r
r
r
r�s
r�c@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)rXr:r�r�rr~r�r'r�r�rCrDNrcCsBd|_||_|_||_||_t�|_d|_|_d|_	d|_
dSr%)r:r�r�rr~rwr'rCrDr�r�)rr�r~rr�r
r
r
r��s
zElement.__init__cCs|jdkri|_i|_dSr%)r�r�rr
r
r
�_ensure_attributes�s
zElement._ensure_attributescCs4z|jWStk
r.|j�dd�dYSXdSr�)r�rhr�r�rr
r
r
ra�szElement._get_localNamecCs|jSr%�r�rr
r
r
�_get_tagName�szElement._get_tagNamecCs@|jdk	r&t|j���D]}|��qd|_d|_t�|�dSr%)r�rrr�rQr�r	)r�attrr
r
r
rQ�s

zElement.unlinkcCs8|jdkrdSz|j|jWStk
r2YdSXdSr)r�r�ri)rr�r
r
r
�getAttribute�s
zElement.getAttributecCs<|jdkrdSz|j||fjWStk
r6YdSXdSr)r�r�rir�r
r
r
�getAttributeNS�s
zElement.getAttributeNScCsV|�|�}|dkr4t|�}||_|j|_|�|�n||jkrR||_|jrRt|�dSr%)�getAttributeNoder�r�rX�setAttributeNoder�rA)rr�r�rr
r
r
�setAttribute�s

zElement.setAttributecCs�t|�\}}|�||�}|dkrHt||||�}||_|j|_|�|�n4||jkrf||_|jrft|�|j|kr|||_||_	dSr%)
�_nssplit�getAttributeNodeNSr�r�rXrr�rArr�)rr~�
qualifiedNamer�r�	localnamerr
r
r
�setAttributeNS�s

zElement.setAttributeNScCs|jdkrdS|j�|�Sr%r�)r�attrnamer
r
r
r�s
zElement.getAttributeNodecCs|jdkrdS|j�||f�Sr%)r�r�r�r
r
r
rs
zElement.getAttributeNodeNScCs�|jd|fkrtj�d��|��|j�|jd�}|dk	rD|�|�|j	�|j
|jfd�}|dk	rt||k	rt|�|�t||�||k	r�|S||k	r�|SdS)Nzattribute node already owned)
r�r6r7ZInuseAttributeErrrr�r�r��removeAttributeNoder�r~r��_set_attribute_node)rrZold1Zold2r
r
r
rs


zElement.setAttributeNodecCsP|jdkrtj���z|j|}Wntk
r@tj���YnX|�|�dSr%)r�r6r7r?r�rir)rr�rr
r
r
�removeAttributes

zElement.removeAttributecCsT|jdkrtj���z|j||f}Wntk
rDtj���YnX|�|�dSr%)r�r6r7r?rir)rr~r�rr
r
r
�removeAttributeNS%s

zElement.removeAttributeNScCs^|dkrtj���z|j|jWntk
r@tj���YnXt|�|��|j|_|Sr%)	r6r7r?r�r�rirArQrXr�r
r
r
r.s
zElement.removeAttributeNodecCs|jdkrdS||jkS�NF�r�r�r
r
r
�hasAttribute>s
zElement.hasAttributecCs|jdkrdS||f|jkSr)r�r�r
r
r
�hasAttributeNSCs
zElement.hasAttributeNScCst||t��Sr%�r�rwr�r
r
r
�getElementsByTagNameHszElement.getElementsByTagNamecCst|||t��Sr%�r�rwr�r
r
r
�getElementsByTagNameNSKs�zElement.getElementsByTagNameNScCsd|jt|�fS)Nz<DOM Element: %s at %#x>)r�r�rr
r
r
rOszElement.__repr__rcCs�|�|d|j�|��}|��D],}|�d|�t|||j�|�d�q$|jr�|�d�t|j�dkr�|jdjt	j
t	jfkr�|jd�|ddd�n4|�|�|jD]}|�|||||�q�|�|�|�d|j|f�n|�d	|�dS)
Nr�z %s="r�r�r1rrz</%s>%sz/>%s)
r�r��_get_attributesr�r�r�r'r�rr	rOr�r)rr$r"�	addindentr#r�Za_namerHr
r
r
rRs*

��


zElement.writexmlcCs|��t|j|j|�Sr%)rr�r�r�rr
r
r
r mszElement._get_attributescCs|jr
dSdSdSr�rrr
r
r
�
hasAttributesqszElement.hasAttributescCs|�|�}|�|�dSr%)r�setIdAttributeNode)rr��idAttrr
r
r
�setIdAttributeys
zElement.setIdAttributecCs|�||�}|�|�dSr%)rr#)rr~r�r$r
r
r
�setIdAttributeNS}szElement.setIdAttributeNScCsj|dks|�|j�stj���t|�dk	r4tj���|jsfd|_|jd7_|j	j
d7_
t|�dS)NTr1)rdr�r6r7r?�_get_containing_entref�NoModificationAllowedErrr�r�rXr�rA)rr$r
r
r
r#�s

zElement.setIdAttributeNode)rrr).r{r|r}r�r	rSrr�r�r�r�r�r�rOr�r�r5rr�rrarrQr	r
r
rrrrZsetAttributeNodeNSrrrZremoveAttributeNodeNSrrrrrrr r"r%r&r#r
r
r
r
r�sT��
		
rr�z*NamedNodeMap of attributes on the element.z%Namespace-local name of this element.cCs8t|�|��||j|j<||j|j|jf<||_dSr%)rArr�r�r�r~r�r�)�elementrr
r
r
r�s
rc@sbeZdZdZdZe�ZdZdZdd�Z	dd�Z
dd�Zd	d
�Zdd�Z
d
d�Zdd�Zdd�ZdS)�	Childlessr
NcCsdSr%r
rr
r
r
r,�szChildless._get_firstChildcCsdSr%r
rr
r
r
r/�szChildless._get_lastChildcCstj�|jd��dS)Nz nodes cannot have children�r6r7r8r�r�r
r
r
r<�s�zChildless.appendChildcCsdSrr
rr
r
r
r(�szChildless.hasChildNodescCstj�|jd��dS�Nz nodes do not have childrenr+�rrErFr
r
r
r4�s�zChildless.insertBeforecCstj�|jd��dSr,)r6r7r?r�rNr
r
r
r;�s�zChildless.removeChildcCsdSr%r
rr
r
r
rT�szChildless.normalizecCstj�|jd��dSr,r+�rrErKr
r
r
rL�s�zChildless.replaceChild)r{r|r}r�r�Z
EmptyNodeListr'r�r�r,r/r<r(r4r;rTrLr
r
r
r
r*�sr*c@s\eZdZejZdZdd�Zdd�Zdd�Z	e
ee	�Zdd	�Zd
d�Z
e
ee
�Zdd
d�ZdS)�ProcessingInstruction��targetrPcCs||_||_dSr%r0)rr1rPr
r
r
r��szProcessingInstruction.__init__cCs|jSr%�rPrr
r
r
�_get_nodeValue�sz$ProcessingInstruction._get_nodeValuecCs
||_dSr%r2r�r
r
r
�_set_nodeValue�sz$ProcessingInstruction._set_nodeValuecCs|jSr%�r1rr
r
r
�
_get_nodeName�sz#ProcessingInstruction._get_nodeNamecCs
||_dSr%r5r�r
r
r
�
_set_nodeName�sz#ProcessingInstruction._set_nodeNamercCs|�d||j|j|f�dS)Nz
%s<?%s %s?>%s)r�r1rP�rr$r"r!r#r
r
r
r�szProcessingInstruction.writexmlN)rrr)r{r|r}r	r�rr�r�r3r4r�r�r6r7r�rr
r
r
r
r/�s

r/c@sreZdZdZdd�Zdd�ZeZdd�Zdd	�Ze	ee�Z
Zd
d�Zdd
�Z
dd�Zdd�Zdd�Zdd�ZdS)�
CharacterData)�_datarXr:rDrCcCs,d|_|_d|_|_d|_t�|�dSr)rXr:rDrCr:r	r�rr
r
r
r��szCharacterData.__init__cCs
t|j�Sr%)r�rPrr
r
r
r��szCharacterData._get_lengthcCs|jSr%�r:rr
r
r
�	_get_data�szCharacterData._get_datacCs
||_dSr%r;�rrPr
r
r
�	_set_data�szCharacterData._set_datacCs6|j}t|�dkrd}nd}d|jj|dd�|fS)N�
z...rz<DOM %s node "%r%s">r)rPr�rr{)rrPZ	dotdotdotr
r
r
r�s
�zCharacterData.__repr__cCsT|dkrtj�d��|t|j�kr.tj�d��|dkrBtj�d��|j|||�S�Nr�offset cannot be negative�#offset cannot be beyond end of data�count cannot be negative�r6r7�IndexSizeErrr�rP�r�offset�countr
r
r
�
substringData�szCharacterData.substringDatacCs|j||_dSr%r2)r�argr
r
r
�
appendDataszCharacterData.appendDatacCsZ|dkrtj�d��|t|j�kr.tj�d��|rVd|jd|�||j|d�f|_dS)NrrArB�%s%s%srD)rrGrJr
r
r
�
insertData	s�zCharacterData.insertDatacCsl|dkrtj�d��|t|j�kr.tj�d��|dkrBtj�d��|rh|jd|�|j||d�|_dSr@rDrFr
r
r
�
deleteDataszCharacterData.deleteDatacCsr|dkrtj�d��|t|j�kr.tj�d��|dkrBtj�d��|rnd|jd|�||j||d�f|_dS)NrrArBrCrLrD)rrGrHrJr
r
r
�replaceDatas�zCharacterData.replaceDataN)r{r|r}r�r�r�r�r<r>r�rPr�rrIrKrMrNrOr
r
r
r
r9�s			
r9zLength of the string data.c@sHeZdZdZejZdZdZdd�Z	ddd�Z
d	d
�Zdd�Zd
d�Z
dS)r�r
z#textNcCs�|dks|t|j�kr"tj�d��|��}|j|d�|_|j|_|j}|jr~||jj	kr~|dkrp|j�
|�n|j�||�|jd|�|_|S)Nrzillegal offset value)r�rPr6r7rErrXrCr:r'r<r4)rrGZnewText�nextr
r
r
�	splitText1szText.splitTextrcCst|d||j|f�dS)NrL)r�rPr8r
r
r
r@sz
Text.writexmlcCs�|jg}|j}|dk	rB|jtjtjfkrB|�d|j�|j}qqBq|j}|dk	rz|jtjtjfkrz|�|j�|j}qHqzqHd�	|�S)Nrr)
rPrDrr	rOr�rBrCrR�join)rrUr�r
r
r
�_get_wholeTextEszText._get_wholeTextcCs�|j}|j}|dk	r@|jtjtjfkr@|j}|�|�|}qq@q|j}|sT|�|�|dk	r�|jtjtjfkr�|j}|�|�|}qTq�qT|r�||_|SdSdSr%)	r:rDrr	rOr�r;rCrP)rZcontentr�r�rPr
r
r
�replaceWholeTextWs*


zText.replaceWholeTextcCsF|j��rdSt|�}|dkr"dS|j�|�}|dkr:dS|��SdSr)rP�strip�_get_containing_elementrXr��isElementContent)rr�r�r
r
r
�!_get_isWhitespaceInElementContentss
z&Text._get_isWhitespaceInElementContent)rrr)r{r|r}r�r	rOrr�r�rQrrSrTrXr
r
r
r
r�*s
r�ZisWhitespaceInElementContentzKTrue iff this text node contains only whitespace and is in element content.Z	wholeTextz.The text of all logically-adjacent text nodes.cCs*|j}|dk	r&|jtjkr|S|j}qdSr%)r:rr	rS�rHrGr
r
r
rV�srVcCs*|j}|dk	r&|jtjkr|S|j}qdSr%)r:rr	r�rYr
r
r
r'�sr'c@s(eZdZejZdZdd�Zddd�ZdS)	�Commentz#commentcCst�|�||_dSr%)r9r�r:r=r
r
r
r��s
zComment.__init__rcCs,d|jkrtd��|�d||j|f�dS)Nz--z%'--' is not allowed in a comment nodez
%s<!--%s-->%s)rPr>r�r8r
r
r
r�s
zComment.writexmlN)rrr)	r{r|r}r	r�rr�r�rr
r
r
r
rZ�srZc@s$eZdZdZejZdZddd�ZdS)�CDATASectionr
z#cdata-sectionrcCs,|j�d�dkrtd��|�d|j�dS)Nz]]>rz$']]>' not allowed in a CDATA sectionz<![CDATA[%s]]>)rP�findr>r�r8r
r
r
r�szCDATASection.writexmlN)rrr)	r{r|r}r�r	r�rr�rr
r
r
r
r[�sr[c@szeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�ReadOnlySequentialNamedNodeMap��_seqr
cCs
||_dSr%r^)r�seqr
r
r
r��sz'ReadOnlySequentialNamedNodeMap.__init__cCs
t|j�Sr%�r�r_rr
r
r
r��sz&ReadOnlySequentialNamedNodeMap.__len__cCs
t|j�Sr%rarr
r
r
r��sz*ReadOnlySequentialNamedNodeMap._get_lengthcCs"|jD]}|j|kr|SqdSr%)r_r�r�r
r
r
r��s

z+ReadOnlySequentialNamedNodeMap.getNamedItemcCs,|jD] }|j|kr|j|kr|SqdSr%)r_r~r�r�r
r
r
r��s
z-ReadOnlySequentialNamedNodeMap.getNamedItemNScCs4t|t�r|j|�}n
|�|�}|dkr0t|��|Sr%)r�r3r�r�ri)rZ
name_or_tuplerHr
r
r
r��s

z*ReadOnlySequentialNamedNodeMap.__getitem__cCs4|dkrdSz|j|WStk
r.YdSXdSr+)r_r�r�r
r
r
r��sz#ReadOnlySequentialNamedNodeMap.itemcCstj�d��dS�Nz"NamedNodeMap instance is read-only�r6r7r(r�r
r
r
r��s�z.ReadOnlySequentialNamedNodeMap.removeNamedItemcCstj�d��dSrbrcr�r
r
r
r��s�z0ReadOnlySequentialNamedNodeMap.removeNamedItemNScCstj�d��dSrbrcr�r
r
r
r��s�z+ReadOnlySequentialNamedNodeMap.setNamedItemcCstj�d��dSrbrcr�r
r
r
r��s�z-ReadOnlySequentialNamedNodeMap.setNamedItemNScCs|jgSr%r^rr
r
r
r��sz+ReadOnlySequentialNamedNodeMap.__getstate__cCs|d|_dSr+r^r�r
r
r
r��sz+ReadOnlySequentialNamedNodeMap.__setstate__N)r
)r{r|r}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r
r
r
r
r]�s
	r]z&Number of entries in the NamedNodeMap.c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�
Identified��publicId�systemIdcCs||_||_dSr%re)rrfrgr
r
r
�_identified_mixin_init�sz!Identified._identified_mixin_initcCs|jSr%)rfrr
r
r
�
_get_publicId�szIdentified._get_publicIdcCs|jSr%)rgrr
r
r
�
_get_systemId�szIdentified._get_systemIdN)r{r|r}r�rhrirjr
r
r
r
rd�srdc@sHeZdZejZdZdZdZdZ	dZ
dd�Zdd�Zdd�Z
dd	d
�ZdS)�DocumentTypeNcCs2t�|_t�|_|r&t|�\}}||_|j|_dSr%)r]�entities�	notationsrr�r�)rrrrr
r
r
r�
szDocumentType.__init__cCs|jSr%)�internalSubsetrr
r
r
�_get_internalSubsetsz DocumentType._get_internalSubsetcCs�|jdkr�td�}|j|_|j|_tjjj}|r�g|j_	g|j
_	|j
j	D]2}t|j|j|j
�}|j
j	�|�|�|||�qH|jj	D]N}t|j|j|j
|j�}|j|_|j|_|j|_|jj	�|�|�|||�q�|�|||�|SdSdSr%)rXrkr�r�r6r7�UserDataHandler�NODE_CLONEDrlr_rm�NotationrfrgrRrv�Entity�notationName�actualEncodingrr_)rrY�clonertr��notation�e�entityr
r
r
rZs0

�zDocumentType.cloneNodercCs�|�d�|�|j�|jr8|�d||j||jf�n|jrR|�d||jf�|jdk	r||�d�|�|j�|�d�|�d|�dS)Nz
<!DOCTYPE z%s  PUBLIC '%s'%s  '%s'z%s  SYSTEM '%s'z [�]r�)r�r�rfrgrnr8r
r
r
r0s
�


zDocumentType.writexml)rrr)r{r|r}r	�DOCUMENT_TYPE_NODErr�r�rfrgrnr�rorZrr
r
r
r
rksrkc@sfeZdZdZejZdZdZdZ	dZ
dd�Zdd�Zdd�Z
dd	�Zd
d�Zdd
�Zdd�Zdd�ZdS)rsNcCs$||_||_t�|_|�||�dSr%)r�rtrwr'rh)rr�rfrgrwr
r
r
r�GszEntity.__init__cCs|jSr%�rurr
r
r
�_get_actualEncodingMszEntity._get_actualEncodingcCs|jSr%�rrr
r
r
�
_get_encodingPszEntity._get_encodingcCs|jSr%�r_rr
r
r
�_get_versionSszEntity._get_versioncCstj�d��dS)Nz(cannot append children to an entity node�r6r7r8)rrEr
r
r
r<Vs�zEntity.appendChildcCstj�d��dS)Nz+cannot insert children below an entity noder�r-r
r
r
r4Zs�zEntity.insertBeforecCstj�d��dS)Nz*cannot remove children from an entity noder�rNr
r
r
r;^s�zEntity.removeChildcCstj�d��dS)Nz)cannot replace children of an entity noder�r.r
r
r
rLbs�zEntity.replaceChild)r{r|r}r�r	ZENTITY_NODErr�rurr_r�r}rr�r<r4r;rLr
r
r
r
rs>srsc@seZdZejZdZdd�ZdS)rrNcCs||_|�||�dSr%)r�rh)rr�rfrgr
r
r
r�jszNotation.__init__)r{r|r}r	r�rr�r�r
r
r
r
rrfsrrc@sHeZdZddddddddgZd	d
�Zdd�Zd
d�Zdd�Zdd�ZdS)�DOMImplementation)�core�1.0)r��2.0)r�N)r6r�)r6r�)r6N)�ls-loadz3.0)r�NcCs|dkrd}|��|f|jkSr)�lower�	_featuresr]r
r
r
r\zszDOMImplementation.hasFeaturec	Cs�|r|jdk	rtj�d��|��}|dko8|dko8|dk}|sP|rPtj�d��|r�t|�\}}|dkr||dkr|tj�d��|r�|s�tj�d��|�||�}|r�|�	|�|�	|�|r�||_|_
||_||_|S)Nz(doctype object owned by another DOM treezElement with no namer6z$http://www.w3.org/XML/1998/namespacezillegal use of 'xml' prefixz(illegal use of prefix without namespaces)
r:r6r7�WrongDocumentErr�_create_documentZInvalidCharacterErrrr��createElementNSr<rX�doctyper[)	rr~rr�r�Zadd_root_elementrrr)r
r
r
�createDocuments>���
��

z DOMImplementation.createDocumentcCst|�}||_||_|Sr%)rkrfrg)rrrfrgr�r
r
r
�createDocumentType�sz$DOMImplementation.createDocumentTypecCs|�|d�r|SdSdSr%)r\rer
r
r
rf�szDOMImplementation.getInterfacecCst�Sr%)�Documentrr
r
r
r��sz"DOMImplementation._create_documentN)	r{r|r}r�r\r�r�rfr�r
r
r
r
r�os�
-r�c@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�ElementInforcCs
||_dSr%rr�r
r
r
r��szElementInfo.__init__cCstSr%�r��rZanamer
r
r
r��szElementInfo.getAttributeTypecCstSr%r�r�r
r
r
r��szElementInfo.getAttributeTypeNScCsdSrr
rr
r
r
rW�szElementInfo.isElementContentcCsdSrr
rr
r
r
�isEmpty�szElementInfo.isEmptycCsdSrr
r�r
r
r
r��szElementInfo.isIdcCsdSrr
r�r
r
r
r��szElementInfo.isIdNScCs|jSr%rrr
r
r
r��szElementInfo.__getstate__cCs
||_dSr%rr�r
r
r
r��szElementInfo.__setstate__N)
r{r|r}r�r�r�r�rWr�r�r�r�r�r
r
r
r
r��s	r�cCs>|jtjkr|j��d|_nt|�r:|jj��d|j_dSr%)rr	r�	_id_cache�clear�_id_search_stackr�rXr�r
r
r
rA�s
rAc@sreZdZdZejejejejfZ	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�rwr'r�r�r�rr
r
r
r�s
zDocument.__init__cCs&|jr|j|jf}n|j}|j�|�Sr%)r~r�r�r�r�)rr)rkr
r
r
r�szDocument._get_elem_infocCs|jSr%r|rr
r
r
r}szDocument._get_actualEncodingcCs|jSr%)r�rr
r
r
�_get_doctypeszDocument._get_doctypecCs|jSr%)�documentURIrr
r
r
�_get_documentURI!szDocument._get_documentURIcCs|jSr%r~rr
r
r
r$szDocument._get_encodingcCs|jSr%)�errorHandlerrr
r
r
�_get_errorHandler'szDocument._get_errorHandlercCs|jSr%)�
standalonerr
r
r
�_get_standalone*szDocument._get_standalonecCs|jSr%)�strictErrorCheckingrr
r
r
�_get_strictErrorChecking-sz!Document._get_strictErrorCheckingcCs|jSr%r�rr
r
r
r�0szDocument._get_versioncCsj|j|jkr(tj�dt|�t|�f��|jdk	r>|j�|�|jtj	kr^|�
�r^tj�d��t�||�S)Nr0z two document elements disallowed)rr5r6r7r8r9r:r;r	rS�_get_documentElementr<r�r
r
r
r<3s�
��zDocument.appendChildcCsVz|j�|�Wntk
r.tj���YnXd|_|_d|_|j	|krRd|_	|Sr%)
r'rMr>r6r7r?rCrDr:�documentElementrNr
r
r
r;Cs
zDocument.removeChildcCs$|jD]}|jtjkr|SqdSr%)r'rr	rSr�r
r
r
r�Os
zDocument._get_documentElementcCs(|jdk	r|j��d|_t�|�dSr%)r�rQr	rr
r
r
rQTs

zDocument.unlinkcCs�|sdS|j�ddd�}|j|_|j|_|j|_|jD]B}t|||�}|j�|�|jt	j
kr`n|jt	jkrr||_||_
q6|�tjjj||�|Sr%)r[r�rr�r_r'rWrRrr	rr{r�r:rvr6r7rprq)rrYrvr�Z
childcloner
r
r
rZZs&
�zDocument.cloneNodecCst�}||_|Sr%)r�rX)rror
r
r
�createDocumentFragmentoszDocument.createDocumentFragmentcCst|�}||_|Sr%)rrX)rr�rxr
r
r
�
createElementtszDocument.createElementcCs(t|t�std��t�}||_||_|S�Nznode contents must be a string)r�r�r�r�rPrX)rrP�tr
r
r
�createTextNodeys
zDocument.createTextNodecCs(t|t�std��t�}||_||_|Sr�)r�r�r�r[rPrX�rrPrGr
r
r
�createCDATASection�s
zDocument.createCDATASectioncCst|�}||_|Sr%)rZrXr�r
r
r
�
createComment�szDocument.createCommentcCst||�}||_|Sr%)r/rX)rr1rP�pr
r
r
�createProcessingInstruction�s
z$Document.createProcessingInstructioncCst|�}||_d|_|Sr)r�rXr�)rr��ar
r
r
�createAttribute�szDocument.createAttributecCs"t|�\}}t|||�}||_|Sr%)rrrX)rr~rrr�rxr
r
r
r��szDocument.createElementNScCs*t|�\}}t||||�}||_d|_|Sr)rr�rXr�)rr~rrr�r�r
r
r
�createAttributeNS�s
zDocument.createAttributeNScCst||||�}||_|Sr%)rsrX)rr�rfrgrtrxr
r
r
�_create_entity�szDocument._create_entitycCst|||�}||_|Sr%)rrrX)rr�rfrgr�r
r
r
�_create_notation�szDocument._create_notationcCs�||jkr|j|S|js$|js$dS|j}|dkrB|jg}||_n|sJdSd}|�r�|��}|�dd�|jD��|�|�}|�rB|j	�
�D]�}|jr�|�|j|j
�r�||j|j<|j|kr�|}n|js��q�q�|�|j��r
||j|j<|j|kr�|}n|j�s>�q�q�|jr�||j|j<|j|k�r.|}q�|jdkr��q�q�n>|j�r�|j	�
�D]*}|j�rT||j|j<|j|k�rT|}�qT|dk	rN�q�qN|S)NcSsg|]}|jtkr|�qSr
)rr@)�.0rVr
r
r
�
<listcomp>�s
�z+Document.getElementById.<locals>.<listcomp>r1)r�r�r�r�r��pop�extendr'r�r�r�r~r�r�r�r�r�r�r�)rr��stack�resultrHr�rr
r
r
�getElementById�sZ






zDocument.getElementByIdcCst||t��Sr%rr�r
r
r
r�szDocument.getElementsByTagNamecCst|||t��Sr%rr�r
r
r
r�s�zDocument.getElementsByTagNameNScCs|j�||�Sr%)r[r\r]r
r
r
r`�szDocument.isSupportedcCs>|jtjkrtj�d��n|jtjkr2tj�d��t|||�S)Nzcannot import document nodesz!cannot import document type nodes)rr	rr6r7�NotSupportedErrr{rW)rrHrYr
r
r
�
importNode�s
zDocument.importNodercCsJ|dkr|�d|�n|�d||f�|jD]}|�||||�q0dS)Nz<?xml version="1.0" ?>z%<?xml version="1.0" encoding="%s"?>%s)r�r'r)rr$r"r!r#rrHr
r
r
r�s�
zDocument.writexmlcCsJ|j|k	r tj�d||jf��|jtjtjfkr>tj�d��|t	kr�d|kr�|�
dd�\}}|dkr�|tjjkr�tj�d��q�|dkr�|tjjkr�|jtjkr�tj�d��d}|}nd}d}|jtjkr�|j
}|dk	r�|j}|�|�nd}||_||_||_||_|jtjk�r||_n*||_|dk	�rF|�|�|�rF|�|�|S)Nz?cannot rename nodes from other documents;
expected %s,
found %sz8renameNode() only applies to element and attribute nodesr�r1r�zillegal use of 'xmlns' prefixz$illegal use of the 'xmlns' attribute)rXr6r7r�rr	rSr�r�rr�rr�r�r�rrr�r~r�r�r�rr#)rr�r~r�rr�r)Zis_idr
r
r
�
renameNode	sb
���
��
�
��


zDocument.renameNode)rrrN)=r{r|r}r�r	rSr�r�r{r5r�r[rrr�r�r�r:rDrCrurr�r_r�r�r�r�r�r�r}r�r�rr�r�r�r�r<r;r�rQrZr�r�r�r�r�r�r�r�r�r�r�r�rrr`r�rr�r
r
r
r
r��sj�	
:
r�r�z#Top-level element of this document.c
Cs�|j�|�rtjjj}n
tjjj}|jtj	kr�|�
|j|j�}|j
��D]0}|�|j|j|j�|�|j|j�}|j|_qH|r�|jD]}t|||�}|�|�q��n|jtjkr�|��}|r�|jD]}t|||�}|�|�qn�|jtjkr�|�|j�}�n�|jtjk�r|�|j�}�n�|jtjk�r>|�|j |j�}�nj|jtj!k�r\|�"|j�}�nL|jtj#k�r�|�$|j|j�}d|_|j|_�n|jtj%k�r�tjjj}|j&�'|j(|j)|j*�}||_|�r�g|j+_,g|j-_,|j-j,D]F}	t.|	j|	j)|	j*�}
||
_|j-j,�/|
�t0|	d��r�|	�1||	|
��q�|j+j,D]b}t2|j|j)|j*|j3�}|j4|_4|j5|_5|j6|_6||_|j+j,�/|�t0|d��r.|�1|||��q.ntj�7dt8|���t0|d��r�|�1|||�|S)NTrvzCannot clone node %s)9rXrdr6r7rprqZ
NODE_IMPORTEDrr	rSr�r~r�r�r�rr�rr�r�r'rWr<r2r�rOr�rPr�r�r�r�r1r�r�r�r�r{r[r�r�rfrgrlr_rmrrrRrqrvrsrtrurr_r�r9)
rHrYZnewOwnerDocumentrtrvrr�rVrGr�rwrxryr
r
r
rWBs�
�


��
��rWcCs,|�dd�}t|�dkr|Sd|dfSdS)Nr�r1�r)r�r�)rZfieldsr
r
r
r�srcCs,|||�}|��\}}|�|�|��|Sr%)ZgetEventZ
expandNoder�)�func�args�kwargsZeventsZtoktypeZrootNoder
r
r
�_do_pulldom_parse�s


r�cCsH|dkr"|s"ddlm}|�|�Sddlm}t|j|f||d��SdS)Nr��expatbuilder��pulldom)�parser�bufsize)�xml.domr��parser�r�)�filer�r�r�r�r
r
r
r��s

�r�cCsB|dkrddlm}|�|�Sddlm}t|j|fd|i�SdS)Nrr�r�r�)r�r��parseStringr�r�)�stringr�r�r�r
r
r
r��s

�r�cCs@|r:t|t�rt�|�}|D]\}}tj�||�sdSqtjSr%)r�r�rZ_parse_feature_stringr�r[r\)Zfeatures�f�vr
r
r
�getDOMImplementation�s

r�)NN)N)N)6rr�r6rrrrZxml.dom.minicompatZxml.dom.xmlbuilderrrr7r	rSr�r@ZdefpropertyrJr�r�r�r�r�r��objectr�Z
AttributeListr�r�rrr*r/r9r�rVr'rZr[r]rdrkrsrrr�r�rAr�rWrr�r�r�r�r
r
r
r
�<module>s��v
	y$�
x��)GU��	>�<(	O*P�R




?>