AlkantarClanX12

Your IP : 3.135.184.195


Current Path : /opt/alt/python37/lib64/python3.7/xml/dom/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/xml/dom/__pycache__/minidom.cpython-37.pyc

B

� 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�Z5dgdcdd�Z6dS)hacSimple 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�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
�4/opt/alt/python37/lib64/python3.7/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�
childNodes)rr
r
r�
hasChildNodesCszNode.hasChildNodescCs|jS)N)r$)rr
r
r�_get_childNodesFszNode._get_childNodescCs|jr|jdSdS)Nr)r$)rr
r
r�_get_firstChildIszNode._get_firstChildcCs|jr|jdSdS)N���)r$)rr
r
r�_get_lastChildMszNode._get_lastChildcCs|j|jkr0xt|j�D]}|�||�qW|S|j|jkrXtj�dt	|�t	|�f��|j
dk	rn|j
�|�|dkr�|�|�n�y|j�
|�}Wntk
r�tj���YnX|jtkr�t|�|j�||�||_||_|r�|j|d}||_||_nd|_||_
|S)Nz%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�cr6�noder
r
rr-Qs6

zNode.insertBeforecCs�|j|jkr.xt|j�D]}|�|�qW|S|j|jkrXtj�dt	|�t	|�f��n|jt
krjt|�|jdk	r�|j�
|�t||�d|_|S)Nz%s cannot be child of %s)rr+r,r$r5r.r/r0r1r2r9r:r3r4�
_append_childr<)rrAr@r
r
rr5qs


zNode.appendChildcCs|j|jkr(|j}|�|�|�||�S|j|jkrPtj�dt	|�t	|�f��||kr\dS|j
dk	rr|j
�|�y|j�|�}Wnt
k
r�tj���YnX||j|<||_
d|_
|jtks�|jtkr�t|�|j|_|j|_d|_d|_|jr�||j_|j�r||j_|S)Nz%s cannot be child of %s)rr+r<r4r-r.r/r0r1r2r3r$r6r7r8r9r:r=)rr>�oldChildr?r6r
r
r�replaceChild�s<




zNode.replaceChildcCs�y|j�|�Wntk
r.tj���YnX|jdk	rD|j|j_|jdk	rX|j|j_d|_|_|jt	krvt
|�d|_|S)N)r$�remover7r/r0r8r<r=rr9r:r3)rrCr
r
rr4�s




zNode.removeChildcCs�g}x�|jD]�}|jtjkr�|jsL|r2|j|d_|jrB|j|j_|��q�|r�|dj|jkr�|d}|j|j|_|j|_|jr�||j_|��q�|�|�q|�|�|jtj	kr|�
�qW||jdd�<dS)Nr()r$rr	�	TEXT_NODE�datar<r=�unlink�append�ELEMENT_NODE�	normalize)r�L�childrAr
r
rrK�s*



zNode.normalizecCst|||jp|�S)N)�_clone_node�
ownerDocument)r�deepr
r
r�	cloneNode�szNode.cloneNodecCs|jj�||�S)N)rO�implementation�
hasFeature)r�feature�versionr
r
r�isSupported�szNode.isSupportedcCsdS)Nr
)rr
r
r�_get_localName�szNode._get_localNamecCs||kS)Nr
)r�otherr
r
r�
isSameNode�szNode.isSameNodecCs|�|d�r|SdSdS)N)rV)rrTr
r
r�getInterface�szNode.getInterfacec	Cs,y|j|dSttfk
r&dSXdS)Nr)�
_user_data�AttributeError�KeyError)r�keyr
r
r�getUserData�szNode.getUserDatacCsnd}y
|j}Wntk
r,i}||_YnX||krB||d}|dkr^d}|dk	rj||=n||f||<|S)Nr)r[r\)rr^rG�handler�old�dr
r
r�setUserData�s
zNode.setUserDatacCsHt|d�rDx8t|j���D]&\}\}}|dk	r|�|||||�qWdS)Nr[)�hasattr�listr[�itemsZhandle)r�	operation�src�dstr^rGr`r
r
r�_call_user_data_handler�s
zNode._call_user_data_handlercCsBd|_|_|jr2x|jD]}|��qWt�|_d|_d|_dS)N)r3rOr$rH�NodeListr=r<)rrMr
r
rrHszNode.unlinkcCs|S)Nr
)rr
r
r�	__enter__szNode.__enter__cCs|��dS)N)rH)rZetZev�tbr
r
r�__exit__sz
Node.__exit__)N)rrN)!�__name__�
__module__�__qualname__�namespaceURIr3rOr<r=r�prefixr
rrr%r&r'r)r-r5rDr4rKrQrVrWrYrZr_rcrjrHrlrnr
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}||_||_|�|�||_dS)Nr()r$r=r<rIr3)rrAr$Zlastr
r
rrBs
rBcCs(x"|dk	r"|jtjkrdS|j}qWdS)NTF)rr	rr3)rAr
r
r�_in_document&s


rxcCs6|r2|�dd��dd��dd��dd�}|�|�d	S)
zWrites datachars to writer.�&z&amp;�<z&lt;�"z&quot;�>z&gt;N)�replace�write)r"rGr
r
r�_write_data.srcCsHxB|jD]8}|jtjkr4|dks*|j|kr4|�|�t|||�qW|S)Nr)r$rr	rJ�tagNamerI�_get_elements_by_tagName_helper)�parent�name�rcrAr
r
rr�5s
r�cCs\xV|jD]L}|jtjkr|dks*|j|krF|dks<|j|krF|�|�t||||�qW|S)Nr)r$rr	rJrwrrrI�"_get_elements_by_tagName_ns_helper)r�ZnsURIrwr�rAr
r
rr�=s
r�c@sJeZdZejZdZdZdZdZ	ej
ejejej
ejejejfZdd�ZdS)�DocumentFragmentz#document-fragmentNcCst�|_dS)N)rkr$)rr
r
r�__init__TszDocumentFragment.__init__)rorprqr	r+r�nodeName�	nodeValue�
attributesr3rJrF�CDATA_SECTION_NODE�ENTITY_REFERENCE_NODE�PROCESSING_INSTRUCTION_NODE�COMMENT_NODE�
NOTATION_NODEr.r�r
r
r
rr�Fsr�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�_valuerr�_prefixr$�
_localNamerO�ownerElementNFcCs2d|_||_||_||_t�|_|j�t��dS)N)r�r�rrr�rkr$rI�Text)r�qNamerrrwrsr
r
rr�bsz
Attr.__init__cCs.y|jStk
r(|j�dd�dSXdS)N�:r*r()r�r\r��split)rr
r
rrWoszAttr._get_localNamecCs|jS)N)�	specified)rr
r
r�_get_specifieduszAttr._get_specifiedcCs|jS)N)r�)rr
r
r�	_get_namexszAttr._get_namecCs||_|jdk	rt|j�dS)N)r�r�r:)r�valuer
r
r�	_set_name{s
zAttr._set_namecCs|jS)N)r�)rr
r
r�
_get_value�szAttr._get_valuecCs6||_||jd_|jdk	r&t|j�||jd_dS)Nr)r�r$rGr�r:)rr�r
r
r�
_set_value�s


zAttr._set_valuecCs|jS)N)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)
rrrr/r0�NamespaceErrr�rwr�r:r�)rrsZnsuriZnewNamer
r
r�_set_prefix�s
zAttr._set_prefixcCsz|j}|dk	rR|j|j=|j|j|jf=|jrRd|_|jd8_|jj	d8_	x|j
D]}|��qZW|j
dd�=dS)NFr*)r��_attrsr��_attrsNSrrrw�_is_id�_magic_id_nodesrO�_magic_id_countr$rH)r�elemrMr
r
rrH�s
zAttr.unlinkcCsf|jr
dS|j}|j}|dks&|dkr*dS|�|�}|dkr@dS|jrV|�|j|j�S|�|j�SdS)NTF)	r�rOr��_get_elem_inforr�isIdNSrw�isIdr�)rrur��infor
r
r�	_get_isId�s
zAttr._get_isIdcCs\|j}|j}|dks|dkr tS|�|�}|dkr6tS|jrL|�|j|j�S|�|j�SdS)N)	rOr��_no_typer�rr�getAttributeTypeNSrw�getAttributeTyper�)rrur�r�r
r
r�_get_schemaType�s
zAttr._get_schemaType) rorprq�	__slots__r	�ATTRIBUTE_NODErr�r�r�rFr�r.rr�rWr�r�r��propertyr�r�r�r�r�r�r�r�rsrHr�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�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||_||_||_dS)N)r�r�r�)r�attrsZattrsNSr�r
r
rr��szNamedNodeMap.__init__cCs
t|j�S)N)�lenr�)rr
r
r�_get_length�szNamedNodeMap._get_lengthcCs0y|t|j���|Stk
r*dSXdS)N)rer��keys�
IndexError)rr6r
r
r�item�szNamedNodeMap.itemcCs.g}x$|j��D]}|�|j|jf�qW|S)N)r��valuesrIr�r�)rrLrAr
r
rrf�szNamedNodeMap.itemscCs4g}x*|j��D]}|�|j|jf|jf�qW|S)N)r�r�rIrrrwr�)rrLrAr
r
r�itemsNS�szNamedNodeMap.itemsNScCs"t|t�r||jkS||jkSdS)N)�
isinstance�strr�r�)rr^r
r
r�__contains__�s

zNamedNodeMap.__contains__cCs
|j��S)N)r�r�)rr
r
rr�szNamedNodeMap.keyscCs
|j��S)N)r�r�)rr
r
r�keysNSszNamedNodeMap.keysNScCs
|j��S)N)r�r�)rr
r
rr�szNamedNodeMap.valuesNcCs|j�||�S)N)r��get)rr�r�r
r
rr�
szNamedNodeMap.getcCs:|jt|dd�krdSt|�t|�kt|�t|�kSdS)Nr�r)r��getattr�id)rrXr
r
r�_cmpszNamedNodeMap._cmpcCs|�|�dkS)Nr)r�)rrXr
r
r�__eq__szNamedNodeMap.__eq__cCs|�|�dkS)Nr)r�)rrXr
r
r�__ge__szNamedNodeMap.__ge__cCs|�|�dkS)Nr)r�)rrXr
r
r�__gt__szNamedNodeMap.__gt__cCs|�|�dkS)Nr)r�)rrXr
r
r�__le__szNamedNodeMap.__le__cCs|�|�dkS)Nr)r�)rrXr
r
r�__lt__!szNamedNodeMap.__lt__cCs"t|t�r|j|S|j|SdS)N)r�r,r�r�)r�attname_or_tupler
r
r�__getitem__$s

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


zNamedNodeMap.__setitem__cCs$y
|j|Stk
rdSXdS)N)r�r])rr�r
r
r�getNamedItem:s
zNamedNodeMap.getNamedItemcCs(y|j||fStk
r"dSXdS)N)r�r])rrrrwr
r
r�getNamedItemNS@szNamedNodeMap.getNamedItemNScCsX|�|�}|dk	rJt|j�|j|j=|j|j|jf=t|d�rFd|_	|St
j���dS)Nr�)
r�r:r�r�r�r�rrrwrdr�r/r0r8)rr��nr
r
r�removeNamedItemFs



zNamedNodeMap.removeNamedItemcCsZ|�||�}|dk	rLt|j�|j|j|jf=|j|j=t|d�rHd|_	|St
j���dS)Nr�)
r�r:r�r�rrrwr�r�rdr�r/r0r8)rrrrwr�r
r
r�removeNamedItemNSRs


zNamedNodeMap.removeNamedItemNScCstt|t�s&tj�dt|�t|�f��|j�|j�}|r@|�	�||j|j<||j
|j|jf<|j
|_t|j�|S)Nz%s cannot be child of %s)r�r�r/r0r1r2r�r�r�rHr�rrrwr�r�r:)rrArar
r
rr�^s

zNamedNodeMap.setNamedItemcCs
|�|�S)N)r�)rrAr
r
r�setNamedItemNSkszNamedNodeMap.setNamedItemNScCs||}t|j�|��dS)N)r:r�rH)rr�rAr
r
r�__delitem__ns
zNamedNodeMap.__delitem__cCs|j|j|jfS)N)r�r�r�)rr
r
r�__getstate__sszNamedNodeMap.__getstate__cCs|\|_|_|_dS)N)r�r�r�)r�stater
r
r�__setstate__vszNamedNodeMap.__setstate__)N)!rorprq�__doc__r�r�r�r�rfr�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��lengthz$Number of nodes in the NamedNodeMap.c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�TypeInfo)�	namespacer�cCs||_||_dS)N)r�r�)rr�r�r
r
rr��szTypeInfo.__init__cCs2|jrd|jj|j|jfSd|jj|jfSdS)Nz<%s %r (from %r)>z<%s %r>)r��	__class__ror�)rr
r
r�__repr__�s
zTypeInfo.__repr__cCs|jS)N)r�)rr
r
rr��szTypeInfo._get_namecCs|jS)N)r�)rr
r
r�_get_namespace�szTypeInfo._get_namespaceN)rorprqr�r�r�r�r�r
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)rOr3r�r�rsrrr�r$r�r�r<r=NrcCsBd|_||_|_||_||_t�|_d|_|_d|_	d|_
dS)N)r3r�r�rsrrrkr$r<r=r�r�)rr�rrrsrwr
r
rr��s
zElement.__init__cCs|jdkri|_i|_dS)N)r�r�)rr
r
r�_ensure_attributes�s
zElement._ensure_attributescCs.y|jStk
r(|j�dd�dSXdS)Nr�r*r()r�r\r�r�)rr
r
rrW�szElement._get_localNamecCs|jS)N)r�)rr
r
r�_get_tagName�szElement._get_tagNamecCsD|jdk	r*xt|j���D]}|��qWd|_d|_t�|�dS)N)r�rer�rHr�r	)r�attrr
r
rrH�s
zElement.unlinkcCs4|jdkrdSy|j|jStk
r.dSXdS)Nr)r�r�r])rr�r
r
r�getAttribute�s
zElement.getAttributecCs8|jdkrdSy|j||fjStk
r2dSXdS)Nr)r�r�r])rrrrwr
r
r�getAttributeNS�s
zElement.getAttributeNScCsV|�|�}|dkr4t|�}||_|j|_|�|�n||jkrR||_|jrRt|�dS)N)�getAttributeNoder�r�rO�setAttributeNoder�r:)rr�r�r�r
r
r�setAttribute�s

zElement.setAttributecCs�t|�\}}|�||�}|dkrHt||||�}||_|j|_|�|�n4||jkrf||_|jrft|�|j|kr|||_||_	dS)N)
�_nssplit�getAttributeNodeNSr�r�rOr�r�r:rsr�)rrr�
qualifiedNamer�rs�	localnamer�r
r
r�setAttributeNS�s

zElement.setAttributeNScCs|jdkrdS|j�|�S)N)r�r�)rZattrnamer
r
rr��s
zElement.getAttributeNodecCs|jdkrdS|j�||f�S)N)r�r�)rrrrwr
r
rr�s
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�r/r0ZInuseAttributeErrr�r�r�r��removeAttributeNoder�rrrw�_set_attribute_node)rr�Zold1Zold2r
r
rr�s


zElement.setAttributeNodecCsP|jdkrtj���y|j|}Wntk
r@tj���YnX|�|�dS)N)r�r/r0r8r�r]r�)rr�r�r
r
r�removeAttributes

zElement.removeAttributecCsT|jdkrtj���y|j||f}Wntk
rDtj���YnX|�|�dS)N)r�r/r0r8r]r�)rrrrwr�r
r
r�removeAttributeNS%s

zElement.removeAttributeNScCs^|dkrtj���y|j|jWntk
r@tj���YnXt|�|��|j|_dS)N)	r/r0r8r�r�r]r:rHrO)rrAr
r
rr�.s
zElement.removeAttributeNodecCs|jdkrdS||jkS)NF)r�)rr�r
r
r�hasAttribute=s
zElement.hasAttributecCs|jdkrdS||f|jkS)NF)r�)rrrrwr
r
r�hasAttributeNSBs
zElement.hasAttributeNScCst||t��S)N)r�rk)rr�r
r
r�getElementsByTagNameGszElement.getElementsByTagNamecCst|||t��S)N)r�rk)rrrrwr
r
r�getElementsByTagNameNSJszElement.getElementsByTagNameNScCsd|jt|�fS)Nz<DOM Element: %s at %#x>)r�r�)rr
r
rr�NszElement.__repr__rc	Cs|�|d|j�|��}t|���}x4|D],}|�d|�t|||j�|�d�q.W|jr�|�d�t|j�dkr�|jdj	t
jkr�|jd�|ddd�n8|�|�x"|jD]}|�|||||�q�W|�|�|�d|j|f�n|�d	|�dS)
Nrzz %s="r{r|r*rrz</%s>%sz/>%s)
r~r��_get_attributes�sortedr�rr�r$r�rr	rFr)	rr"r �	addindentr!r�Za_namesZa_namerAr
r
rrQs$



zElement.writexmlcCs|��t|j|j|�S)N)r�r�r�r�)rr
r
rr�lszElement._get_attributescCs|jr
dSdSdS)NTF)r�)rr
r
r�
hasAttributespszElement.hasAttributescCs|�|�}|�|�dS)N)r��setIdAttributeNode)rr��idAttrr
r
r�setIdAttributexs
zElement.setIdAttributecCs|�||�}|�|�dS)N)r�r)rrrrwrr
r
r�setIdAttributeNS|szElement.setIdAttributeNScCsj|dks|�|j�stj���t|�dk	r4tj���|jsfd|_|jd7_|j	j
d7_
t|�dS)NTr*)rYr�r/r0r8�_get_containing_entref�NoModificationAllowedErrr�r�rOr�r:)rrr
r
rr�s

zElement.setIdAttributeNode)rrr).rorprqr�r	rJrr�r�r�r�r�r�rFr�r�r.rr�r�rWr�rHr�r�r�r�r�r�r�ZsetAttributeNodeNSr�r�r�ZremoveAttributeNodeNSr�r�r�r�r�rr�rrrrr
r
r
rr��sP		

r�r�z*NamedNodeMap of attributes on the element.z%Namespace-local name of this element.cCs8t|�|��||j|j<||j|j|jf<||_dS)N)r:r�r�r�r�rrrwr�)�elementr�r
r
rr��s
r�c@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.
    r
NcCsdS)Nr
)rr
r
rr'�szChildless._get_firstChildcCsdS)Nr
)rr
r
rr)�szChildless._get_lastChildcCstj�|jd��dS)Nz nodes cannot have children)r/r0r1r�)rrAr
r
rr5�szChildless.appendChildcCsdS)NFr
)rr
r
rr%�szChildless.hasChildNodescCstj�|jd��dS)Nz nodes do not have children)r/r0r1r�)rr>r?r
r
rr-�szChildless.insertBeforecCstj�|jd��dS)Nz nodes do not have children)r/r0r8r�)rrCr
r
rr4�szChildless.removeChildcCsdS)Nr
)rr
r
rrK�szChildless.normalizecCstj�|jd��dS)Nz nodes do not have children)r/r0r1r�)rr>rCr
r
rrD�szChildless.replaceChild)rorprqr�r�r�Z
EmptyNodeListr$rtrvr'r)r5r%r-r4rKrDr
r
r
rr�src@s\eZdZejZdZdd�Zdd�Zdd�Z	e
ee	�Zdd	�Zd
d�Z
e
ee
�Zdd
d�ZdS)�ProcessingInstruction)�targetrGcCs||_||_dS)N)r
rG)rr
rGr
r
rr��szProcessingInstruction.__init__cCs|jS)N)rG)rr
r
r�_get_nodeValue�sz$ProcessingInstruction._get_nodeValuecCs
||_dS)N)rG)rr�r
r
r�_set_nodeValue�sz$ProcessingInstruction._set_nodeValuecCs|jS)N)r
)rr
r
r�
_get_nodeName�sz#ProcessingInstruction._get_nodeNamecCs
||_dS)N)r
)rr�r
r
r�
_set_nodeName�sz#ProcessingInstruction._set_nodeNamercCs|�d||j|j|f�dS)Nz
%s<?%s %s?>%s)r~r
rG)rr"r r�r!r
r
rr�szProcessingInstruction.writexmlN)rrr)rorprqr	r�rr�r�rrr�r�r
rr�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)�_datarOr3r=r<cCs,d|_|_d|_|_d|_t�|�dS)Nr)rOr3r=r<rr	r�)rr
r
rr��szCharacterData.__init__cCs
t|j�S)N)r�rG)rr
r
rr��szCharacterData._get_lengthcCs|jS)N)r)rr
r
r�	_get_data�szCharacterData._get_datacCs
||_dS)N)r)rrGr
r
r�	_set_data�szCharacterData._set_datacCs6|j}t|�dkrd}nd}d|jj|dd�|fS)N�
z...rz<DOM %s node "%r%s">r)rGr�r�ro)rrGZ	dotdotdotr
r
rr��szCharacterData.__repr__cCsT|dkrtj�d��|t|j�kr.tj�d��|dkrBtj�d��|j|||�S)Nrzoffset cannot be negativez#offset cannot be beyond end of datazcount cannot be negative)r/r0�IndexSizeErrr�rG)r�offset�countr
r
r�
substringData�szCharacterData.substringDatacCs|j||_dS)N)rG)r�argr
r
r�
appendDataszCharacterData.appendDatacCsZ|dkrtj�d��|t|j�kr.tj�d��|rVd|jd|�||j|d�f|_dS)Nrzoffset cannot be negativez#offset cannot be beyond end of dataz%s%s%s)r/r0rr�rG)rrrr
r
r�
insertDataszCharacterData.insertDatacCsl|dkrtj�d��|t|j�kr.tj�d��|dkrBtj�d��|rh|jd|�|j||d�|_dS)Nrzoffset cannot be negativez#offset cannot be beyond end of datazcount cannot be negative)r/r0rr�rG)rrrr
r
r�
deleteDataszCharacterData.deleteDatacCsr|dkrtj�d��|t|j�kr.tj�d��|dkrBtj�d��|rnd|jd|�||j||d�f|_dS)Nrzoffset cannot be negativez#offset cannot be beyond end of datazcount cannot be negativez%s%s%s)r/r0rr�rG)rrrrr
r
r�replaceDataszCharacterData.replaceDataN)rorprqr�r�r�r�rrr�rGr�r�rrrrrr
r
r
rr�s			
rzLength 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�rGr/r0rr�rOr<r3r$r5r-)rrZnewText�nextr
r
r�	splitText0szText.splitTextrcCst|d||j|f�dS)Nz%s%s%s)rrG)rr"r r�r!r
r
rr?sz
Text.writexmlcCs�|jg}|j}x6|dk	rD|jtjtjfkr@|�d|j�|j}qPqW|j}x4|dk	r�|jtjtjfkr||�|j�|j}qNPqNWd�	|�S)Nrr)
rGr=rr	rFr�r;r<rI�join)rrLr�r
r
r�_get_wholeTextDs

zText._get_wholeTextcCs�|j}|j}x6|dk	rB|jtjtjfkr>|j}|�|�|}qPqW|j}|sX|�|�x6|dk	r�|jtjtjfkr�|j}|�|�|}qZPqZW|r�||_|SdSdS)N)	r3r=rr	rFr�r4r<rG)rZcontentr�r�rr
r
r�replaceWholeTextVs*




zText.replaceWholeTextcCsF|j��rdSt|�}|dkr"dS|j�|�}|dkr:dS|��SdS)NF)rG�strip�_get_containing_elementrOr��isElementContent)rr�r�r
r
r�!_get_isWhitespaceInElementContentrs
z&Text._get_isWhitespaceInElementContent)rrr)rorprqr�r	rFrr�r�rrr r!r%r
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}x"|dk	r(|jtjkr |S|j}qWdS)N)r3rr	rJ)rAr@r
r
rr#�s

r#cCs.|j}x"|dk	r(|jtjkr |S|j}qWdS)N)r3rr	r�)rAr@r
r
rr�s

rc@s(eZdZejZdZdd�Zddd�ZdS)	�Commentz#commentcCst�|�||_dS)N)rr�r)rrGr
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)rGr7r~)rr"r r�r!r
r
rr�s
zComment.writexmlN)rrr)	rorprqr	r�rr�r�rr
r
r
rr&�sr&c@s$eZdZdZejZdZddd�ZdS)�CDATASectionr
z#cdata-sectionrcCs,|j�d�dkrtd��|�d|j�dS)Nz]]>rz$']]>' not allowed in a CDATA sectionz<![CDATA[%s]]>)rG�findr7r~)rr"r r�r!r
r
rr�szCDATASection.writexmlN)rrr)	rorprqr�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
||_dS)N)r*)r�seqr
r
rr��sz'ReadOnlySequentialNamedNodeMap.__init__cCs
t|j�S)N)r�r*)rr
r
rr��sz&ReadOnlySequentialNamedNodeMap.__len__cCs
t|j�S)N)r�r*)rr
r
rr��sz*ReadOnlySequentialNamedNodeMap._get_lengthcCs"x|jD]}|j|kr|SqWdS)N)r*r�)rr�r�r
r
rr��s
z+ReadOnlySequentialNamedNodeMap.getNamedItemcCs,x&|jD]}|j|kr|j|kr|SqWdS)N)r*rrrw)rrrrwr�r
r
rr��sz-ReadOnlySequentialNamedNodeMap.getNamedItemNScCs4t|t�r|j|�}n
|�|�}|dkr0t|��|S)N)r�r,r�r�r])rZ
name_or_tuplerAr
r
rr��s

z*ReadOnlySequentialNamedNodeMap.__getitem__cCs0|dkrdSy
|j|Stk
r*dSXdS)Nr)r*r�)rr6r
r
rr��s
z#ReadOnlySequentialNamedNodeMap.itemcCstj�d��dS)Nz"NamedNodeMap instance is read-only)r/r0r)rr�r
r
rr��sz.ReadOnlySequentialNamedNodeMap.removeNamedItemcCstj�d��dS)Nz"NamedNodeMap instance is read-only)r/r0r)rrrrwr
r
rr��sz0ReadOnlySequentialNamedNodeMap.removeNamedItemNScCstj�d��dS)Nz"NamedNodeMap instance is read-only)r/r0r)rrAr
r
rr��sz+ReadOnlySequentialNamedNodeMap.setNamedItemcCstj�d��dS)Nz"NamedNodeMap instance is read-only)r/r0r)rrAr
r
rr��sz-ReadOnlySequentialNamedNodeMap.setNamedItemNScCs|jgS)N)r*)rr
r
rr��sz+ReadOnlySequentialNamedNodeMap.__getstate__cCs|d|_dS)Nr)r*)rr�r
r
rr��sz+ReadOnlySequentialNamedNodeMap.__setstate__N)r
)rorprqr�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,eZdZdZdZdd�Zdd�Zdd�Zd	S)
�
Identifiedz@Mix-in class that supports the publicId and systemId attributes.)�publicId�systemIdcCs||_||_dS)N)r-r.)rr-r.r
r
r�_identified_mixin_init�sz!Identified._identified_mixin_initcCs|jS)N)r-)rr
r
r�
_get_publicId�szIdentified._get_publicIdcCs|jS)N)r.)rr
r
r�
_get_systemId�szIdentified._get_systemIdN)rorprqr�r�r/r0r1r
r
r
rr,�s
r,c@sHeZdZejZdZdZdZdZ	dZ
dd�Zdd�Zdd�Z
dd	d
�ZdS)�DocumentTypeNcCs2t�|_t�|_|r&t|�\}}||_|j|_dS)N)r)�entities�	notationsr�r�r�)rr�rsr�r
r
rr�	szDocumentType.__init__cCs|jS)N)�internalSubset)rr
r
r�_get_internalSubsetsz DocumentType._get_internalSubsetcCs�|jdkr�td�}|j|_|j|_tjjj}|r�g|j_	g|j
_	x>|j
j	D]2}t|j|j|j
�}|j
j	�|�|�|||�qJWxZ|jj	D]N}t|j|j|j
|j�}|j|_|j|_|j|_|jj	�|�|�|||�q�W|�|||�|SdSdS)N)rOr2r�r�r/r0�UserDataHandler�NODE_CLONEDr3r*r4�Notationr-r.rIrj�Entity�notationName�actualEncodingrrU)rrP�clonergr��notation�e�entityr
r
rrQs.

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�r-r.r5)rr"r r�r!r
r
rr/s



zDocumentType.writexml)rrr)rorprqr	�DOCUMENT_TYPE_NODErr�r�r-r.r5r�r6rQrr
r
r
rr2sr2c@sfeZdZdZejZdZdZdZ	dZ
dd�Zdd�Zdd�Z
dd	�Zd
d�Zdd
�Zdd�Zdd�ZdS)r:NcCs$||_||_t�|_|�||�dS)N)r�r;rkr$r/)rr�r-r.r>r
r
rr�FszEntity.__init__cCs|jS)N)r<)rr
r
r�_get_actualEncodingLszEntity._get_actualEncodingcCs|jS)N)r)rr
r
r�
_get_encodingOszEntity._get_encodingcCs|jS)N)rU)rr
r
r�_get_versionRszEntity._get_versioncCstj�d��dS)Nz(cannot append children to an entity node)r/r0r1)rr>r
r
rr5UszEntity.appendChildcCstj�d��dS)Nz+cannot insert children below an entity node)r/r0r1)rr>r?r
r
rr-YszEntity.insertBeforecCstj�d��dS)Nz*cannot remove children from an entity node)r/r0r1)rrCr
r
rr4]szEntity.removeChildcCstj�d��dS)Nz)cannot replace children of an entity node)r/r0r1)rr>rCr
r
rrDaszEntity.replaceChild)rorprqr�r	ZENTITY_NODErr�r<rrUr�rCrDrEr5r-r4rDr
r
r
rr:=sr:c@seZdZejZdZdd�ZdS)r9NcCs||_|�||�dS)N)r�r/)rr�r-r.r
r
rr�iszNotation.__init__)rorprqr	r�rr�r�r
r
r
rr9esr9c@sHeZdZddddddddgZd	d
�Zdd�Zd
d�Zdd�Zdd�ZdS)�DOMImplementation)�corez1.0)rGz2.0)rGN)r/z1.0)r/z2.0)r/N)zls-loadz3.0)zls-loadNcCs|dkrd}|��|f|jkS)Nr)�lower�	_features)rrTrUr
r
rrSyszDOMImplementation.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 namer/z$http://www.w3.org/XML/1998/namespacezillegal use of 'xml' prefixz(illegal use of prefix without namespaces)
r3r/r0�WrongDocumentErr�_create_documentZInvalidCharacterErrr�r��createElementNSr5rO�doctyperR)	rrrr�rMruZadd_root_elementrsr�rr
r
r�createDocument~s4



z DOMImplementation.createDocumentcCst|�}||_||_|S)N)r2r-r.)rr�r-r.rMr
r
r�createDocumentType�sz$DOMImplementation.createDocumentTypecCs|�|d�r|SdSdS)N)rS)rrTr
r
rrZ�szDOMImplementation.getInterfacecCst�S)N)�Document)rr
r
rrK�sz"DOMImplementation._create_documentN)	rorprqrIrSrNrOrZrKr
r
r
rrFns-rFc@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�cCs
||_dS)N)r�)rr�r
r
rr��szElementInfo.__init__cCstS)N)r�)r�anamer
r
rr��szElementInfo.getAttributeTypecCstS)N)r�)rrrrwr
r
rr��szElementInfo.getAttributeTypeNScCsdS)NFr
)rr
r
rr$�szElementInfo.isElementContentcCsdS)zQReturns true iff this element is declared to have an EMPTY
        content model.Fr
)rr
r
r�isEmpty�szElementInfo.isEmptycCsdS)z7Returns true iff the named attribute is a DTD-style ID.Fr
)rrRr
r
rr��szElementInfo.isIdcCsdS)z<Returns true iff the identified attribute is a DTD-style ID.Fr
)rrrrwr
r
rr��szElementInfo.isIdNScCs|jS)N)r�)rr
r
rr��szElementInfo.__getstate__cCs
||_dS)N)r�)rr�r
r
rr��szElementInfo.__setstate__N)rorprqr�r�r�r�r�r$rSr�r�r�r�r
r
r
rrQ�srQcCs>|jtjkr|j��d|_nt|�r:|jj��d|j_dS)N)rr	r�	_id_cache�clear�_id_search_stackrxrO)rAr
r
rr:�s
r:c@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)JrP)�
_elem_inforMrVr$rTz	#documentNFrcCs$d|_t�|_i|_i|_d|_dS)N)rMrkr$rWrTrV)rr
r
rr�
s
zDocument.__init__cCs&|jr|j|jf}n|j}|j�|�S)N)rrrwr�rWr�)rrr^r
r
rr�szDocument._get_elem_infocCs|jS)N)r<)rr
r
rrCszDocument._get_actualEncodingcCs|jS)N)rM)rr
r
r�_get_doctypeszDocument._get_doctypecCs|jS)N)�documentURI)rr
r
r�_get_documentURI szDocument._get_documentURIcCs|jS)N)r)rr
r
rrD#szDocument._get_encodingcCs|jS)N)�errorHandler)rr
r
r�_get_errorHandler&szDocument._get_errorHandlercCs|jS)N)�
standalone)rr
r
r�_get_standalone)szDocument._get_standalonecCs|jS)N)�strictErrorChecking)rr
r
r�_get_strictErrorChecking,sz!Document._get_strictErrorCheckingcCs|jS)N)rU)rr
r
rrE/szDocument._get_versioncCsj|j|jkr(tj�dt|�t|�f��|jdk	r>|j�|�|jtj	kr^|�
�r^tj�d��t�||�S)Nz%s cannot be child of %sz two document elements disallowed)rr.r/r0r1r2r3r4r	rJ�_get_documentElementr5)rrAr
r
rr52s
zDocument.appendChildcCsVy|j�|�Wntk
r.tj���YnXd|_|_d|_|j	|krRd|_	|S)N)
r$rEr7r/r0r8r<r=r3�documentElement)rrCr
r
rr4Bs
zDocument.removeChildcCs$x|jD]}|jtjkr|SqWdS)N)r$rr	rJ)rrAr
r
rraNszDocument._get_documentElementcCs(|jdk	r|j��d|_t�|�dS)N)rMrHr	)rr
r
rrHSs

zDocument.unlinkcCs�|sdS|j�ddd�}|j|_|j|_|j|_xx|jD]n}t|||�}|j�|�sXt	�|j�
|�|jtj
kr�|jdks�t	�n |jtjkr�|jdks�t	�||_||_q8W|�tjjj||�|S)N)rRrNrr]rUr$rNrOrY�AssertionErrorrIrr	rrbrBrMr3rjr/r0r7r8)rrPr=r�Z
childcloner
r
rrQYs&
zDocument.cloneNodecCst�}||_|S)N)r�rO)rrbr
r
r�createDocumentFragmentnszDocument.createDocumentFragmentcCst|�}||_|S)N)r�rO)rr�r?r
r
r�
createElementsszDocument.createElementcCs(t|t�std��t�}||_||_|S)Nznode contents must be a string)r�r�r�r�rGrO)rrG�tr
r
r�createTextNodexs
zDocument.createTextNodecCs(t|t�std��t�}||_||_|S)Nznode contents must be a string)r�r�r�r'rGrO)rrGr@r
r
r�createCDATASection�s
zDocument.createCDATASectioncCst|�}||_|S)N)r&rO)rrGr@r
r
r�
createComment�szDocument.createCommentcCst||�}||_|S)N)r	rO)rr
rG�pr
r
r�createProcessingInstruction�s
z$Document.createProcessingInstructioncCst|�}||_d|_|S)Nr)r�rOr�)rr��ar
r
r�createAttribute�szDocument.createAttributecCs"t|�\}}t|||�}||_|S)N)r�r�rO)rrrr�rsrwr?r
r
rrL�szDocument.createElementNScCs*t|�\}}t||||�}||_d|_|S)Nr)r�r�rOr�)rrrr�rsrwrlr
r
r�createAttributeNS�s
zDocument.createAttributeNScCst||||�}||_|S)N)r:rO)rr�r-r.r;r?r
r
r�_create_entity�szDocument._create_entitycCst|||�}||_|S)N)r9rO)rr�r-r.r�r
r
r�_create_notation�szDocument._create_notationcCs�||jkr|j|S|js$|js$dS|j}|dkrB|jg}||_n|sJdSd}�x<|�r�|��}|�dd�|jD��|�|�}|�r>x�|j	�
�D]�}|jr�|�|j|j
�r�||j|j<|j|kr�|}n|js�Pq�|�|j��r||j|j<|j|kr�|}n
|j�s8Pq�|jr�||j|j<|j|k�r,|}q�|jdkr�Pq�WnB|j�r�x8|j	�
�D]*}|j�rR||j|j<|j|k�rR|}�qRW|dk	rRPqRW|S)NcSsg|]}|jtkr|�qSr
)rr9)�.0rMr
r
r�
<listcomp>�sz+Document.getElementById.<locals>.<listcomp>r*)rTrWr�rVrb�pop�extendr$r�r�r�rrr�rwr�r�r�r�r�)rr��stack�resultrAr�r�r
r
r�getElementById�sZ







zDocument.getElementByIdcCst||t��S)N)r�rk)rr�r
r
rr��szDocument.getElementsByTagNamecCst|||t��S)N)r�rk)rrrrwr
r
rr��szDocument.getElementsByTagNameNScCs|j�||�S)N)rRrS)rrTrUr
r
rrV�szDocument.isSupportedcCs>|jtjkrtj�d��n|jtjkr2tj�d��t|||�S)Nzcannot import document nodesz!cannot import document type nodes)rr	rr/r0�NotSupportedErrrBrN)rrArPr
r
r�
importNode�s
zDocument.importNodercCsN|dkr|�d|�n|�d||f�x|jD]}|�||||�q2WdS)Nz<?xml version="1.0" ?>z%<?xml version="1.0" encoding="%s"?>%s)r~r$r)rr"r r�r!rrAr
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�r*r�zillegal use of 'xmlns' prefixz$illegal use of the 'xmlns' attribute)rOr/r0rJrr	rJr�rxrr�rr�r�r�r�rsr�rrr�r�r�r�r)rr�rrr�rsrwrZis_idr
r
r�
renameNodesR



zDocument.renameNode)rrrN)=rorprqr�r	rJr�r�rBr.rFrRrrr�r�r�r3r=r<r<rr]rUr_r[rYr�r�r�rCrXrZrDr\r^r`rEr5r4rarHrQrdrergrhrirkrmrLrnrorprwr�r�rVryrrzr
r
r
rrP�sf	
:
rPrbz#Top-level element of this document.c
Cs�|j�|�rtjjj}n
tjjj}|jtj	kr�|�
|j|j�}x>|j
��D]0}|�|j|j|j�|�|j|j�}|j|_qJW|r�x$|jD]}t|||�}|�|�q�W�n"|jtjkr�|��}|r�x$|jD]}t|||�}|�|�q�W�n�|jtjk�r|�|j�}�n�|jtjk�r*|�|j�}�n�|jtjk�rL|�|j |j�}�n�|jtj!k�rj|�"|j�}�nd|jtj#k�r�|�$|j|j�}d|_|j|_�n4|jtj%k�r�|j|k	�s�t&�tjjj}|j'�(|j)|j*|j+�}||_|�r�g|j,_-g|j._-xR|j.j-D]F}	t/|	j|	j*|	j+�}
||
_|j.j-�0|
�t1|	d��r�|	�2||	|
��q�Wx�|j,j-D]b}t3|j|j*|j+|j4�}|j5|_5|j6|_6|j7|_7||_|j,j-�0|�t1|d��rR|�2|||��qRWntj�8dt9|���t1|d��r�|�2|||�|S)zo
    Clone a node and give it the new owner document.
    Called by Node.cloneNode and Document.importNode
    TrjzCannot clone node %s):rOrYr/r0r7r8Z
NODE_IMPORTEDrr	rJrLrrr�r�r�r�r�r�rwr�r$rNr5r+rdrFrgrGr�rhr�rkr
r�rir�rnrBrcrRrOr�r-r.r3r*r4r9rIrdrjr:r;r<rrUrxr2)
rArPZnewOwnerDocumentrgr=r�rlrMr@r�r>r?r@r
r
rrNAs~

rNcCs,|�dd�}t|�dkr|Sd|dfSdS)Nr�r*�r)r�r�)r�Zfieldsr
r
rr��sr�cCs,|||�}|��\}}|�|�|��|S)N)ZgetEventZ
expandNoderU)�func�args�kwargsZeventsZtoktypeZrootNoder
r
r�_do_pulldom_parse�s


rcCsH|dkr"|s"ddlm}|�|�Sddlm}t|j|f||d��SdS)z3Parse a file into a DOM by filename or file object.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)z&Parse a file into a DOM from a string.Nr)r�)r�r�)r�r��parseStringr�r)�stringr�r�r�r
r
rr��s

r�cCsB|r<t|t�rt�|�}x"|D]\}}tj�||�sdSqWtjS)N)r�r�rZ_parse_feature_stringrPrRrS)Zfeatures�f�vr
r
r�getDOMImplementation�s

r�)NN)N)N)7r�rr�r/rrrrZxml.dom.minicompatZxml.dom.xmlbuilderrrr0r	rJr�r9ZdefpropertyrBrxrr�r�r�r��objectr�Z
AttributeListr�r�r�r�rr	rr�r#rr&r'r)r,r2r:r9rFrQr:rPrNr�rr�r�r�r
r
r
r�<module>s�v
	y$
w)GU	><(	O*PR