AlkantarClanX12

Your IP : 3.145.95.233


Current Path : /proc/self/root/opt/alt/python39/lib64/python3.9/xml/dom/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python39/lib64/python3.9/xml/dom/__pycache__/minidom.cpython-39.opt-1.pyc

a

R�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/python39/lib64/python3.9/xml/dom/minidom.py�__bool__+sz
Node.__bool__cCs|�dd||�S�N�)�toprettyxml)r�encoding�
standaloner
r
r
�toxml.sz
Node.toxml�	�
cCsz|durt��}ntjt��|ddd�}|jtjkrJ|�|d||||�n|�|d||�|durj|��S|�	���SdS)N�xmlcharrefreplacer)r�errors�newliner)
�io�StringIO�
TextIOWrapper�BytesIO�nodeTyper	�
DOCUMENT_NODE�writexml�getvalue�detach)r�indent�newlrr�writerr
r
r
r1s

�zNode.toprettyxmlcCs
t|j�S�N)�bool�
childNodesrr
r
r
�
hasChildNodesDszNode.hasChildNodescCs|jSr&�r(rr
r
r
�_get_childNodesGszNode._get_childNodescCs|jr|jdSdS�Nrr*rr
r
r
�_get_firstChildJszNode._get_firstChildcCs|jr|jdSdS�N���r*rr
r
r
�_get_lastChildNszNode._get_lastChildcCs|j|jkr,t|j�D]}|�||�q|S|j|jvrTtj�dt	|�t	|�f��|j
durj|j
�|�|dur~|�|�n�z|j�
|�}Wnty�tj���Yn0|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�cr>�noder
r
r
r5Rs8�

zNode.insertBeforecCs�|j|jkr*t|j�D]}|�|�q|S|j|jvrTtj�dt	|�t	|�f��n|jt
vrft|�|jdur||j�
|�t||�d|_|S�Nr1)rr3r4r(r=r6r7r8r9r:rArBr;r<�
_append_childrD)rrIrHr
r
r
r=rs�


zNode.appendChildcCs|j|jkr(|j}|�|�|�||�S|j|jvrPtj�dt	|�t	|�f��||ur\dS|j
durr|j
�|�z|j�|�}Wnt
y�tj���Yn0||j|<||_
d|_
|jtvs�|jtvr�t|�|j|_|j|_d|_d|_|jr�||j_|j�r||j_|SrJ)rr3rDr<r5r6r7r8r9r:r;r(r>r?r@rArBrE)rrF�oldChildrGr>r
r
r
�replaceChild�s@
�


�zNode.replaceChildcCs~z|j�|�Wnty,tj���Yn0|jdurB|j|j_|jdurV|j|j_d|_|_|jt	vrtt
|�d|_|Sr&)r(�remover?r7r8r@rDrErrArBr;�rrLr
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�datarDrE�unlink�append�ELEMENT_NODE�	normalize)r�L�childrIr
r
r
rU�s*





zNode.normalizecCst|||jp|�Sr&)�_clone_node�
ownerDocument)r�deepr
r
r
�	cloneNode�szNode.cloneNodecCs|jj�||�Sr&)rY�implementation�
hasFeature�r�feature�versionr
r
r
�isSupported�szNode.isSupportedcCsdSr&r
rr
r
r
�_get_localName�szNode._get_localNamecCs||uSr&r
�r�otherr
r
r
�
isSameNode�szNode.isSameNodecCs|�|d�r|SdSdSr&)ra�rr_r
r
r
�getInterface�szNode.getInterfacec	Cs.z|j|dWSttfy(YdS0dSr,)�
_user_data�AttributeError�KeyError�r�keyr
r
r
�getUserData�szNode.getUserDatacCsld}z
|j}Wnty*i}||_Yn0||vr@||d}|dur\d}|durh||=n||f||<|Sr,)rhri)rrlrQ�handler�old�dr
r
r
�setUserData�s
zNode.setUserDatacCsDt|d�r@t|j���D]&\}\}}|dur|�|||||�qdS)Nrh)�hasattr�listrh�itemsZhandle)r�	operation�srcZdstrlrQrnr
r
r
�_call_user_data_handler�s
zNode._call_user_data_handlercCs>d|_|_|jr.|jD]}|��qt�|_d|_d|_dSr&)r;rYr(rR�NodeListrErD)rrWr
r
r
rRs

zNode.unlinkcCs|Sr&r
rr
r
r
�	__enter__szNode.__enter__cCs|��dSr&)rR)rZetZev�tbr
r
r
�__exit__sz
Node.__exit__)NN)rrNN)!�__name__�
__module__�__qualname__�namespaceURIr;rYrDrEr�prefixrrrr)r+r-r0r5r=rMr<rUr[rarbrergrmrqrwrRryr{r
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(rErDrSr;)rrIr(Zlastr
r
r
rKs
rKcCs$|dur |jtjkrdS|j}qdS�NTF)rr	rr;�rIr
r
r
�_in_document's
r�cCs6|r2|�dd��dd��dd��dd�}|�|�d	S)
zWrites datachars to writer.�&z&amp;�<z&lt;�"z&quot;�>z&gt;N)�replace�write)r%rQr
r
r
�_write_data/s��r�cCsD|jD]8}|jtjkr2|dks(|j|kr2|�|�t|||�q|S�Nr)r(rr	rT�tagNamerS�_get_elements_by_tagName_helper)�parent�name�rcrIr
r
r
r�6s
��
r�cCsX|jD]L}|jtjkr|dks(|j|krD|dks:|j|krD|�|�t||||�q|Sr�)r(rr	rTr�rrS�"_get_elements_by_tagName_ns_helper)r�ZnsURIr�r�rIr
r
r
r�>s
��
r�c@sJeZdZejZdZdZdZdZ	ej
ejejej
ejejejfZdd�ZdS)�DocumentFragmentz#document-fragmentNcCst�|_dSr&)rxr(rr
r
r
�__init__UszDocumentFragment.__init__)r|r}r~r	r3r�nodeName�	nodeValue�
attributesr;rTrP�CDATA_SECTION_NODE�ENTITY_REFERENCE_NODE�PROCESSING_INSTRUCTION_NODE�COMMENT_NODE�
NOTATION_NODEr6r�r
r
r
r
r�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(�
_localNamerY�ownerElementNFcCs2d|_||_||_||_t�|_|j�t��dSr&)r�r�rr�rxr(rS�Text)r�qNamerr�r�r
r
r
r�csz
Attr.__init__cCs2z|jWSty,|j�dd�dYS0dS�N�:r2r/)r�rir��splitrr
r
r
rbpszAttr._get_localNamecCs|jSr&)�	specifiedrr
r
r
�_get_specifiedvszAttr._get_specifiedcCs|jSr&)r�rr
r
r
�	_get_nameyszAttr._get_namecCs||_|jdurt|j�dSr&)r�r�rB�r�valuer
r
r
�	_set_name|s
zAttr._set_namecCs|jSr&)r�rr
r
r
�
_get_value�szAttr._get_valuecCs6||_||jd_|jdur&t|j�||jd_dSr,)r�r(rQr�rBr�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��||_|dur<|j}nd||jf}|jrZt|j�||_	dS)N�xmlnsz5illegal use of 'xmlns' prefix for the wrong namespacez%s:%s)
rrr7r8�NamespaceErrr�r�r�rBr�)rr�ZnsuriZnewNamer
r
r
�_set_prefix�s�
zAttr._set_prefixcCsv|j}|durR|j|j=|j|j|jf=|jrRd|_|jd8_|jj	d8_	|j
D]}|��qX|j
dd�=dS)NFr2)r��_attrsr��_attrsNSrr��_is_id�_magic_id_nodesrY�_magic_id_countr(rR)r�elemrWr
r
r
rR�s


zAttr.unlinkcCsf|jr
dS|j}|j}|dus&|dur*dS|�|�}|dur@dS|jrV|�|j|j�S|�|j�SdSr�)	r�rYr��_get_elem_infor�isIdNSr��isIdr��rr�r��infor
r
r
�	_get_isId�s
zAttr._get_isIdcCs\|j}|j}|dus|dur tS|�|�}|dur6tS|jrL|�|j|j�S|�|j�SdSr&)	rYr��_no_typer�r�getAttributeTypeNSr��getAttributeTyper�r�r
r
r
�_get_schemaType�s
zAttr._get_schemaType) r|r}r~�	__slots__r	�ATTRIBUTE_NODErr�r�r�rPr�r6rr�rbr�r�r��propertyr�r�r�r�r�r�r�r�r�rRr�r�r
r
r
r
r�Ys.�


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�r
r
r
r��szNamedNodeMap.__init__cCs
t|j�Sr&)�lenr�rr
r
r
�_get_length�szNamedNodeMap._get_lengthcCs2z|t|j���|WSty,YdS0dSr&)rsr��keys�
IndexError�rr>r
r
r
�item�szNamedNodeMap.itemcCs*g}|j��D]}|�|j|jf�q|Sr&)r��valuesrSr�r��rrVrIr
r
r
rt�szNamedNodeMap.itemscCs0g}|j��D]}|�|j|jf|jf�q|Sr&)r�r�rSrr�r�r�r
r
r
�itemsNS�szNamedNodeMap.itemsNScCs"t|t�r||jvS||jvSdSr&)�
isinstance�strr�r�rkr
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�urdSt|�t|�kt|�t|�kSdS)Nr�r)r��getattr�idrcr
r
r
�_cmpszNamedNodeMap._cmpcCs|�|�dkSr,�r�rcr
r
r
�__eq__szNamedNodeMap.__eq__cCs|�|�dkSr,r�rcr
r
r
�__ge__szNamedNodeMap.__ge__cCs|�|�dkSr,r�rcr
r
r
�__gt__szNamedNodeMap.__gt__cCs|�|�dkSr,r�rcr
r
r
�__le__szNamedNodeMap.__le__cCs|�|�dkSr,r�rcr
r
r
�__lt__"szNamedNodeMap.__lt__cCs"t|t�r|j|S|j|SdSr&)r�r4r�r�)r�attname_or_tupler
r
r
�__getitem__%s

zNamedNodeMap.__getitem__cCstt|t�rPz|j|}Wn.tyFt|�}|jj|_|�|�Yn0||_n t|t�sbt	d��|}|�|�dS)Nz%value must be a string or Attr object)
r�r�r�rjr�r�rY�setNamedItemr��	TypeError)r�attnamer�rIr
r
r
�__setitem__,s


zNamedNodeMap.__setitem__cCs&z|j|WSty YdS0dSr&)r�rj�rr�r
r
r
�getNamedItem;szNamedNodeMap.getNamedItemcCs*z|j||fWSty$YdS0dSr&)r�rj�rrr�r
r
r
�getNamedItemNSAszNamedNodeMap.getNamedItemNScCsX|�|�}|durJt|j�|j|j=|j|j|jf=t|d�rFd|_	|St
j���dS�Nr�)
r�rBr�r�r�r�rr�rrr�r7r8r@�rr��nr
r
r
�removeNamedItemGs



zNamedNodeMap.removeNamedItemcCsZ|�||�}|durLt|j�|j|j|jf=|j|j=t|d�rHd|_	|St
j���dSr�)
r�rBr�r�rr�r�r�rrr�r7r8r@�rrr�r�r
r
r
�removeNamedItemNSSs


zNamedNodeMap.removeNamedItemNScCstt|t�s&tj�dt|�t|�f��|j�|j�}|r@|�	�||j|j<||j
|j|jf<|j
|_t|j�|SrJ)r�r�r7r8r9r:r�r�r�rRr�rr�r�r�rB)rrIror
r
r
r�_s
�
zNamedNodeMap.setNamedItemcCs
|�|�Sr&)r��rrIr
r
r
�setNamedItemNSlszNamedNodeMap.setNamedItemNScCs||}t|j�|��dSr&)rBr�rR)rr�rIr
r
r
�__delitem__os
zNamedNodeMap.__delitem__cCs|j|j|jfSr&r�rr
r
r
�__getstate__tszNamedNodeMap.__getstate__cCs|\|_|_|_dSr&r��r�stater
r
r
�__setstate__wszNamedNodeMap.__setstate__)N)!r|r}r~�__doc__r�r�r�r�rtr�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
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)rYr;r�r�r�rr�r(r�r�rDrENrcCsBd|_||_|_||_||_t�|_d|_|_d|_	d|_
dSr&)r;r�r�r�rrxr(rDrEr�r�)rr�rr�r�r
r
r
r��s
zElement.__init__cCs|jduri|_i|_dSr&)r�r�rr
r
r
�_ensure_attributes�s
zElement._ensure_attributescCs2z|jWSty,|j�dd�dYS0dSr�)r�rir�r�rr
r
r
rb�szElement._get_localNamecCs|jSr&�r�rr
r
r
�_get_tagName�szElement._get_tagNamecCs@|jdur&t|j���D]}|��qd|_d|_t�|�dSr&)r�rsr�rRr�r	)r�attrr
r
r
rR�s

zElement.unlinkcCs6|jdurdSz|j|jWSty0YdS0dS)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�rj)rr�r
r
r
�getAttribute�s	
zElement.getAttributecCs:|jdurdSz|j||fjWSty4YdS0dSr)r�r�rjr�r
r
r
�getAttributeNS�s
zElement.getAttributeNScCsV|�|�}|dur4t|�}||_|j|_|�|�n||jkrR||_|jrRt|�dSr&)�getAttributeNoder�r�rY�setAttributeNoder�rB)rr�r�r
r
r
r
�setAttribute�s

zElement.setAttributecCs�t|�\}}|�||�}|durHt||||�}||_|j|_|�|�n4||jkrf||_|jrft|�|j|kr|||_||_	dSr&)
�_nssplit�getAttributeNodeNSr�r�rYrr�rBr�r�)rr�
qualifiedNamer�r��	localnamer
r
r
r
�setAttributeNS�s

zElement.setAttributeNScCs|jdurdS|j�|�Sr&r�)r�attrnamer
r
r
r
s
zElement.getAttributeNodecCs|jdurdS|j�||f�Sr&)r�r�r�r
r
r
rs
zElement.getAttributeNodeNScCs�|jd|fvrtj�d��|��|j�|jd�}|durD|�|�|j	�|j
|jfd�}|durt||urt|�|�t||�||ur�|S||ur�|SdS)Nzattribute node already owned)
r�r7r8ZInuseAttributeErrrr�r�r��removeAttributeNoder�rr��_set_attribute_node)rr
Zold1Zold2r
r
r
rs


zElement.setAttributeNodecCsN|jdurtj���z|j|}Wnty>tj���Yn0|�|�dSr&)r�r7r8r@r�rjr)rr�r
r
r
r
�removeAttribute%s

zElement.removeAttributecCsR|jdurtj���z|j||f}WntyBtj���Yn0|�|�dSr&)r�r7r8r@rjr)rrr�r
r
r
r
�removeAttributeNS.s

zElement.removeAttributeNScCs\|durtj���z|j|jWnty>tj���Yn0t|�|��|j|_|Sr&)	r7r8r@r�r�rjrBrRrYr�r
r
r
r7s
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�r�r
r
r
�hasAttributeGs
zElement.hasAttributecCs|jdurdS||f|jvS�NF)r�r�r
r
r
�hasAttributeNSQs
zElement.hasAttributeNScCst||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�rxr�r
r
r
�getElementsByTagNameVszElement.getElementsByTagNamecCst|||t��Sr&�r�rxr�r
r
r
�getElementsByTagNameNS^s
�zElement.getElementsByTagNameNScCsd|jt|�fS)Nz<DOM Element: %s at %#x>)r�r�rr
r
r
rbszElement.__repr__rcCs�|�|d|j�|��}|��D],}|�d|�t|||j�|�d�q$|jr�|�d�t|j�dkr�|jdjt	j
t	jfvr�|jd�|ddd�n4|�|�|jD]}|�|||||�q�|�|�|�d|j|f�n|�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�r2rrz</%s>%sz/>%sN)
r�r��_get_attributesr�r�r�r(r�rr	rPr�r )rr%r#�	addindentr$r�Za_namerIr
r
r
r es(	

��


zElement.writexmlcCs|��t|j|j|�Sr&)rr�r�r�rr
r
r
r"�szElement._get_attributescCs|jr
dSdSdSr�rrr
r
r
�
hasAttributes�szElement.hasAttributescCs|�|�}|�|�dSr&)r
�setIdAttributeNode)rr��idAttrr
r
r
�setIdAttribute�s
zElement.setIdAttributecCs|�||�}|�|�dSr&)rr%)rrr�r&r
r
r
�setIdAttributeNS�szElement.setIdAttributeNScCsj|dus|�|j�stj���t|�dur4tj���|jsfd|_|jd7_|j	j
d7_
t|�dS)NTr2)rer�r7r8r@�_get_containing_entref�NoModificationAllowedErrr�r�rYr�rB)rr&r
r
r
r%�s

zElement.setIdAttributeNode)rrr).r|r}r~r�r	rTrr�r�r�r�r�r�rPr�r�r6rr�rrbr	rRrrrrr
rrZsetAttributeNodeNSrrrZremoveAttributeNodeNSrrrr!rr r"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&)rBrr�r�r�rr�r�)�elementr
r
r
r
r�s
rc@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
NcCsdSr&r
rr
r
r
r-�szChildless._get_firstChildcCsdSr&r
rr
r
r
r0�szChildless._get_lastChildcCstj�|jd��dS)Nz nodes cannot have children�r7r8r9r�r�r
r
r
r=�s�zChildless.appendChildcCsdSrr
rr
r
r
r)�szChildless.hasChildNodescCstj�|jd��dS�Nz nodes do not have childrenr-�rrFrGr
r
r
r5�s�zChildless.insertBeforecCstj�|jd��dSr.)r7r8r@r�rOr
r
r
r<�s�zChildless.removeChildcCsdSr&r
rr
r
r
rU�szChildless.normalizecCstj�|jd��dSr.r-�rrFrLr
r
r
rM�s�zChildless.replaceChild)r|r}r~r�r�r�Z
EmptyNodeListr(r�r�r-r0r=r)r5r<rUrMr
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��targetrQcCs||_||_dSr&r2)rr3rQr
r
r
r��szProcessingInstruction.__init__cCs|jSr&�rQrr
r
r
�_get_nodeValue�sz$ProcessingInstruction._get_nodeValuecCs
||_dSr&r4r�r
r
r
�_set_nodeValue�sz$ProcessingInstruction._set_nodeValuecCs|jSr&�r3rr
r
r
�
_get_nodeName�sz#ProcessingInstruction._get_nodeNamecCs
||_dSr&r7r�r
r
r
�
_set_nodeName�sz#ProcessingInstruction._set_nodeNamercCs|�d||j|j|f�dS)Nz
%s<?%s %s?>%s)r�r3rQ�rr%r#r#r$r
r
r
r �szProcessingInstruction.writexmlN)rrr)r|r}r~r	r�rr�r�r5r6r�r�r8r9r�r r
r
r
r
r1�s

r1c@sreZdZdZdd�Zdd�ZeZdd�Zdd	�Ze	ee�Z
Zd
d�Zdd
�Z
dd�Zdd�Zdd�Zdd�ZdS)�
CharacterData)�_datarYr;rErDcCs,d|_|_d|_|_d|_t�|�dSr)rYr;rErDr<r	r�rr
r
r
r��szCharacterData.__init__cCs
t|j�Sr&)r�rQrr
r
r
r�szCharacterData._get_lengthcCs|jSr&�r<rr
r
r
�	_get_dataszCharacterData._get_datacCs
||_dSr&r=�rrQr
r
r
�	_set_dataszCharacterData._set_datacCs6|j}t|�dkrd}nd}d|jj|dd�|fS)N�
z...rz<DOM %s node "%r%s">r)rQr�rr|)rrQZ	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�r7r8�IndexSizeErrr�rQ�r�offset�countr
r
r
�
substringDataszCharacterData.substringDatacCs|j||_dSr&r4)r�argr
r
r
�
appendDataszCharacterData.appendDatacCsZ|dkrtj�d��|t|j�kr.tj�d��|rVd|jd|�||j|d�f|_dS)NrrCrD�%s%s%srF)rrIrLr
r
r
�
insertData!s�zCharacterData.insertDatacCsl|dkrtj�d��|t|j�kr.tj�d��|dkrBtj�d��|rh|jd|�|j||d�|_dSrBrFrHr
r
r
�
deleteData*szCharacterData.deleteDatacCsr|dkrtj�d��|t|j�kr.tj�d��|dkrBtj�d��|rnd|jd|�||j||d�f|_dS)NrrCrDrErNrF)rrIrJrLr
r
r
�replaceData4s�zCharacterData.replaceDataN)r|r}r~r�r�r�r�r>r@r�rQr�rrKrMrOrPrQr
r
r
r
r;�s			
r;zLength 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	vr~|durp|j�
|�n|j�||�|jd|�|_|S)Nrzillegal offset value)r�rQr7r8rGrrYrDr;r(r=r5)rrIZnewText�nextr
r
r
�	splitTextIszText.splitTextrcCst|d||j|f�dS)NrN)r�rQr:r
r
r
r Xsz
Text.writexmlcCs�|jg}|j}|durB|jtjtjfvrB|�d|j�|j}qqBq|j}|durz|jtjtjfvrz|�|j�|j}qHqzqHd�	|�S)Nrr)
rQrErr	rPr�rCrDrS�join)rrVr�r
r
r
�_get_wholeText]szText._get_wholeTextcCs�|j}|j}|dur@|jtjtjfvr@|j}|�|�|}qq@q|j}|sT|�|�|dur�|jtjtjfvr�|j}|�|�|}qTq�qT|r�||_|SdSdSr&)	r;rErr	rPr�r<rDrQ)rZcontentr�r�rRr
r
r
�replaceWholeTextos*


zText.replaceWholeTextcCsF|j��rdSt|�}|dur"dS|j�|�}|dur:dS|��SdSr)rQ�strip�_get_containing_elementrYr��isElementContent)rr�r�r
r
r
�!_get_isWhitespaceInElementContent�s
z&Text._get_isWhitespaceInElementContent)rrr)r|r}r~r�r	rPrr�r�rSr rUrVrZr
r
r
r
r�Bs
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}|dur&|jtjkr|S|j}qdSr&)r;rr	rT�rIrHr
r
r
rX�srXcCs*|j}|dur&|jtjkr|S|j}qdSr&)r;rr	r�r[r
r
r
r)�sr)c@s(eZdZejZdZdd�Zddd�ZdS)	�Commentz#commentcCst�|�||_dSr&)r;r�r<r?r
r
r
r��s
zComment.__init__rcCs,d|jvrtd��|�d||j|f�dS)Nz--z%'--' is not allowed in a comment nodez
%s<!--%s-->%s)rQr?r�r:r
r
r
r �s
zComment.writexmlN)rrr)	r|r}r~r	r�rr�r�r r
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]]>)rQ�findr?r�r:r
r
r
r �szCDATASection.writexmlN)rrr)	r|r}r~r�r	r�rr�r r
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�rarr
r
r
r��sz&ReadOnlySequentialNamedNodeMap.__len__cCs
t|j�Sr&rcrr
r
r
r��sz*ReadOnlySequentialNamedNodeMap._get_lengthcCs"|jD]}|j|kr|SqdSr&)rar�r�r
r
r
r��s

z+ReadOnlySequentialNamedNodeMap.getNamedItemcCs,|jD] }|j|kr|j|kr|SqdSr&)rarr�r�r
r
r
r��s
z-ReadOnlySequentialNamedNodeMap.getNamedItemNScCs4t|t�r|j|�}n
|�|�}|dur0t|��|Sr&)r�r4r�r�rj)rZ
name_or_tuplerIr
r
r
r��s

z*ReadOnlySequentialNamedNodeMap.__getitem__cCs2|dkrdSz|j|WSty,YdS0dSr,)rar�r�r
r
r
r��sz#ReadOnlySequentialNamedNodeMap.itemcCstj�d��dS�Nz"NamedNodeMap instance is read-only�r7r8r*r�r
r
r
r��s�z.ReadOnlySequentialNamedNodeMap.removeNamedItemcCstj�d��dSrdrer�r
r
r
r��s�z0ReadOnlySequentialNamedNodeMap.removeNamedItemNScCstj�d��dSrdrer�r
r
r
r��s�z+ReadOnlySequentialNamedNodeMap.setNamedItemcCstj�d��dSrdrer�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,eZdZdZdZdd�Zdd�Zdd�Zd	S)
�
Identifiedz@Mix-in class that supports the publicId and systemId attributes.��publicId�systemIdcCs||_||_dSr&rg)rrhrir
r
r
�_identified_mixin_initsz!Identified._identified_mixin_initcCs|jSr&)rhrr
r
r
�
_get_publicIdszIdentified._get_publicIdcCs|jSr&)rirr
r
r
�
_get_systemIdszIdentified._get_systemIdN)r|r}r~r�r�rjrkrlr
r
r
r
rfs
rfc@sHeZdZejZdZdZdZdZ	dZ
dd�Zdd�Zdd�Z
dd	d
�ZdS)�DocumentTypeNcCs2t�|_t�|_|r&t|�\}}||_|j|_dSr&)r_�entities�	notationsrr�r�)rrr�rr
r
r
r�"szDocumentType.__init__cCs|jSr&)�internalSubsetrr
r
r
�_get_internalSubset*sz DocumentType._get_internalSubsetcCs�|jdur�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&)rYrmr�r�r7r8�UserDataHandler�NODE_CLONEDrnraro�NotationrhrirSrw�Entity�notationName�actualEncodingrr`)rrZ�clonerur��notation�e�entityr
r
r
r[-s0

�zDocumentType.cloneNodercCs�|�d�|�|j�|jr8|�d||j||jf�n|jrR|�d||jf�|jdur||�d�|�|j�|�d�|�d|�dS)Nz
<!DOCTYPE z%s  PUBLIC '%s'%s  '%s'z%s  SYSTEM '%s'z [�]r�)r�r�rhrirpr:r
r
r
r Hs
�


zDocumentType.writexml)rrr)r|r}r~r	�DOCUMENT_TYPE_NODErr�r�rhrirpr�rqr[r r
r
r
r
rmsrmc@sfeZdZdZejZdZdZdZ	dZ
dd�Zdd�Zdd�Z
dd	�Zd
d�Zdd
�Zdd�Zdd�ZdS)ruNcCs$||_||_t�|_|�||�dSr&)r�rvrxr(rj)rr�rhriryr
r
r
r�_szEntity.__init__cCs|jSr&�rwrr
r
r
�_get_actualEncodingeszEntity._get_actualEncodingcCs|jSr&�rrr
r
r
�
_get_encodinghszEntity._get_encodingcCs|jSr&�r`rr
r
r
�_get_versionkszEntity._get_versioncCstj�d��dS)Nz(cannot append children to an entity node�r7r8r9)rrFr
r
r
r=ns�zEntity.appendChildcCstj�d��dS)Nz+cannot insert children below an entity noder�r/r
r
r
r5rs�zEntity.insertBeforecCstj�d��dS)Nz*cannot remove children from an entity noder�rOr
r
r
r<vs�zEntity.removeChildcCstj�d��dS)Nz)cannot replace children of an entity noder�r0r
r
r
rMzs�zEntity.replaceChild)r|r}r~r�r	ZENTITY_NODErr�rwrr`r�rr�r�r=r5r<rMr
r
r
r
ruVsruc@seZdZejZdZdd�ZdS)rtNcCs||_|�||�dSr&)r�rj)rr�rhrir
r
r
r��szNotation.__init__)r|r}r~r	r�rr�r�r
r
r
r
rt~srtc@s<eZdZgd�Zdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�DOMImplementation))�core�1.0)r��2.0)r�N)r7r�)r7r�)r7N)�ls-loadz3.0)r�NcCs|dkrd}|��|f|jvSr)�lower�	_featuresr^r
r
r
r]�szDOMImplementation.hasFeaturec	Cs�|r|jdurtj�d��|��}|duo8|duo8|du}|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 namer7z$http://www.w3.org/XML/1998/namespacezillegal use of 'xml' prefixz(illegal use of prefix without namespaces)
r;r7r8�WrongDocumentErr�_create_documentZInvalidCharacterErrrr��createElementNSr=rY�doctyper\)	rrrr�r�Zadd_root_elementr�rr+r
r
r
�createDocument�s>���
��

z DOMImplementation.createDocumentcCst|�}||_||_|Sr&)rmrhri)rrrhrir�r
r
r
�createDocumentType�sz$DOMImplementation.createDocumentTypecCs|�|d�r|SdSdSr&)r]rfr
r
r
rg�szDOMImplementation.getInterfacecCst�Sr&)�Documentrr
r
r
r��sz"DOMImplementation._create_documentN)	r|r}r~r�r]r�r�rgr�r
r
r
r
r��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.

    rcCs
||_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
rY�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
r�r
r
r
r��szElementInfo.isIdcCsdS)z<Returns true iff the identified attribute is a DTD-style ID.Fr
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�r�rYr�r�r�r�r�r
r
r
r
r��sr�cCs>|jtjkr|j��d|_nt|�r:|jj��d|j_dSr&)rr	r�	_id_cache�clear�_id_search_stackr�rYr�r
r
r
rBs
rBc@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�rxr(r�r�r�rr
r
r
r�#s
zDocument.__init__cCs&|jr|j|jf}n|j}|j�|�Sr&)rr�r�r�r�)rr+rlr
r
r
r�,szDocument._get_elem_infocCs|jSr&r~rr
r
r
r3szDocument._get_actualEncodingcCs|jSr&)r�rr
r
r
�_get_doctype6szDocument._get_doctypecCs|jSr&)�documentURIrr
r
r
�_get_documentURI9szDocument._get_documentURIcCs|jSr&r�rr
r
r
r�<szDocument._get_encodingcCs|jSr&)�errorHandlerrr
r
r
�_get_errorHandler?szDocument._get_errorHandlercCs|jSr&)rrr
r
r
�_get_standaloneBszDocument._get_standalonecCs|jSr&)�strictErrorCheckingrr
r
r
�_get_strictErrorCheckingEsz!Document._get_strictErrorCheckingcCs|jSr&r�rr
r
r
r�HszDocument._get_versioncCsj|j|jvr(tj�dt|�t|�f��|jdur>|j�|�|jtj	kr^|�
�r^tj�d��t�||�S)Nr1z two document elements disallowed)rr6r7r8r9r:r;r<r	rT�_get_documentElementr=r�r
r
r
r=Ks�
��zDocument.appendChildcCsTz|j�|�Wnty,tj���Yn0d|_|_d|_|j	|urPd|_	|Sr&)
r(rNr?r7r8r@rDrEr;�documentElementrOr
r
r
r<[s
zDocument.removeChildcCs$|jD]}|jtjkr|SqdSr&)r(rr	rTr�r
r
r
r�gs
zDocument._get_documentElementcCs(|jdur|j��d|_t�|�dSr&)r�rRr	rr
r
r
rRls

zDocument.unlinkcCs�|sdS|j�ddd�}|j|_|j|_|j|_|jD]B}t|||�}|j�|�|jt	j
kr`n|jt	jkrr||_||_
q6|�tjjj||�|Sr&)r\r�rrr`r(rXrSrr	rr}r�r;rwr7r8rrrs)rrZrxr�Z
childcloner
r
r
r[rs$
�zDocument.cloneNodecCst�}||_|Sr&)r�rY)rrpr
r
r
�createDocumentFragment�szDocument.createDocumentFragmentcCst|�}||_|Sr&)rrY)rr�rzr
r
r
�
createElement�szDocument.createElementcCs(t|t�std��t�}||_||_|S�Nznode contents must be a string)r�r�r�r�rQrY)rrQ�tr
r
r
�createTextNode�s
zDocument.createTextNodecCs(t|t�std��t�}||_||_|Sr�)r�r�r�r]rQrY�rrQrHr
r
r
�createCDATASection�s
zDocument.createCDATASectioncCst|�}||_|Sr&)r\rYr�r
r
r
�
createComment�szDocument.createCommentcCst||�}||_|Sr&)r1rY)rr3rQ�pr
r
r
�createProcessingInstruction�s
z$Document.createProcessingInstructioncCst|�}||_d|_|Sr)r�rYr�)rr��ar
r
r
�createAttribute�szDocument.createAttributecCs"t|�\}}t|||�}||_|Sr&)rrrY)rrrr�r�rzr
r
r
r��szDocument.createElementNScCs*t|�\}}t||||�}||_d|_|Sr)rr�rYr�)rrrr�r�r�r
r
r
�createAttributeNS�s
zDocument.createAttributeNScCst||||�}||_|Sr&)rurY)rr�rhrirvrzr
r
r
�_create_entity�szDocument._create_entitycCst|||�}||_|Sr&)rtrY)rr�rhrir�r
r
r
�_create_notation�szDocument._create_notationcCs�||jvr|j|S|js$|js$dS|j}|durB|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|durN�q�qN|S)NcSsg|]}|jtvr|�qSr
)rrA)�.0rWr
r
r
�
<listcomp>�s
�z+Document.getElementById.<locals>.<listcomp>r2)r�r�r�r�r��pop�extendr(r�r�r�rr�r�r�r�r�r�r�)rr��stack�resultrIr�r
r
r
r
�getElementById�sZ






zDocument.getElementByIdcCst||t��Sr&rr�r
r
r
rszDocument.getElementsByTagNamecCst|||t��Sr&r r�r
r
r
r!s
�zDocument.getElementsByTagNameNScCs|j�||�Sr&)r\r]r^r
r
r
raszDocument.isSupportedcCs>|jtjkrtj�d��n|jtjkr2tj�d��t|||�S)Nzcannot import document nodesz!cannot import document type nodes)rr	rr7r8�NotSupportedErrr}rX)rrIrZr
r
r
�
importNodes
zDocument.importNoderc	Csxg}|r|�d|�d��|dur<|�d|r0dnd�d��|�dd�|��d|���|jD]}|�||||�q^dS)	Nz
encoding="r�zstandalone="ZyesZnoz<?xml version="1.0" � z?>)rSr�rTr(r )	rr%r#r#r$rrZdeclarationsrIr
r
r
r s
zDocument.writexmlcCsJ|j|ur tj�d||jf��|jtjtjfvr>tj�d��|t	kr�d|vr�|�
dd�\}}|dkr�|tjjkr�tj�d��q�|dkr�|tjjkr�|jtjkr�tj�d��d}|}nd}d}|jtjkr�|j
}|dur�|j}|�|�nd}||_||_||_||_|jtjk�r||_n*||_|du�rF|�|�|�rF|�|�|S)Nz?cannot rename nodes from other documents;
expected %s,
found %sz8renameNode() only applies to element and attribute nodesr�r2r�zillegal use of 'xmlns' prefixz$illegal use of the 'xmlns' attribute)rYr7r8r�rr	rTr�r�rr�rr�r�r�rr�r�rr�r�r�rr%)rr�rr�r�r�r+Zis_idr
r
r
�
renameNode&sb
���
��
�
��


zDocument.renameNode)rrrNN)=r|r}r~r�r	rTr�r�r}r6r�r\rrr�r�r�r;rErDrwrrr`r�r�r�r�r�r�rr�r�r�r�r�r�r�r=r<r�rRr[r�r�r�r�r�r�r�r�r�r�r�r�rr!rar�r r�r
r
r
r
r�sl�	
:�
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)zo
    Clone a node and give it the new owner document.
    Called by Node.cloneNode and Document.importNode
    TrwzCannot clone node %s)9rYrer7r8rrrsZ
NODE_IMPORTEDrr	rTr�rr�r�r�rr�rr�r�r(rXr=r3r�rPr�rQr�r�r�r�r3r�r�r�r�r}r\r�r�rhrirnrarortrSrrrwrurvrwrr`r�r:)
rIrZZnewOwnerDocumentrurxr
r�rWrHr�ryrzr{r
r
r
rX_s�
�


��
��rXcCs,|�dd�}t|�dkr|Sd|dfSdS)Nr�r2�r)r�r�)r�fieldsr
r
r
r�srcCs0||i|��}|��\}}|�|�|��|Sr&)ZgetEventZ
expandNoder�)�func�args�kwargsZeventsZtoktypeZrootNoder
r
r
�_do_pulldom_parse�s

r�cCsH|dur"|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|durddlm}|�|�Sddlm}t|j|fd|i�SdS)z&Parse a file into a DOM from a string.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)7r�rr�r7rrrrZxml.dom.minicompatZxml.dom.xmlbuilderrrr8r	rTr�rAZdefpropertyrKr�r�r�r�r�r��objectr�Z
AttributeListrr�rrr,r1r;r�rXr)r\r]r_rfrmrurtr�r�rBr�rXrr�r�r�r�r
r
r
r
�<module>s��w
	y$�
��)GU��	>�<(	O*U�R