%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/web/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/web/__pycache__/microdom.cpython-312.pyc

�

Ϫ�f���
��dZddlmZddlZddlZddlmZmZddlm	Z	m
Z
ddlmZddl
mZddlmZmZd	j%e
e	d
ddd���Zej(eed
��d�Zd�Zd�ZdZee�Zej9�edzZee�Zej9�efd�Zefd�Z Gd�de!�Z"Gd�d�Z#Gd�de#�Z$Gd�de#�Z%Gd�de#�Z&Gd �d!e&�Z'Gd"�d#e&�Z(Gd$�d%e&�Z)d&�Z*e*�Z+Gd'�d(e&�Z,Gd)�d*e#�Z-d+�Z.d,�Z/Gd-�d.e�Z0d/�Z1d0�Z2d1�Z3d2�Z4Gd3�d4�Z5y)5a�
Micro Document Object Model: a partial DOM implementation with SUX.

This is an implementation of what we consider to be the useful subset of the
DOM.  The chief advantage of this library is that, not being burdened with
standards compliance, it can remain very stable between versions.  We can also
implement utility 'pythonic' ways to access and mutate the XML tree.

Since this has not subjected to a serious trial by fire, it is not recommended
to use this outside of Twisted applications.  However, it seems to work just
fine for the documentation generator, which parses a fairly representative
sample of XML.

Microdom mainly focuses on working with HTML and XHTML.

This module is now deprecated.
�)�annotationsN)�BytesIO�StringIO)�Version�getVersionString)�ioType)�InsensitiveDict)�
ParseError�	XMLParserz)twisted.web.microdom was deprecated at {}�Twisted��
�)�
stacklevelc���g}|j}|g}t|�dkDrF|jd�}|j|k(r||�|j|ddt|�dkDr�F|S)a3
    Return a list of all child elements of C{iNode} with a name matching
    C{name}.

    Note that this implementation does not conform to the DOM Level 1 Core
    specification because it may return C{iNode}.

    @param iNode: An element at which to begin searching.  If C{iNode} has a
        name matching C{name}, it will be included in the result.

    @param name: A C{str} giving the name of the elements to return.

    @return: A C{list} of direct or indirect child elements of C{iNode} with
        the name C{name}.  This may include C{iNode}.
    rN)�append�len�pop�nodeName�
childNodes��iNode�name�matches�matches_append�slice�cs      �6/usr/lib/python3/dist-packages/twisted/web/microdom.py�getElementsByTagNamer)sh�� �G��^�^�N�
�G�E�

�e�*�q�.��I�I�a�L���:�:����1���L�L��b�q�	�	�e�*�q�.�
�N�c��|j�}g}|j}|g}t|�dkDrT|jd�}|jj�|k(r||�|j
|ddt|�dkDr�T|S�Nr)�lowerrrrrrrs      r�getElementsByTagNameNoCaser$Dsz���:�:�<�D��G��^�^�N�
�G�E�

�e�*�q�.��I�I�a�L���:�:�����%��1���L�L��b�q�	�	�e�*�q�.�
�Nr c�D��t��tk(r�fd�}|S�fd�}|S)Nc�j��t|t�r|jd�}�j|�y�Nzutf-8)�
isinstance�str�encode�write��s�streams �r�wz_streamWriteWrapper.<locals>.wTs&����!�S�!��H�H�W�%���L�L��Or c�j��t|t�r|jd�}�j|�yr')r(�bytes�decoder+r,s �rr/z_streamWriteWrapper.<locals>.w[s&����!�U�#��H�H�W�%���L�L��Or )rr1)r.r/s` r�_streamWriteWrapperr3Qs'���
�f�~���	�
�H�	�

�Hr ))�&z&amp;)�<z&lt;)�>z&gt;)�"z&quot;))�'z&apos;c�>�|D]\}}|j||�}�|S)z1
    Perform the exact opposite of 'escape'.
    ��replace��text�charsr-�hs    r�unescaper@r�,���"���1��|�|�A�q�!��"��Kr c�>�|D]\}}|j||�}�|S)z;
    Escape a few XML special chars with XML entities.
    r:r<s    r�escaperC{rAr c��eZdZd�Zdd�Zy)�MismatchedTagsc�l�|||||||f\|_|_|_|_|_|_|_y�N)�filename�expect�got�begLine�begCol�endLine�endCol)�selfrHrIrJrMrNrKrLs        r�__init__zMismatchedTags.__init__�s>���v�s�G�V�W�f�E�	
��M��K��H��L��K��L��Kr c��d|j�d|j�d|j�d|j�d|j�d|j
��S)Nzexpected </z	>, got </z> line: z col: z, began line: )rIrJrMrNrKrL�rOs r�__str__zMismatchedTags.__str__�s8��
������������������	
�	
r N��returnr))�__name__�
__module__�__qualname__rPrS�r rrErE�s
��	F�
r rEc��eZdZdZdd�Zd�Zddddidfd�Zddddidfd�Zdd�Zdd	�Z	dd
�Z
d�Zd�Zd
�Z
d�Zd�Zd�Zd�Zy)�NodeNc� �||_g|_yrG)�
parentNoder)rOr]s  rrPz
Node.__init__�s��$�����r c���t|j�t|j�k7ryt|j|j�D]\}}|j|�r�yy)a
        Compare this node to C{other}.  If the nodes have the same number of
        children and corresponding children are equal to each other, return
        C{True}, otherwise return C{False}.

        @type other: L{Node}
        @rtype: C{bool}
        FT)rr�zip�
isEqualToNode)rO�other�a�bs    rr`zNode.isEqualToNode�s[���t����3�u�'7�'7�#8�8�������)9�)9�:�	�D�A�q��?�?�1�%��	�r �rc��t��rG��NotImplementedError)rOr.�indent�	addindent�newl�strip�
nsprefixes�	namespaces        r�writexmlz
Node.writexml�s
��"�#�#r c	�h�t�}|j|||||||�|j�}|SrG)rrn�getvalue)	rOrhrirjrkrlrmr-�rvs	         r�toxmlz
Node.toxml�s3��
�J���
�
�a���D�%��Y�O�
�Z�Z�\���	r c�,�|j|||||�SrG)rn)rOr.rhrirjrks      r�writeprettyxmlzNode.writeprettyxml�s���}�}�V�V�Y��e�D�Dr c�*�|j||||�SrG)rr)rOrhrirjrks     r�toprettyxmlzNode.toprettyxml�s���z�z�&�)�T�5�9�9r c��t��rGrf�rO�deep�parents   r�	cloneNodezNode.cloneNode�s��!�#�#r c��|jryy)N�r�rrRs r�
hasChildNodeszNode.hasChildNodes�s���?�?��r c�~�t|t�std��|jj	|�||_y)z�
        Make the given L{Node} the last child of this node.

        @param child: The L{Node} which will become a child of this node.

        @raise TypeError: If C{child} is not a C{Node} instance.
        �expected Node instanceN)r(r[�	TypeErrorrrr]�rO�childs  r�appendChildzNode.appendChild�s4���%��&��4�5�5������u�%���r c���t|t�rt|t�std��|jj	|�}||_|jj
||�|S)a�
        Make the given L{Node} C{new} a child of this node which comes before
        the L{Node} C{ref}.

        @param new: A L{Node} which will become a child of this node.

        @param ref: A L{Node} which is already a child of this node which
            C{new} will be inserted before.

        @raise TypeError: If C{new} or C{ref} is not a C{Node} instance.

        @return: C{new}
        r�)r(r[r�r�indexr]�insert)rO�new�ref�is    r�insertBeforezNode.insertBefore�sW���#�t�$�J�s�D�,A��4�5�5��O�O�!�!�#�&����������q�#�&��
r c��t|t�std��||jvr"|jj	|�d|_|S)a7
        Remove the given L{Node} from this node's children.

        @param child: A L{Node} which is a child of this node which will no
            longer be a child of this node after this method is called.

        @raise TypeError: If C{child} is not a C{Node} instance.

        @return: C{child}
        r�N)r(r[r�r�remover]r�s  r�removeChildzNode.removeChild�sE���%��&��4�5�5��D�O�O�#��O�O�"�"�5�)�#�E���r c��t|t�rt|t�std��|j|urt	d��||j
|j
j
|�<d|_||_y)a�
        Replace a L{Node} which is already a child of this node with a
        different node.

        @param newChild: A L{Node} which will be made a child of this node.

        @param oldChild: A L{Node} which is a child of this node which will
            give up its position to C{newChild}.

        @raise TypeError: If C{newChild} or C{oldChild} is not a C{Node}
            instance.

        @raise ValueError: If C{oldChild} is not a child of this C{Node}.
        r�z$oldChild is not a child of this nodeN)r(r[r�r]�
ValueErrorrr�)rO�newChild�oldChilds   r�replaceChildzNode.replaceChild
sj���(�D�)��H�d�1K��4�5�5����d�*��C�D�D�;C�������-�-�h�7�8�"���"��r c� �|jdS�N���r~rRs r�	lastChildzNode.lastChild$s�����r�"�"r c�L�t|j�r|jdSyr")rrrRs r�
firstChildzNode.firstChild's ���t�����?�?�1�%�%�r rG)rd� �
r�rN)rVrWrXrrPr`rnrrrtrvr{rr�r�r�r�r�r�rYr rr[r[�sr���H���&��
����
$��2�B�a�B�RT��E�:�$�� ��*�$#�.#�r r[c�~�eZdZUdd�Zdd�ZdZded<d�ZeZe	d��Z
d	�Zd
d
d
did
fd�Zd�Z
d
�Zd�Zd�Zd�Zy)�DocumentNc�V�tj|�|r|j|�yyrG)r[rPr�)rO�documentElements  rrPzDocument.__init__:s$���
�
�d������_�-�r rc��t�}|j|_|r|jjd|�}n|j}|j	|�|S�Nr})r��doctyper�r{r�)rOryrz�d�newEls     rr{zDocument.cloneNode?sK���J���L�L��	���(�(�2�2�1�d�;�E��(�(�E�	�
�
�e���r z
None | strr�c�d�|j|jk(xrtj||�SrG)r�r[r`�rO�ns  r�isEqualToDocumentzDocument.isEqualToDocumentKs'������	�	�)�J�t�/A�/A�$��/J�Jr c� �|jdSr"r~rRs rr�zDocument.documentElementPs�����q�!�!r c�^�|jrtd��tj||�y)a
        Make the given L{Node} the I{document element} of this L{Document}.

        @param child: The L{Node} to make into this L{Document}'s document
            element.

        @raise ValueError: If this document already has a document element.
        zOnly one element per document.N)rr�r[r�r�s  rr�zDocument.appendChildTs'���?�?��=�>�>�����u�%r rdc	��t|�}|d|z�|jr|d|j�d|���|jj|||||||�y)Nz<?xml version="1.0"?>z
<!DOCTYPE r6)r3r�r�rn�	rOr.rhrirjrkrlrmr/s	         rrnzDocument.writexmlas_��
 ��'��	�
!�D�
(�)��<�<�
�
�4�<�<�.��$��0�1����%�%��F�I�t�U�J�	�	
r c��t|fi|��SrG)�Element)rOr�kws   r�
createElementzDocument.createElementus���t�"�r�"�"r c��t|�SrG)�Text�rOr=s  r�createTextNodezDocument.createTextNodexs���D�z�r c��t|�SrG)�Commentr�s  r�
createCommentzDocument.createComment{s���t�}�r c�^�|jjrt||�St||�SrG)r��caseInsensitiver$r�rOrs  rrzDocument.getElementsByTagName~s+�����/�/�-�d�D�9�9�#�D�$�/�/r c���|jdd}|r^|jd�}|jr|j|j�t|d�r|j	d�|k(r|S|r�]yy)Nr�getAttribute�id)rr�extend�hasattrr�)rOr�r�nodes    r�getElementByIdzDocument.getElementById�s`���_�_�Q�'�
���>�>�!�$�D�����!�!�$�/�/�2��t�^�,��1B�1B�4�1H�B�1N���r rGr�)rVrWrXrPr{r��__annotations__r�r`�propertyr�r�rnr�r�r�rr�rYr rr�r�9sn��.�
��G�Z��K�&�M�
�"��"�&� ��
����
�(#���0�
r r�c�:�eZdZdd�Zd�ZeZddddidfd�Zd	d�Zy)
�EntityReferenceNc�f�tj||�||_d|zdzx|_|_y)Nr4�;)r[rP�eref�	nodeValue�data)rOr�r]s   rrPzEntityReference.__init__�s.���
�
�d�J�'���	�%(�4�Z�#�%5�5����r c��t|t�sy|j|jk(xr|j|jk(Sr")r(r�r�r�r�s  r�isEqualToEntityReferencez(EntityReference.isEqualToEntityReference�s4���!�_�-���	�	�Q�V�V�#�H�$�.�.�A�K�K�*G�Hr rdrc�D�t|�}|d|jz�y)Nrd�r3r�r�s	         rrnzEntityReference.writexml�s��
 ��'��	�"�t�~�~�
�r c�.�t|j|�SrG)r�r�rxs   rr{zEntityReference.cloneNode�s���t�y�y�&�1�1r rGr�)rVrWrXrPr�r`rnr{rYr rr�r��s2��6�
I�
-�M�
��
�����2r r�c��eZdZdd�Zd�ZeZy)�
CharacterDataNc�Z�tj||�|x|_x|_|_yrG)r[rP�valuer�r�)rOr�r]s   rrPzCharacterData.__init__�s%���
�
�d�J�'�26�6��
�6�T�Y��r c�4�|j|jk(SrG)r�r�s  r�isEqualToCharacterDataz$CharacterData.isEqualToCharacterData�s���z�z�Q�W�W�$�$r rG)rVrWrXrPr�r`rYr rr�r��s��7�%�+�Mr r�c�,�eZdZdZddddidfd�Zdd�Zy)r�z
    A comment node.
    rdrc�J�t|�}|j}	|d|	�d��y)Nz<!--z-->)r3r�)
rOr.rhrirjrkrlrmr/�vals
          rrnzComment.writexml�s'��
 ��'���i�i��	�D���S�/�r Nc�.�t|j|�SrG)r�r�rxs   rr{zComment.cloneNode�s���t�~�~�v�.�.r r�)rVrWrX�__doc__rnr{rYr rr�r��s%�����
�����/r r�c�>�eZdZd	d�Zd�Zd
d�Zddddidfd�Zdd�Zy)r�Nrc�@�tj|||�||_yrG)r�rP�raw)rOr�r]r�s    rrPz
Text.__init__�s�����t�T�:�6���r c�d�tj||�xr|j|jk(S)z�
        Compare this text to C{text}.  If the underlying values and the C{raw}
        flag are the same, return C{True}, otherwise return C{False}.
        )r�r`r��rOras  rr`zText.isEqualToNode�s)��
�*�*�4��7�Q�D�H�H��	�	�<Q�Qr c�D�t|j||j�SrG)r�r�r�rxs   rr{zText.cloneNode�s���D�N�N�F�D�H�H�5�5r rdc�L�t|�}|jr2|j}	t|	t�sit	|j�}	nS|j}
t|
t�st	|
�}
|rdj|
j
��}
t|
�}	||	�y)Nr�)r3r�r�r(r)�join�splitrC)rOr.rhrirjrkrlrmr/r��vs           rrnz
Text.writexml�sy��
 ��'���8�8��.�.�C��c�3�'��$�.�.�)�����A��a��%���F����H�H�Q�W�W�Y�'����)�C�	�#�r c�8�dt|j�zdzS)NzText(%s�))�reprr�rRs r�__repr__z
Text.__repr__�s���4����/�/�#�5�5r r"r�rT)rVrWrXrPr`r{rnr�rYr rr�r��s0���R�6���
�����06r r�c�(�eZdZdd�Zddddidfd�Zy)�CDATASectionrNc�.�t|j|�SrG)r�r�rxs   rr{zCDATASection.cloneNode�s���D�N�N�F�3�3r rdc�d�t|�}|d�|d|jz�|d�y)Nz	<![CDATA[rdz]]>r�r�s	         rrnzCDATASection.writexml�s-��
 ��'��	�+��	�"�t�~�~�
��	�%�r r�)rVrWrXr{rnrYr rr�r��s ��4���
����
r r�c#�<K�d}	dt|�z��|dz}��w)Nr�pr})r))r�s r�
_genprefixr�s*����	�A�
��C��F�l��
��E���s�c��eZdZdZy)�_Attrz#Support class for getAttributeNode.N)rVrWrXr�rYr rr�r�s��)r r�c��eZdZdZdZdZ							dd�Zd�Zd�Zd�Z	d�Z
dd	�Zd
�Zd�Z
dd�Zdd
�Zd�Zd�Zd�Zd�Zddddidfd�Zdd�Zdd�Zy)r�rr}Nc	��tj||�|xs||_||_|s|j	�}|�i|_nA||_|j
j
�D]\}	}
t|
�|j
|	<�|rt|j
|��|_|x|_	x|_
|_||_||_
||_y)N)�preserve)r[rP�preserveCaser�r#�
attributes�itemsr@r	�
endTagNamer�tagName�	_filename�_markposrm)rOr�r�r]rH�markposr�r�rm�kr�s           rrPzElement.__init__s���	
�
�
�d�J�'�(�?��,?���.�����m�m�o�G��� �D�O�(�D�O����-�-�/�
1���1�%-�a�[�����"�
1��-�d�o�o��U�D�O�9@�@���@�$�-�$�,�!�����
�"��r c�b�|j�||_y|jj|�yrG)rl�update)rO�pfxss  r�addPrefixeszElement.addPrefixes>s%���?�?�"�"�D�O��O�O�"�"�4�(r c�J�|js|j�}||_yrG)r�r#r�)rOr�s  r�endTagzElement.endTagDs ��� � �#�)�)�+�J�$��r c�"�|jrP|j|jk(xr5|jj�|jj�k(S|j|jk(xr|j|jk(SrG)r�r�rr#r�s  r�isEqualToElementzElement.isEqualToElementIsn������O�O�q�|�|�3���
�
�#�#�%����)9�)9�);�;�
����1�<�<�/�R�d�m�m�q�z�z�6Q�Rr c��|jj�|jj�k(xrL|j|jk(xr1|j|jk(xrtj||�S)z�
        Compare this element to C{other}.  If the C{nodeName}, C{namespace},
        C{attributes}, and C{childNodes} are all the same, return C{True},
        otherwise return C{False}.
        )rr#rmr�r[r`r�s  rr`zElement.isEqualToNodePsn��
�M�M���!�U�^�^�%9�%9�%;�;�
0����%�/�/�1�
0����5�#3�#3�3�
0��"�"�4��/�		
r c�>�t|j||j|j|j��}|j
j
|j
�|r1|jD�cgc]}|jd|���c}|_|Sg|_|Scc}w)N)r]rmr�r�r})	r�r�rmr�r�r�rrr{)rOryrz�cloner�s     rr{zElement.cloneNode]s�����L�L���n�n��*�*� �0�0�
��	��������0��GK���W�e�����5� 9�W�E���� "�E����� Xs�.Bc�J�|jrt||�St||�SrG)r�r$rr�s  rrzElement.getElementsByTagNamels%�����-�d�D�9�9�#�D�$�/�/r c��yr�rYrRs r�
hasAttributeszElement.hasAttributesqs��r c�:�|jj||�SrG)r��get)rOr�defaults   rr�zElement.getAttributets�����"�"�4��1�1r c��||f}||jvr|j|S||jk(r|jj||�S|SrG)r�rmr)rO�nsrr�nsks     r�getAttributeNSzElement.getAttributeNSwsN���4�j���$�/�/�!��?�?�3�'�'�
������?�?�&�&�t�W�5�5��r c�8�t|j|�|�SrG)r�r�r�s  r�getAttributeNodezElement.getAttributeNodes���T�&�&�t�,�d�3�3r c�"�||j|<yrG�r�)rOr�attrs   r�setAttributezElement.setAttribute�s�� $�����r c�<�||jvr|j|=yyrGrr�s  r�removeAttributezElement.removeAttribute�s���4�?�?�"�����%�#r c��||jvSrGrr�s  r�hasAttributezElement.hasAttribute�s���t���&�&r rdc
���d}d}	d}
|js|j|_t|�}|jr8|jj�}|j
�D]
}
|
|vs�||
=�ni}dg}|j|	vr||g|z}|j��fd�}|j}||jk7r�|j�z|j|vr:||j}�|dz|jz�|dz|jz}nD�|j�|d|j�|j}n�|j�d	j}t|jj��D]Y\}}t|t�r7|\}
}|
|vr||
}ntt �}|||
<|�J�||dz|z|��M|�J�|||��[|r;|j�D]\}
}|s�	|d
|z|
��|j#|�|}n|}|||��|j$r�|d�||z}|j$D]E}|j|	vr|j|
vr||||f��|j'|||||||��G|j|	vr||||f��||d|df��y|jj)�|vr||d
|df��y|d�y)a*
        Serialize this L{Element} to the given stream.

        @param stream: A file-like object to which this L{Element} will be
            written.

        @param nsprefixes: A C{dict} mapping namespace URIs as C{str} to
            prefixes as C{str}.  This defines the prefixes which are already in
            scope in the document at the point at which this L{Element} exists.
            This is essentially an implementation detail for namespace support.
            Applications should not try to use it.

        @param namespace: The namespace URI as a C{str} which is the default at
            the point in the document at which this L{Element} exists.  This is
            essentially an implementation detail for namespace support.
            Applications should not try to use it.
        )
�img�br�hr�base�meta�link�param�area�input�col�basefont�isindex�frame)�html�head�body�noscript�ins�del�h1�h2�h3�h4�h5�h6�script�ul�ol�dl�prer"�
blockquote�addressr��div�fieldset�table�tr�form�objectrA�applet�map)rCr:r;r.r5c�0���d|dt|�df�S)Nr�z="r7)rC)�_atr�_val�bexts  �r�<lambda>z"Element.writexml.<locals>.<lambda>�s���t�S�$��f�T�l�C�,P�'Q�r N�:�xmlnsrdzxmlns:r6z</z></� />)r�r�r�r3rl�copy�keysr�rmr��sortedr�r�r(�tuple�next�	genprefixrrrnr#)rOr.rhrirjrkrlrm�ALLOWSINGLETON�
BLOCKELEMENTS�FORMATNICELYr/�newprefixesr�begin�	writeattrr��prefix�jrr��key�downprefixes�	newindentr�rKs                         @rrnzElement.writexml�s���8
��
�
�@2��� � �"�l�l�D�O���'���?�?��/�/�.�.�0�K� �o�o�'�
(����$�#�B��
(��K�����<�<�=�(��6�N�U�*�E��|�|��Q�	�
�_�_�
�����&�4�>�>�+E��~�~��+�$�D�N�N�3���V�c�\�D�L�L�0�1�#�c�\�D�O�O�;�
��T�\�\�"��'�4�>�>�2�!�N�N�	�
������G�G������ 5� 5� 7�8�	%�I�D�#��$��&����C���#�'��^�F�!�)�_�F�&,�K��O���&���&�3�,��,�c�2���&���$��$�	%��)�/�/�1�
5�
��F���h��/��4�
5�
���z�*�&�L�%�L�	�!�E�(���?�?�
�c�F���*�I����
���<�<�=�0�T�\�\�\�5Q��a��y�)�*�+�����I�y�$��|�Y��
��|�|�}�,��!�T�6�N�#�$�
�a��z�3�'�(�)�
�\�\�
�
�
!��
7�
�a��
�C�(�)�*�
�e�Hr c���dt|j�z}|jr|d|j��z
}|jr|d|j��z
}|jr|d|j��z
}|dzS)Nz
Element(%sz
, attributes=z, filename=z
, markpos=r�)r�rr�r�r�)rO�reps  rr�zElement.__repr__5sv���T�$�-�-�0�0���?�?��]�4�?�?�"5�6�6�C��>�>��[���� 2�3�3�C��=�=��Z��
�
�0�1�1�C��S�y�r c��d|jz}|js|jr|dz
}|jr|t|j�z
}|jr|d|jzz
}|js|jr|dz
}|jj�D]
}|d|zz
}�|j
�r|d|jzz
}|S|dz
}|S)Nr5z (z line %s column %sr�z %s=%rz
 >...</%s>rO)rr�r�r�r�r�r)rOrb�items   rrSzElement.__str__?s����D�M�M�!���>�>�T�]�]��4�K�C��>�>��4����'�'�C��=�=��'�$�-�-�7�7�C��>�>�T�]�]��3�J�C��O�O�)�)�+�	#�D��8�d�?�"�C�	#������<�$�-�-�/�/�C��
�
�5�L�C��
r )NNNNr}rNr�rGrT)rVrWrXr�r�rlrPrrrr`r{rr
r�rrrrrrnr�rSrYr rr�r�s����L��O��J�
�������#�>)�%�
S�
�
�0�
�2��4�%�&�'���
����g�R�r r�c�V�i}|j�D]\}}t|�||<�|SrG)r�r@�r��ddr�r�s    r�
_unescapeDictrhRs2��	�B����	����1�����1���
�Ir c�D�i}|j�D]
\}}|||<�|SrG)r�rfs    r�_reverseDictrjYs.��	�B����	����1���1���
�Ir c��eZdZdj�Zddgddgddgdggd�gd�gd�dgdgd	gd
gdgdgd
dgdgd�Zdddeefd�Zd�Zd�Ze	jd�Zd�Zd�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy )!�MicroDOMParserz#area link br img hr input base metar��dtrg�li)�thead�tfoot�tbody�colgroupr)rC�td�thr/r.�option)r�rmrgrnrqrorprrr)rCrsrtr.�titlerurr}c��g|_ddd�}t|�}|d|fg|_g|_d|_||_||_|xs||_||_||_	y)NrN)rNrd)
�elementstackrj�nsstack�	documents�
_mddoctype�beExtremelyLenientr�r��soonClosers�laterClosers)rOr|r�r�r}r~r��drs        rrPzMicroDOMParser.__init__xsl������4�(��
�!�_���D�"�
����������"4���.���(�?��,?���&���(��r c��tt|j��D]8}|j|}|jdk(s|j	dd�dk(s�8yy)Nr=z	xml:spacerdr�r}r)�rangerrxr�r�)rO�edx�els   r�shouldPreserveSpacez"MicroDOMParser.shouldPreserveSpace�sY����T�.�.�/�0�	�C��"�"�C�4�(�B��z�z�U�"�b�o�o�k�2�&F�*�&T��	�r c�:�|jr|jdSyr�)rxrRs r�
_getparentzMicroDOMParser._getparent�s������$�$�R�(�(�r z\s*/[/*]\s*c��|jrt|j�dk(sy|j�}t	|t
�r�d}|j}|jj|�}|r|j�}|t|�d}	td|z�jd}t|j�dk7ry|j�}t	|ttf�rIg|_|r$|jjt|��|jj|�yyy#ttf$rYywxYw)Nr}rdz	<a>%s</a>r)r|rrr�r(r�r��COMMENT�match�group�parseStringr
rEr�r�r)rOr�rr\�oldvaluer��es       r�_fixScriptElementz MicroDOMParser._fixScriptElement�s���&�&�c�"�-�-�.@�A�.E���M�M�O���a����F��w�w�H��L�L�&�&�x�0�E�������#�C��K�M�2��
���h� 6�7�B�B�1�E���1�<�<� �A�%������A��!�l�G�4�5� "��
���M�M�(�(��f��6��
�
�$�$�Q�'�	6�+�� ��/�
��
�s�D5�5E�Ec��||_yrG)r{)rOr�s  r�
gotDoctypezMicroDOMParser.gotDoctype�s	��!��r c���|j�}|jr�t|t�r�|j}|}|j
r |j
�}|j
�}||jj|g�vr+|j|j�|j�}t|�}|jdd}i}g}|j�D]V\}	}
|	jd�s�|	jdd�}t|�dk(r	|
||d<n|
|d<|j!|	��X|D]}	||	=�|r!|j#�}|j%|�g}|j�D]Q\}	}
|	jdd�}t|�dk(s�'|\}
}|
dk7s�2|
|vs�7|
|||
|f<|j!|	��S|D]}	||	=�t||||j&|j)�|j
|j*|jd��	�}t-|�}|j/|�|rO|jddj#�}|j%|�|jj!|||f�|j0j!|�|r|j3|�|jr+|j|j4vr|j|�yyy)
Nr�rrNrMr}�rd�xml)r�r�rm)r�r|r(r�r�r�r#r~r�	gotTagEndrhryr��
startswithr�rrrPrrH�saveMarkr�rjrrxr�r})rOrr�rz�
parentName�myName�
namespaces�	newspaces�keysToDeleter�r��
spacenames�ksplit�pfx�tvr��	revspaces�rscopys                  r�gotTagStartzMicroDOMParser.gotTagStart�s������"���"�"�z�&�'�'B����J��F��#�#�'�-�-�/�
��������*�*�.�.�z�2�>�>����v�~�~�.����*��"�:�.�
��\�\�"�%�a�(�
��	����$�$�&�	'�D�A�q��|�|�G�$��W�W�S�!�_�
��z�?�a�'�/0�I�j��m�,�$%�I�b�M��#�#�A�&�	'��	�A��1�
�	��#���*�J����i�(����$�$�&�	+�D�A�q��W�W�S�!�_�F��6�{�a�� ���R��%�<�C�:�$5�67�J�z�#���2�3� �'�'��*�
	+��	�A��1�
�	�
�����M�M��M�M�O� �0�0��*�*� �n�n�R�(�	
��!��+�	�
���y�!���\�\�"�%�a�(�-�-�/�F��M�M�)�$��L�L����R�� 8�9���� � ��$�����r�"��"�"�r�z�z�T�5E�5E�'E��N�N�4� �(F�"r c��|j�}|||�}|r|j|�y|jr|jj	|�yyrG)r�r�r|rzr)rO�factoryr�rz�tes     r�_gotStandalonezMicroDOMParser._gotStandalone�sK�����"��
�T�6�
"������r�"�
�
$�
$��N�N�!�!�"�%�%r c�r�|j�s|j�r|jt|�yyrG)rkr�r�r��rOr�s  r�gotTextzMicroDOMParser.gotTexts+���:�:�<�4�3�3�5�����d�+�6r c�0�|jt|�yrG)r�r�r�s  r�
gotCommentzMicroDOMParser.gotComments�����G�T�*r c�0�|jt|�yrG)r�r�)rO�	entityRefs  r�gotEntityReferencez!MicroDOMParser.gotEntityReferences�����O�Y�7r c�0�|jt|�yrG)r�r�)rO�cdatas  r�gotCDatazMicroDOMParser.gotCDatas�����L�%�0r c�F�|js6|jryt|jd|f|j	�zdz��|jj�}|jdd}|jdd|ur|jj�}nd}|jr+|jj�}|j�}n|j}|}|jdd�}t|�dk(rq|\}}	|j|d�}
|
�X|j|
k7rI|js=t|j|j|f|j	�z|jz��||k(�s@|jr�|j�r'|jd}tt|j��D]F}|j|dzj|k(s�$|j|dzj!|�n:|jj#|�|�|jj#|�y|j|dzd�=|jsY|j$j#|�yt|j|j|f|j	�z|jz��|j!|�|js|j$j#|�|jr"|jdk(r|j'|�yyy)	N�NOTHING)rrr�r�r}rMrr9)rxr|rErHr�rryr�r�r#r�rrrmr�r�rrrzr�)
rOrr��pfxdix�nstuple�tn�cname�nsplitr��newnamer�lastEl�idxs
             rr�zMicroDOMParser.gotTagEnds���� � ��&�&�� ��=�=�)�T�2�T�]�]�_�D�v�M��
��
�
�
"�
"�
$�����b�!�!�$���<�<���A��"�$��l�l�&�&�(�G��G�������!�!�#�B��J�J�L�E����B��E����C��#���v�;�!��!�L�C�����C��&�B��~��<�<�2�%��2�2�,�!%����
�
�D� A�"&�-�-�/�!2�"$�+�+�!.����e���&�&��$�$�!�.�.�q�1�F�$�S��):�):�%;�<�	���,�,�s�Q�w�Z�8�@�@�E�I� �-�-��a��j�9�@�@��F�!�	��)�)�0�0��4�"�.� �L�L�/�/��8���)�)�C�!�G�*�,�7��,�,����-�-�f�5��$��}�}�b�j�j�$�7�$�-�-�/�I�B�K�K�W���	�	�	�$��� � ��N�N�!�!�"�%��"�"�r�z�z�X�'=��"�"�2�&�(>�"r c�L�tj||�|jr�|jr)|jj|jd�yt
|j|jddf|j�z|jdjz��y)Nrr��END_OF_FILE)
r�connectionLostrxr|rzrrErHr�r�)rO�reasons  rr�zMicroDOMParser.connectionLostTs���� � ��v�.�����&�&����%�%�d�&7�&7��&:�;�$�����(9�(9�"�(=�}�M��-�-�/�*��+�+�B�/�8�8�9���	r N)rVrWrXr�r}r~rPr�r��re�compiler�r�r�r�r�r�r�r�r�r�r�rYr rrlrl`s���
8�=�=�?�K��4�[��T�l��T�l��f�,�,�,��L��w��f��f��f����&�!��*��L�(����!�
)�*���b�j�j��(�G�(�B"�=!�~&�,�+�8�1�>'�@r rlc�:�t|d�st|d�}t|i|��}t|dd�|_|jd�t|d�r |j
|j��n8|jd�}|r%|j
|�|jd�}|r�%|jd�|jst|jddd	��|jr�t|j�d
k(r>|jd}t|t�s\td�}|j!|�|}n=td�}|jD]}|j!|��n|jd}t#|�}|j$|_|S)z%
    Parse HTML or XML readable.
    �read�rbrz<xmlfile />NrpirzNo top-level Nodes in documentr}r-)r��openrl�getattrrH�makeConnection�dataReceivedrpr�r�rzr
r|rr(r�r�r�r{r�)	�readable�args�kwargs�mdp�rr�r�r��docs	         r�parser�csd���8�V�$���$�'��
�$�
)�&�
)�C��8�V�]�;�C�L����t���x��$�����*�*�,�-��M�M�$�������Q���
�
�d�#�A�����t���=�=�����q�!�-M�N�N�
����s�}�}���"��
�
�a� �A��a��)��V�_�����q�!������A����
%���
�
�e�$�
%�
�M�M�!���
�1�+�C��.�.�C�K��Jr c��t|t�r'tt|j	d��g|��i|��Stt|�g|��i|��S)NzUTF-16)r(r)r�rr*)�str�r�s   rr�r��sH���"�c���W�R�Y�Y�x�0�1�?�D�?�B�?�?�����*�t�*�r�*�*r c��t|dd��S�z'
    Parse an XML readable object.
    rr}�r�r�)r�)r�s r�parseXMLr��s����1�1�=�=r c��t|dd��Sr�)r�)r�s r�parseXMLStringr��s���r�1�1�=�=r c�8�eZdZdZd	d�Zd�Zd�Zd�Zd
d�Zd�Z	y)�lmxz
    Easy creation of XML.
    c�H�t|t�rt|�}||_yrG)r(r)r�r�)rOr�s  rrPzlmx.__init__�s���d�C� ��4�=�D���	r c�8����ddk(rtd����fd�S)Nr�_zno private attrsc�*���j�fi|��SrG)�add)r�rrOs ��rrLz!lmx.__getattr__.<locals>.<lambda>�s���H�D�H�H�T�0�R�0�r )�AttributeErrorr�s``r�__getattr__zlmx.__getattr__�s �����7�c�>� �!3�4�4�0�0r c�<�|jj||�yrG)r�r)rOr^r�s   r�__setitem__zlmx.__setitem__�s���	�	���s�C�(r c�8�|jj|�SrG)r�r�)rOr^s  r�__getitem__zlmx.__getitem__�s���y�y�%�%�c�*�*r c�V�t||��}|jj|�|S)N)r�)r�r�r�)rO�txtr��nns    rr=zlmx.text�s%��
�#�3�
���	�	���b�!��r c���t|dd��}|jj|�t|�}|j	�D]\}}|ddk(r|dd}|||<�|S)Nrr�r�r})r�r�r�r�r�)rOr�r��newNode�xfr�r�s       rr�zlmx.add�sj���'�1�1�E���	�	���g�&�
��\���H�H�J�	�D�A�q���t�s�{��a�b�E���B�q�E�	��	r N)r@)r)
rVrWrXr�rPr�r�r�r=r�rYr rr�r��s%����
1�
)�+��
r r�)6r��
__future__rr��warnings�iorr�incrementalrr�twisted.python.compatr�twisted.python.utilr	�twisted.web.suxr
r�format�
warningString�warn�DeprecationWarningrr$r3�HTML_ESCAPE_CHARS�list�REV_HTML_ESCAPE_CHARS�reverse�XML_ESCAPE_CHARS�REV_XML_ESCAPE_CHARSr@rC�	ExceptionrEr[r�r�r�r�r�r�r�rUr�r�rhrjrlr�r�r�r�r�rYr r�<module>r�s����"#�
�� �1�)�/�1�;�B�B��W�Y��B��2�3��
���
�
�m�/�A�>��6
�
�&���.�/������$�'9�9���,�-������/��)��
�Y�
�6K�K�tQ�t�Q�h2�d�2�<+�D�+�/�m�/�.(6�=�(6�V�=��(�
�L�	�*�M�*�u�d�u�p	��@�Y�@�F$�N+�>�>�"�"r 

Zerion Mini Shell 1.0