Hacked By AnonymousFox

Current Path : /opt/alt/python312/lib64/python3.12/xml/etree/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/xml/etree/__pycache__/ElementTree.cpython-312.pyc

�

7�f!!����dZgd�ZdZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZGd�de
�Zd	�ZGd
�d�Zifd�ZdCd
�ZdCd�ZeZGd�d�ZGd�d�Ze	j.d��ZdCd�Zd�Zhd�Zd�Zd�Zeeed�Zd�Zdddddd d!d"�Z e e_ d#�Z!d$�Z"d%�Z#d&�Z$dDddd'd(�d)�Z%Gd*�d+ejL�Z'dDddd'd(�d,�Z(d-�Z)dEd.�Z*dCd/�Z+dDd0�Z,Gd1�d2�Z-dCd3�Z.dCd4�Z/e.Z0dCd5�Z1Gd6�d7�Z2Gd8�d9�Z3dCddd:�d;�Z4ejjd<ejl�jnZ8Gd=�d>�Z9d?�Z:d@�Z;	eZ<ddAl=�ddBl=m>Z>e>ee�y#e?$rYywxYw)FaLightweight XML support for Python.

 XML is an inherently hierarchical data format, and the most natural way to
 represent it is with a tree.  This module has two classes for this purpose:

    1. ElementTree represents the whole XML document as a tree and

    2. Element represents a single node in this tree.

 Interactions with the whole document (reading and writing to/from files) are
 usually done on the ElementTree level.  Interactions with a single XML element
 and its sub-elements are done on the Element level.

 Element is a flexible container object designed to store hierarchical data
 structures in memory. It can be described as a cross between a list and a
 dictionary.  Each Element has a number of properties associated with it:

    'tag' - a string containing the element's name.

    'attributes' - a Python dictionary storing the element's attributes.

    'text' - a string containing the element's text content.

    'tail' - an optional string containing text after the element's end tag.

    And a number of child elements stored in a Python sequence.

 To create an element instance, use the Element constructor,
 or the SubElement factory function.

 You can also use the ElementTree class to wrap an element structure
 and convert it to and from XML.

)�Comment�dump�Element�ElementTree�
fromstring�fromstringlist�indent�	iselement�	iterparse�parse�
ParseError�PI�ProcessingInstruction�QName�
SubElement�tostring�tostringlist�TreeBuilder�VERSION�XML�XMLID�	XMLParser�
XMLPullParser�register_namespace�canonicalize�C14NWriterTargetz1.3.0�N�)�ElementPathc��eZdZdZy)rz�An error when parsing an XML document.

    In addition to its exception value, a ParseError contains
    two extra attributes:
        'code'     - the specific exception code
        'position' - the line and column of the error

    N)�__name__�
__module__�__qualname__�__doc__���</opt/alt/python312/lib64/python3.12/xml/etree/ElementTree.pyrrks���	r%rc��t|d�S)z2Return True if *element* appears to be an Element.�tag)�hasattr)�elements r&r	r	ys���7�E�"�"r%c���eZdZdZdZ	dZ	dZ	dZ	ifd�Zd�Z	d�Z
d�Zd�Zd�Z
d	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zdd�Zdd�Zdd�Zdd�Zd�Zdd�Zd�Zd�Zd�Zdd�Zd�Z y)rahAn XML element.

    This class is the reference implementation of the Element interface.

    An element's length is its number of subelements.  That means if you
    want to check if an element is truly empty, you should check BOTH
    its length AND its text attribute.

    The element tag, attribute names, and attribute values can be either
    bytes or strings.

    *tag* is the element name.  *attrib* is an optional dictionary containing
    element attributes. *extra* are additional element attributes given as
    keyword arguments.

    Example form:
        <tag attrib>text<child/>...</tag>tail

    Nc��t|t�s"td|jj����||_i|�|�|_g|_y)Nzattrib must be dict, not )�
isinstance�dict�	TypeError�	__class__r r(�attrib�	_children)�selfr(r1�extras    r&�__init__zElement.__init__�sL���&�$�'��� � �)�)�,�-�
-����)��)�5�)�����r%c�`�d|jj|jt|�fzS)Nz<%s %r at %#x>)r0r r(�id�r3s r&�__repr__zElement.__repr__�s&���4�>�>�#:�#:�D�H�H�b��h�"O�O�Or%c�&�|j||�S)z�Create a new element with the same type.

        *tag* is a string containing the element name.
        *attrib* is a dictionary containing the element attributes.

        Do not call this method, use the SubElement factory function instead.

        )r0)r3r(r1s   r&�makeelementzElement.makeelement�s���~�~�c�6�*�*r%c��|j|j|j�}|j|_|j|_||dd|S�N)r;r(r1�text�tail)r3�elems  r&�__copy__zElement.__copy__�s@��������$�+�+�6���I�I��	��I�I��	���Q���r%c�,�t|j�Sr=)�lenr2r8s r&�__len__zElement.__len__�s���4�>�>�"�"r%c�j�tjdtd��t|j�dk7S)Nz�Testing an element's truth value will always return True in future versions.  Use specific 'len(elem)' or 'elem is not None' test instead.���
stacklevelr)�warnings�warn�DeprecationWarningrCr2r8s r&�__bool__zElement.__bool__�s1���
�
�
K�
�1�		��4�>�>�"�a�'�'r%c� �|j|Sr=�r2�r3�indexs  r&�__getitem__zElement.__getitem__�s���~�~�e�$�$r%c��t|t�r|D]}|j|��n|j|�||j|<yr=)r-�slice�_assert_is_elementr2)r3rPr*�elts    r&�__setitem__zElement.__setitem__�sB���e�U�#����'�'��,��
�#�#�G�,� '����u�r%c��|j|=yr=rNrOs  r&�__delitem__zElement.__delitem__�s���N�N�5�!r%c�\�|j|�|jj|�y)aAdd *subelement* to the end of this element.

        The new element will appear in document order after the last existing
        subelement (or directly after the text, if it's the first subelement),
        but before the end tag for this element.

        N�rTr2�append�r3�
subelements  r&r[zElement.append�s$��	
���
�+������j�)r%c�j�|D].}|j|�|jj|��0y)zkAppend subelements from a sequence.

        *elements* is a sequence with zero or more elements.

        NrZ)r3�elementsr*s   r&�extendzElement.extend�s.�� �G��#�#�G�,��N�N�!�!�'�*� r%c�^�|j|�|jj||�y)z(Insert *subelement* at position *index*.N)rTr2�insert)r3rPr]s   r&rbzElement.insert�s$�����
�+������e�Z�0r%c�f�t|t�s!tdt|�jz��y)Nzexpected an Element, not %s)r-�_Element_Pyr/�typer )r3�es  r&rTzElement._assert_is_element�s.���!�[�)��9�D��G�<L�<L�L�M�M�*r%c�:�|jj|�y)a�Remove matching subelement.

        Unlike the find methods, this method compares elements based on
        identity, NOT ON tag value or contents.  To remove subelements by
        other means, the easiest way is to use a list comprehension to
        select what elements to keep, and then use slice assignment to update
        the parent element.

        ValueError is raised if a matching element could not be found.

        N)r2�remover\s  r&rhzElement.removes��	
�����j�)r%c�0�tj|||�S)aFind first matching element by tag name or path.

        *path* is a string having either an element tag or an XPath,
        *namespaces* is an optional mapping from namespace prefix to full name.

        Return the first matching element, or None if no element was found.

        )r�find�r3�path�
namespacess   r&rjzElement.finds������d�J�7�7r%c�2�tj||||�S)a�Find text for first matching element by tag name or path.

        *path* is a string having either an element tag or an XPath,
        *default* is the value to return if the element was not found,
        *namespaces* is an optional mapping from namespace prefix to full name.

        Return text content of first matching element, or default value if
        none was found.  Note that if an element is found having no text
        content, the empty string is returned.

        )r�findtext�r3rl�defaultrms    r&rozElement.findtexts���#�#�D�$���D�Dr%c�0�tj|||�S)aFind all matching subelements by tag name or path.

        *path* is a string having either an element tag or an XPath,
        *namespaces* is an optional mapping from namespace prefix to full name.

        Returns list containing all matching elements in document order.

        )r�findallrks   r&rszElement.findall)s���"�"�4��z�:�:r%c�0�tj|||�S)a Find all matching subelements by tag name or path.

        *path* is a string having either an element tag or an XPath,
        *namespaces* is an optional mapping from namespace prefix to full name.

        Return an iterable yielding all matching elements in document order.

        )r�iterfindrks   r&ruzElement.iterfind4s���#�#�D�$�
�;�;r%c�b�|jj�g|_dx|_|_y)z�Reset element.

        This function removes all subelements, clears all attributes, and sets
        the text and tail attributes to None.

        N)r1�clearr2r>r?r8s r&rwz
Element.clear?s)��	
��������� $�$��	�D�Ir%c�:�|jj||�S)agGet element attribute.

        Equivalent to attrib.get, but some implementations may handle this a
        bit more efficiently.  *key* is what attribute to look for, and
        *default* is what to return if the attribute was not found.

        Returns a string containing the attribute value, or the default if
        attribute was not found.

        )r1�get)r3�keyrqs   r&ryzElement.getJs���{�{���s�G�,�,r%c�"�||j|<y)z�Set element attribute.

        Equivalent to attrib[key] = value, but some implementations may handle
        this a bit more efficiently.  *key* is what attribute to set, and
        *value* is the attribute value to set it to.

        N)r1)r3rz�values   r&�setzElement.setWs��!����C�r%c�6�|jj�S)z�Get list of attribute names.

        Names are returned in an arbitrary order, just like an ordinary
        Python dict.  Equivalent to attrib.keys()

        )r1�keysr8s r&rzElement.keysas���{�{���!�!r%c�6�|jj�S)z�Get element attributes as a sequence.

        The attributes are returned in arbitrary order.  Equivalent to
        attrib.items().

        Return a list of (name, value) tuples.

        )r1�itemsr8s r&r�z
Element.itemsjs���{�{� � �"�"r%c#�K�|dk(rd}|�|j|k(r|��|jD]}|j|�Ed{����y7��w)aCreate tree iterator.

        The iterator loops over the element and all subelements in document
        order, returning all elements with a matching tag.

        If the tree structure is modified during iteration, new or removed
        elements may or may not be included.  To get a stable set, use the
        list() function on the iterator, and loop over the resulting list.

        *tag* is what tags to look for (default is to return all elements)

        Return an iterator containing all the matching elements.

        �*N)r(r2�iter)r3r(rfs   r&r�zElement.iterusJ�����#�:��C��;�$�(�(�c�/��J����A��v�v�c�{�"�"� �"�s�AA�A
�Ac#��K�|j}t|t�s|�y|j}|r|��|D]-}|j	�Ed{���|j
}|s�*|���/y7��w)z�Create text iterator.

        The iterator loops over the element and all subelements in document
        order, returning all inner text.

        N)r(r-�strr>�itertextr?)r3r(�trfs    r&r�zElement.itertext�s`�����h�h���#�s�#�����I�I����G��A��z�z�|�#�#����A����	�#�s�A
A)�A'�
A)� A)r=�NN)!r r!r"r#r(r1r>r?r5r9r;rArDrLrQrVrXr[r`rbrTrhrjrorsrurwryr}rr�r�r�r$r%r&rr~s����(�C��
�F�1��D���D��$&��P�	+��#�(�%�(�"�	*�+�1�
N�
*�	8�E�	;�	<�	%�-�!�"�	#�#�,r%rc�X�i|�|�}|j||�}|j|�|S)a�Subelement factory which creates an element instance, and appends it
    to an existing parent.

    The element tag, attribute names, and attribute values can be either
    bytes or Unicode strings.

    *parent* is the parent element, *tag* is the subelements name, *attrib* is
    an optional directory containing element attributes, *extra* are
    additional attributes given as keyword arguments.

    )r;r[)�parentr(r1r4r*s     r&rr�s6��!��
 �%�
 �F�� � ��f�-�G�
�M�M�'���Nr%c�2�tt�}||_|S)z�Comment element factory.

    This function creates a special element which the standard serializer
    serializes as an XML comment.

    *text* is a string containing the comment string.

    )rrr>)r>r*s  r&rr�s���g��G��G�L��Nr%c�d�tt�}||_|r|jdz|z|_|S)a*Processing Instruction element factory.

    This function creates a special element which the standard serializer
    serializes as an XML comment.

    *target* is a string containing the processing instruction, *text* is a
    string containing the processing instruction contents, if any.

    � )rrr>)�targetr>r*s   r&rr�s3���+�,�G��G�L���|�|�c�)�D�0����Nr%c�H�eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zy)
ra�Qualified name wrapper.

    This class can be used to wrap a QName attribute value in order to get
    proper namespace handing on output.

    *text_or_uri* is a string containing the QName value either in the form
    {uri}local, or if the tag argument is given, the URI part of a QName.

    *tag* is an optional argument which if given, will make the first
    argument (text_or_uri) be interpreted as a URI, and this argument (tag)
    be interpreted as a local name.

    Nc�&�|rd|�d|��}||_y)N�{�}�r>)r3�text_or_urir(s   r&r5zQName.__init__�s���&1�3�7�K���	r%c��|jSr=r�r8s r&�__str__z
QName.__str__�s���y�y�r%c�P�d|jj�d|j�d�S)N�<r��>)r0r r>r8s r&r9zQName.__repr__�s�� �N�N�3�3�T�Y�Y�?�?r%c�,�t|j�Sr=)�hashr>r8s r&�__hash__zQName.__hash__�s���D�I�I��r%c�r�t|t�r|j|jkS|j|kSr=�r-rr>�r3�others  r&�__le__zQName.__le__��.���e�U�#��9�9��
�
�*�*��y�y�E�!�!r%c�r�t|t�r|j|jkS|j|kSr=r�r�s  r&�__lt__zQName.__lt__��.���e�U�#��9�9�u�z�z�)�)��y�y�5� � r%c�r�t|t�r|j|jk\S|j|k\Sr=r�r�s  r&�__ge__zQName.__ge__�r�r%c�r�t|t�r|j|jkDS|j|kDSr=r�r�s  r&�__gt__zQName.__gt__�r�r%c�r�t|t�r|j|jk(S|j|k(Sr=r�r�s  r&�__eq__zQName.__eq__�r�r%r=)
r r!r"r#r5r�r9r�r�r�r�r�r�r$r%r&rr�s5��� ��@��"�!�"�!�"r%rc�p�eZdZdZdd�Zd�Zd�Zdd�Zdd�Zdd�Z	dd	�Z
dd
�Zdd�Z				ddd
�d�Z
d�Zy)ra%An XML element hierarchy.

    This class also provides support for serialization to and from
    standard XML.

    *element* is an optional root element node,
    *file* is an optional file handle or file name of an XML file whose
    contents will be used to initialize the tree with.

    Nc�:�||_|r|j|�yyr=)�_rootr)r3r*�files   r&r5zElementTree.__init__
s����
���J�J�t��r%c��|jS)z!Return root element of this tree.�r�r8s r&�getrootzElementTree.getroots���z�z�r%c��||_y)z�Replace root element of this tree.

        This will discard the current contents of the tree and replace it
        with the given element.  Use with care!

        Nr�)r3r*s  r&�_setrootzElementTree._setroots����
r%c���d}t|d�st|d�}d}	|�Kt�}t|d�r5|j|�|_|j|r|j�SS|j
d�x}r%|j|�|j
d�x}r�%|j�|_|j|r|j�SS#|r|j�wwxYw)a=Load external XML document into element tree.

        *source* is a file name or file object, *parser* is an optional parser
        instance that defaults to XMLParser.

        ParseError is raised if the parser fails to parse the document.

        Returns the root element of the given source document.

        F�read�rbT�_parse_wholei)r)�openrr�r��closer��feed)r3�source�parser�close_source�datas     r&rzElementTree.parse!s������v�v�&��&�$�'�F��L�	��~�"����6�>�2�
"(�!4�!4�V�!<�D�J��:�:�������!�+�+�e�,�,�$�,����D�!�!�+�+�e�,�,�$�,�����D�J��:�:��������|������s�9C�+7C�# C�C,c�8�|jj|�S)z�Create and return tree iterator for the root element.

        The iterator loops over all elements in this tree, in document order.

        *tag* is a string with the tag name to iterate over
        (default is to return all elements).

        )r�r��r3r(s  r&r�zElementTree.iterCs���z�z���s�#�#r%c��|dddk(r$d|z}tjd|ztd��|jj	||�S)a\Find first matching element by tag name or path.

        Same as getroot().find(path), which is Element.find()

        *path* is a string having either an element tag or an XPath,
        *namespaces* is an optional mapping from namespace prefix to full name.

        Return the first matching element, or None if no element was found.

        Nr�/�.��This search is broken in 1.3 and earlier, and will be fixed in a future version.  If you rely on the current behaviour, change it to %rrFrG)rIrJ�
FutureWarningr�rjrks   r&rjzElementTree.findOsQ�����8�s�?���:�D��M�M�-�/3�4��!�	
��z�z���t�Z�0�0r%c��|dddk(r$d|z}tjd|ztd��|jj	|||�S)aeFind first matching element by tag name or path.

        Same as getroot().findtext(path),  which is Element.findtext()

        *path* is a string having either an element tag or an XPath,
        *namespaces* is an optional mapping from namespace prefix to full name.

        Return the first matching element, or None if no element was found.

        Nrr�r�r�rFrG)rIrJr�r�rorps    r&rozElementTree.findtextesU�����8�s�?���:�D��M�M�-�/3�4��!�	
��z�z�"�"�4��*�=�=r%c��|dddk(r$d|z}tjd|ztd��|jj	||�S)aaFind all matching subelements by tag name or path.

        Same as getroot().findall(path), which is Element.findall().

        *path* is a string having either an element tag or an XPath,
        *namespaces* is an optional mapping from namespace prefix to full name.

        Return list containing all matching elements in document order.

        Nrr�r�r�rFrG)rIrJr�r�rsrks   r&rszElementTree.findall{sS�����8�s�?���:�D��M�M�-�/3�4��!�	
��z�z�!�!�$�
�3�3r%c��|dddk(r$d|z}tjd|ztd��|jj	||�S)agFind all matching subelements by tag name or path.

        Same as getroot().iterfind(path), which is element.iterfind()

        *path* is a string having either an element tag or an XPath,
        *namespaces* is an optional mapping from namespace prefix to full name.

        Return an iterable yielding all matching elements in document order.

        Nrr�r�r�rFrG)rIrJr�r�rurks   r&ruzElementTree.iterfind�sS�����8�s�?���:�D��M�M�-�/3�4��!�	
��z�z�"�"�4��4�4r%T��short_empty_elementsc��|sd}n|tvrtd|z��|s
|dk(rd}nd}t||�5\}}|dk(r5|s'|�1|j�dk7r|j�dvr|d	|�d
��|dk(rt	||j
�n9t
|j
|�\}	}
t|}|||j
|	|
|��ddd�y#1swYyxYw)
a�Write element tree to a file as XML.

        Arguments:
          *file_or_filename* -- file name or a file object opened for writing

          *encoding* -- the output encoding (default: US-ASCII)

          *xml_declaration* -- bool indicating if an XML declaration should be
                               added to the output. If None, an XML declaration
                               is added if encoding IS NOT either of:
                               US-ASCII, UTF-8, or Unicode

          *default_namespace* -- sets the default XML namespace (for "xmlns")

          *method* -- either "xml" (default), "html, "text", or "c14n"

          *short_empty_elements* -- controls the formatting of elements
                                    that contain no content. If True (default)
                                    they are emitted as a single self-closed
                                    tag, otherwise they are emitted as a pair
                                    of start/end tags

        �xmlzunknown method %r�c14n�utf-8�us-asciiN�unicode)r�r�z<?xml version='1.0' encoding='z'?>
r>r�)�
_serialize�
ValueError�_get_writer�lower�_serialize_textr��_namespaces)r3�file_or_filename�encoding�xml_declaration�default_namespace�methodr��write�declared_encoding�qnamesrm�	serializes            r&r�zElementTree.write�s���:��F�
�:�
%��0�6�9�:�:�����"��%��
�)�8�
4�
	E�8R��@Q����O�$�,��^�^�%��2�&�,�,�.�6K�K��%�(�)������t�z�z�2�%0����=N�%O�"��
�&�v�.�	��%����V�Z�/C�E�
	E�
	E�
	E�s�BC�Cc�(�|j|d��S)Nr�)r�)r�)r3r�s  r&�
write_c14nzElementTree.write_c14n�s���z�z�$�v�z�.�.r%r�r=)NNNN)r r!r"r#r5r�r�rr�rjrorsrur�r�r$r%r&rrsZ��	���� �D
$�1�,>�,4�,5�.�"� $��	3E�
$(�3E�j/r%rc#�~K�	|j}|j�dk(r|t|dd�xsdf��ytj�5}t|tj�r|}n�t|tj�r1t
j|�}|j|j�nFt
j�}d�|_||_	|j|_
|j|_t
j ||dd��}|j|j�|j|f��ddd�y#t$rY�XwxYw#1swYyxYw#t$rM|j�dk(rd}t#|d|d�	�5}|j|f��ddd�Yy#1swYYyxYwwxYw�w)
Nr�r�r�c��y�NTr$r$r%r&�<lambda>z_get_writer.<locals>.<lambda>s��Dr%�xmlcharrefreplace�
)r��errors�newline�w)r�r�)r�r��getattr�
contextlib�	ExitStackr-�io�BufferedIOBase�	RawIOBase�BufferedWriter�callback�detach�writable�seekable�tell�AttributeError�
TextIOWrapperr�)r�r�r��stackr�s     r&r�r��s�����-+� �&�&���>�>��y�(���!1�:�t�D�O��O�O��%�%�'�
+�5��.��0A�0A�B�+�D�� 0�"�,�,�?��,�,�-=�>�D��N�N�4�;�;�/��,�,�.�D�$0�D�M�!&�D�J��)9�(A�(A��
�$4�$9�$9��	��'�'��19�/B�04�6�����t�{�{�+��j�j�(�*�*�9
+�
+��&*�����'
+�
+���'��>�>��y�(��H�
�"�C�(�,�.�	'�15��*�*�h�&�&�	'�	'�	'��	'�s��F=�E$�=F=�
BE�"E	�<AE�	F=�		E�E�E�E�E!�F=�$-F:�F,�"F:�*F=�,F6	�1F:�4F=�6F:�:F=c�����ddi�i��rd��<���fd�}|j�D�],}|j}t|t�r!|j�vrM||j�n:t|t
�r
|�vr&||�n|�|tur|turt|�|j�D]_\}}t|t�r|j}|�vr||�t|t�s�?|j�vs�N||j��a|j}t|t�s��|j�vs��||j���/��fS)N�c�J��	|dddk(rm|ddjdd�\}}�j|�}|�/tj|�}|�dt��z}|dk7r|�|<|r|�d|���|<y|�|<y�rt	d��|�|<y#t
$rt
|�YywxYw)Nrr�r�zns%dr��:z<cannot use non-qualified names with default_namespace option)�rsplitry�_namespace_maprCr�r/�_raise_serialization_error)�qname�urir(�prefixr�rmr�s    ���r&�	add_qnamez_namespaces.<locals>.add_qname s����	.��R�a�y�C�� ���9�+�+�C��3���S�#����,���>�+�/�/��4�F��~�!'�#�j�/�!9�����*0�
�3���/5�s�$;�F�5�M�$'�F�5�M�$�$�3���!&��u�
���	.�&�u�-�	.�s�A.B�2B�8B�B"�!B")
r�r(r-rr>r�rr
rr�)	r@r�rr(rzr|r>rmr�s	 `     @@r&r�r�s(����D�\�F��J��(*�
�$�%�.�8�	�	����h�h���c�5�!��x�x�v�%��#�(�(�#�
��S�
!��&� ��#��
�_��G�!3��2�
�&�s�+��*�*�,�J�C���#�u�%��h�h���&� ��#���%��'�E�J�J�f�,D��%�*�*�%�
'��y�y���d�E�"�t�y�y��'>��d�i�i� �'�(�:��r%c	��|j}|j}|tur
|d|z��np|tur
|d|z��n[||}|�,|r|t	|��|D]}t|||d|����n(|d|z�t
|j��}	|	s|r�|rCt|j�d���D]$\}
}|rd|z}|d|�d	t|
��d
���&|	D]^\}}
t|t�r|j}t|
t�r||
j}
nt|
�}
|d||�d	|
�d
���`|s
t|�s|sA|d�|r|t	|��|D]}t|||d|���|d
|zdz�n|d�|jr|t	|j��yy)N�	<!--%s-->�<?%s?>r�r�c��|dS�Nrr$��xs r&r�z _serialize_xml.<locals>.<lambda>h���Q�q�Tr%�rzr�� xmlns�="�"r�r��</z />)r(r>rr�
_escape_cdata�_serialize_xml�listr��sorted�_escape_attribr-rrCr?)r�r@r�rmr��kwargsr(r>rfr��v�ks            r&rrRs���
�(�(�C��9�9�D�
�g�~�
�k�D� �!�	�%�	%�
�h��o���S�k���;���m�D�)�*����u�a���4H�J��
�#��)�������&�E��
�� &�z�'7�'7�'9�+9�!;���1�� #�a��A���*�1�-���	!;�"�D�A�q�!�!�U�+��F�F��!�!�U�+�"�1�6�6�N��*�1�-���&��)�Q�7�8�"��s�4�y�(<��c�
���-��-�.��A�"�5�!�V�T�8L�N���d�S�j�3�&�'��e���y�y�
�m�D�I�I�&�'�r%>�br�hr�col�img�wbr�area�base�link�meta�embed�frame�input�param�trackr��isindex�basefontc	���|j}|j}|tur|dt|�z��n�|tur|dt|�z��nj||}|�*|r|t|��|D]}t|||d���n9|d|z�t
|j��}|s|r�|rCt|j�d���D]$\}	}
|
rd|
z}
|d|
�dt|	��d	���&|D]^\}
}	t|
t�r|
j}
t|	t�r||	j}	nt|	�}	|d
||
�d|	�d	���`|d�|j�}|r$|dk(s|d
k(r	||�n|t|��|D]}t|||d��|tvr|d|zdz�|jr|t|j��yy)Nrr	r�c��|dSrr$rs r&r�z!_serialize_html.<locals>.<lambda>�rr%rr�rrrr�r��script�styler)r(r>rrr�_serialize_htmlrr�rrr-r�_escape_attrib_htmlr��
HTML_EMPTYr?)r�r@r�rmrr(r>rfr�rr�ltags            r&r0r0�s���
�(�(�C��9�9�D�
�g�~�
�k�M�$�/�/�0�	�%�	%�
�h��t�,�,�-��S�k���;���m�D�)�*�����q�&�$�7��
�#��)�������&�E��
�� &�z�'7�'7�'9�+9�!;���1�� #�a��A���*�1�-���	!;�"�D�A�q�!�!�U�+��F�F��!�!�U�+�"�1�6�6�N��/��2���&��)�Q�7�8�"�
�#�J��9�9�;�D���8�#�t�w���$�K��-��-�.�����q�&�$�7���:�%��d�S�j�3�&�'��y�y�
�m�D�I�I�&�'�r%c�|�|j�D]
}||��|jr||j�yyr=)r�r?)r�r@�parts   r&r�r��s1���
�
���
�d�� ��y�y�
�d�i�i��r%)r��htmlr>c���tjd|�rtd��ttj��D]\}}||k(s||k(s�t|=�|t|<y)atRegister a namespace prefix.

    The registry is global, and any existing mapping for either the
    given prefix or the namespace URI will be removed.

    *prefix* is the namespace prefix, *uri* is a namespace uri. Tags and
    attributes in this namespace will be serialized with prefix if possible.

    ValueError is raised if prefix is reserved or is invalid.

    zns\d+$z'Prefix format reserved for internal useN)�re�matchr�rrr�)rrrrs    r&rr�s[��
�x�x�	�6�"��B�C�C��^�)�)�+�,���1���8�q�F�{��q�!�-�!�N�3�r%r�r6�rdf�wsdl�xs�xsi�dc)�$http://www.w3.org/XML/1998/namespacezhttp://www.w3.org/1999/xhtmlz+http://www.w3.org/1999/02/22-rdf-syntax-ns#z http://schemas.xmlsoap.org/wsdl/z http://www.w3.org/2001/XMLSchemaz)http://www.w3.org/2001/XMLSchema-instancez http://purl.org/dc/elements/1.1/c�L�td|�dt|�j�d���)Nzcannot serialize z (type �))r/rer r�s r&rr�s!��
�+/��d��1D�1D�E�
�
r%c���	d|vr|jdd�}d|vr|jdd�}d|vr|jdd�}|S#ttf$rt|�YywxYw)N�&�&amp;r��&lt;r��&gt;��replacer/r�rr�s r&rr�so��)��$�;��<�<��W�-�D��$�;��<�<��V�,�D��$�;��<�<��V�,�D�����~�&�)�"�4�(�)���AA�A#�"A#c�|�	d|vr|jdd�}d|vr|jdd�}d|vr|jdd�}d|vr|jdd�}d	|vr|jd	d
�}d|vr|jdd�}d
|vr|jd
d�}|S#ttf$rt|�YywxYw)NrCrDr�rEr�rFr�&quot;�
z&#13;r�z&#10;�	z&#09;rGr�s r&rrs���)��$�;��<�<��W�-�D��$�;��<�<��V�,�D��$�;��<�<��V�,�D��4�<��<�<��h�/�D��4�<��<�<��g�.�D��4�<��<�<��g�.�D��4�<��<�<��g�.�D�����~�&�)�"�4�(�)�s�BB�B;�:B;c���	d|vr|jdd�}d|vr|jdd�}d|vr|jdd�}|S#ttf$rt|�YywxYw)NrCrDr�rFrrKrGr�s r&r1r1sm��	)��$�;��<�<��W�-�D��$�;��<�<��V�,�D��4�<��<�<��h�/�D�����~�&�)�"�4�(�)�rIT)r�r�r�c��|dk(rtj�ntj�}t|�j	||||||��|j�S)a
Generate string representation of XML element.

    All subelements are included.  If encoding is "unicode", a string
    is returned. Otherwise a bytestring is returned.

    *element* is an Element instance, *encoding* is an optional output
    encoding defaulting to US-ASCII, *method* is an optional output which can
    be one of "xml" (default), "html", "text" or "c14n", *default_namespace*
    sets the default XML namespace (for "xmlns").

    Returns an (optionally) encoded string containing the XML data.

    r��r�r�r�r�)r��StringIO�BytesIOrr��getvalue)r*r�r�r�r�r��streams       r&rr+sV�� '�)�3�R�[�[�]�����F������v�x�/>�1B�&,�4H�	�J�
�?�?��r%c�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)�_ListDataStreamz7An auxiliary stream accumulating into a list reference.c��||_yr=)�lst)r3rXs  r&r5z_ListDataStream.__init__Es	����r%c��yr�r$r8s r&r�z_ListDataStream.writableH���r%c��yr�r$r8s r&r�z_ListDataStream.seekableKrZr%c�:�|jj|�yr=)rXr[)r3�bs  r&r�z_ListDataStream.writeNs��������r%c�,�t|j�Sr=)rCrXr8s r&r�z_ListDataStream.tellQs���4�8�8�}�r%N)	r r!r"r#r5r�r�r�r�r$r%r&rVrVCs��A�����r%rVc�`�g}t|�}t|�j||||||��|S)NrP)rVrr�)r*r�r�r�r�r�rXrTs        r&rrTsC��
�C�
�S�
!�F������v�x�/>�1B�&,�4H�	�J�
�Jr%c��t|t�st|�}|jtjd��|j�j}|r|ddk7r tjjd�yy)a#Write element tree or element structure to sys.stdout.

    This function should be used for debugging only.

    *elem* is either an ElementTree, or a single Element.  The exact output
    format is implementation dependent.  In this version, it's written as an
    ordinary XML file.

    r�)r����r�N)r-rr��sys�stdoutr�r?)r@r?s  r&rrasb���d�K�(��4� ���J�J�s�z�z�I�J�.��<�<�>���D��4��8�t�#��
�
�����$r%c�����t|t�r|j�}|dkrtd|����t	|�syd|�zzg����fd���|d�y)a&Indent an XML document by inserting newlines and indentation space
    after elements.

    *tree* is the ElementTree or Element to modify.  The (root) element
    itself will not be changed, but the tail text of all elements in its
    subtree will be adapted.

    *space* is the whitespace to insert for each indentation level, two
    space characters by default.

    *level* is the initial indentation level. Setting this to a higher
    value than 0 can be used for indenting subtrees that are more deeply
    nested inside of a document.
    rz,Initial indentation level must be >= 0, got Nr�c���|dz}	�|}|jr|jj�s||_|D]D}t	|�r	�||�|j
r|j
j�r�>||_�Fj
j�s�||_yy#t$r�|�z}�j|�Y��wxYwr)�
IndexErrorr[r>�striprCr?)r@�level�child_level�child_indentation�child�_indent_children�indentations�spaces     ���r&rlz indent.<locals>._indent_children�s�����a�i��	3� ,�[� 9��
�y�y��	�	��� 1�)�D�I��E��5�z� ���4��:�:�U�Z�Z�%5�%5�%7�.��
�	��z�z���!�%�e�,�E�J�"���	3� ,�U� 3�e� ;����� 1�2�	3�s�B)�)"C�
C)r-rr�r�rC)�treernrhrlrms ` @@r&rrtsb����$��$��|�|�~���q�y��G��w�O�P�P��t�9���5�5�=�(�)�L�-�,�T�1�r%c�>�t�}|j||�|S)z�Parse XML document into element tree.

    *source* is a filename or file object containing XML data,
    *parser* is an optional parser instance defaulting to XMLParser.

    Return an ElementTree instance.

    )rr)r�r�ros   r&rr�s���=�D��J�J�v�v���Kr%c�������t||���t�d�st�d��d�nd����fd��G���fd�dtjj
�}|�}d	|_tj|��|S)
aJIncrementally parse XML document into ElementTree.

    This class also reports what's going on to the user based on the
    *events* it is initialized with.  The supported events are the strings
    "start", "end", "start-ns" and "end-ns" (the "ns" events are used to get
    detailed namespace information).  If *events* is omitted, only
    "end" events are reported.

    *source* is a filename or file object containing XML data, *events* is
    a list of events to report back, *parser* is an optional parser instance.

    Returns an iterator providing (event, elem) pairs.

    )�events�_parserr�r�TFc3�\�K�		�j�Ed{���|jd�}|sn�j|��>�j�}�j�Ed{�����}|�||_�r|j�yy7�v7�*#�r|j�wwxYw�w)Ni@)�read_eventsr�r��_close_and_return_root�rootr�)r�r�rw�itr��
pullparser�wrs    ���r&�iteratorziterparse.<locals>.iterator�s������	��%�1�1�3�3�3��{�{�9�-��������%�
��4�4�6�D�!�-�-�/�/�/���B��~����������4��
0��
������s?�B,�B�B�A
B�'B�(B�<B,�B�B�B)�)B,c�B��eZdZW�W��jZ��fd�Zy)�$iterparse.<locals>.IterParseIteratorc�,���r�j�yyr=)r�)r3r�r�s ��r&�__del__z,iterparse.<locals>.IterParseIterator.__del__�s��������r%N)r r!r"�__next__r)r�r{r�s���r&�IterParseIteratorr}�s����F�#�,�,��	r%r�N)	rr)r��collections�abc�Iteratorrw�weakref�ref)	r�rrr�r�rxr�r{ryrzs	`    @@@@r&r
r
�st���"�f�f�=�J��6�6�"��f�d�#�������$��K�O�O�4�4��
�	�B��B�G�	���R��B�
�Ir%c�8�eZdZd	dd�d�Zd�Zd�Zd�Zd�Zd�Zy)
rN)rsc���tj�|_|xstt	���|_|�d}|j
j
|j|�y)N�r�)�end)r��deque�
_events_queuerrrs�
_setevents)r3rrrss   r&r5zXMLPullParser.__init__�sL��
)�.�.�0����A�)�;�=�"A����>��F������� 2� 2�F�;r%c���|j�td��|r	|jj|�yy#t$r%}|jj|�Yd}~yd}~wwxYw)�Feed encoded data to parser.Nz!feed() called after end of stream)rsr�r��SyntaxErrorr�r[)r3r��excs   r&r�zXMLPullParser.feed�s`���<�<���@�A�A��
/����!�!�$�'����
/��"�"�)�)�#�.�.��
/�s�8�	A&�A!�!A&c�H�|jj�}d|_|Sr=)rsr�)r3rws  r&rvz$XMLPullParser._close_and_return_roots ���|�|�!�!�#������r%c�$�|j�y)z�Finish feeding data to parser.

        Unlike XMLParser, does not return the root element. Use
        read_events() to consume elements from XMLPullParser.
        N)rvr8s r&r�zXMLPullParser.closes��	
�#�#�%r%c#�|K�|j}|r*|j�}t|t�r|�|��|r�)yy�w)z�Return an iterator over currently available (event, elem) pairs.

        Events are consumed from the internal event queue as they are
        retrieved from the iterator.
        N)r��popleftr-�	Exception)r3rr�events   r&ruzXMLPullParser.read_eventss;�����#�#����N�N�$�E��%��+������s�7<�<c�f�|j�td��|jj�y)Nz"flush() called after end of stream)rsr��flushr8s r&r�zXMLPullParser.flush$s(���<�<���A�B�B������r%r=)	r r!r"r5r�rvr�rur�r$r%r&rr�s'��
<�t�
<�/��&��r%rc�p�|stt���}|j|�|j�S)aParse XML document from string constant.

    This function can be used to embed "XML Literals" in Python code.

    *text* is a string containing XML data, *parser* is an
    optional parser instance, defaulting to the standard XMLParser.

    Returns an Element instance.

    r��rrr�r�)r>r�s  r&rr*s+����+�-�0��
�K�K����<�<�>�r%c���|stt���}|j|�|j�}i}|j	�D]}|jd�}|s�|||<�||fS)aParse XML document from string constant for its IDs.

    *text* is a string containing XML data, *parser* is an
    optional parser instance, defaulting to the standard XMLParser.

    Returns an (Element, dict) tuple, in which the
    dict maps element id:s to elements.

    r�r7)rrr�r�r�ry)r>r�ro�idsr@r7s      r&rr;sd����+�-�0��
�K�K����<�<�>�D�
�C��	�	���
�X�X�d�^��
��C��G����9�r%c�~�|stt���}|D]}|j|��|j�S)z�Parse XML document from sequence of string fragments.

    *sequence* is a list of other sequence, *parser* is an optional parser
    instance, defaulting to the standard XMLParser.

    Returns an Element instance.

    r�r�)�sequencer�r>s   r&rrSs5����+�-�0�������D����<�<�>�r%c�V�eZdZdZdddddd�d�Zd�Zd�Zd�Zd	�Zd
�Z	d�Z
dd�Zd
�Zy)ra8Generic element structure builder.

    This builder converts a sequence of start, data, and end method
    calls to a well-formed element structure.

    You can use this class to build an element structure using a custom XML
    parser, or a parser for some other XML-like format.

    *element_factory* is an optional element factory which is called
    to create new Element instances, as necessary.

    *comment_factory* is a factory to create comments to be used instead of
    the standard factory.  If *insert_comments* is false (the default),
    comments will not be inserted into the tree.

    *pi_factory* is a factory to create processing instructions to be used
    instead of the standard factory.  If *insert_pis* is false (the default),
    processing instructions will not be inserted into the tree.
    NF)�comment_factory�
pi_factory�insert_comments�
insert_pisc��g|_g|_d|_d|_d|_|�t
}||_||_|�t}||_	||_
|�t}||_yr=)
�_data�_elem�_lastr��_tailr�_comment_factoryr�r�_pi_factoryr�r�_factory)r3�element_factoryr�r�r�r�s      r&r5zTreeBuilder.__init__ysn����
���
���
���
���
��"�%�O� /���.�����.�J�%���$����"�%�O�'��
r%c�~�t|j�dk(sJd��|j�Jd��|jS)z;Flush builder buffers and return toplevel document Element.rzmissing end tagszmissing toplevel element)rCr�r�r8s r&r�zTreeBuilder.close�s>���4�:�:��!�#�7�%7�7�#��z�z�%�A�'A�A�%��z�z�r%c�L�|jr�|j��dj|j�}|jr/|jj�Jd��||j_n.|jj
�Jd��||j_g|_yy)Nr�zinternal error (tail)zinternal error (text))r�r��joinr�r?r>�r3r>s  r&�_flushzTreeBuilder._flush�s����:�:��z�z�%��w�w�t�z�z�*���:�:��:�:�?�?�2�K�4K�K�2�&*�D�J�J�O��:�:�?�?�2�K�4K�K�2�&*�D�J�J�O��D�J�r%c�:�|jj|�y)zAdd text to current element.N)r�r[�r3r�s  r&r�zTreeBuilder.data�s���
�
���$�r%c��|j�|j||�x|_}|jr|jdj	|�n|j
�||_|jj	|�d|_|S)z�Open new element and return it.

        *tag* is the element name, *attrs* is a dict containing element
        attributes.

        rar)r�r�r�r�r[r�r�)r3r(�attrsr@s    r&�startzTreeBuilder.start�sp��	
���
� �M�M�#�u�5�5��
�T��:�:��J�J�r�N�!�!�$�'�
�Z�Z�
��D�J��
�
���$����
��r%c��|j�|jj�|_|jj|k(s"Jd|jj�d|�d���d|_|jS)zOClose and return current Element.

        *tag* is the element name.

        zend tag mismatch (expected z, got rAr)r�r��popr�r(r�r�s  r&r�zTreeBuilder.end�sa��	
���
��Z�Z�^�^�%��
��z�z�~�~��$�	(��:�:�>�>�3�(�	(�$���
��z�z�r%c�P�|j|j|j|�S)z`Create a comment using the comment_factory.

        *text* is the text of the comment.
        )�_handle_singler�r�r�s  r&�commentzTreeBuilder.comment�s*��
�"�"��!�!�4�#7�#7��?�	?r%c�R�|j|j|j||�S)z�Create a processing instruction using the pi_factory.

        *target* is the target name of the processing instruction.
        *text* is the data of the processing instruction, or ''.
        )r�r�r�)r3r�r>s   r&�pizTreeBuilder.pi�s*���"�"����d�o�o�v�t�=�	=r%c��||�}|rH|j�||_|jr|jdj|�d|_|S)Nrar)r�r�r�r[r�)r3�factoryrb�argsr@s     r&r�zTreeBuilder._handle_single�sG����~����K�K�M��D�J��z�z��
�
�2��%�%�d�+��D�J��r%r=)
r r!r"r#r5r�r�r�r�r�r�r�r�r$r%r&rresC���&(�!%�$�!&�5�(�(�
� ��"�?�=�r%rc�`�eZdZdZddd�d�Zd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�Zd�Zy)raaElement structure builder for XML source data based on the expat parser.

    *target* is an optional target object which defaults to an instance of the
    standard TreeBuilder class, *encoding* is an optional encoding string
    which if given, overrides the encoding specified in the XML file:
    http://www.iana.org/assignments/character-sets

    N)r�r�c�J�	ddlm}|j	|d�}|�
t�}|x|_|_|x|_|_	|j|_i|_|j|_t|d�r|j |_t|d�r|j$|_t|d�r|j(|_t|d�r|j,|_t|d	�r|j0|_t|d
�r|j4|_t|d�r|j8|_d|_d|_d|_ i|_!	d
|jDz|_#y#t$r"	ddl}n#t$rtd��wxYwY���wxYw#tH$rYywxYw)Nr��expatz7No module named expat; use SimpleXMLTreeBuilder insteadr�r�r��start_ns�end_nsr�r�r�rzExpat %d.%d.%d)%�xml.parsersr��ImportError�pyexpat�ParserCreaterr�rsr��_target�error�_error�_names�_default�DefaultHandlerExpandr)�_start�StartElementHandler�_end�EndElementHandler�	_start_ns�StartNamespaceDeclHandler�_end_ns�EndNamespaceDeclHandlerr��CharacterDataHandlerr��CommentHandlerr��ProcessingInstructionHandler�buffer_text�ordered_attributes�_doctype�entity�version_info�versionr�)r3r�r�r�r�s     r&r5zXMLParser.__init__�s���	�)��#�#�H�c�2���>� �]�F�%+�+���d�l�%+�+���d�l��k�k������&*�m�m��#��6�7�#�)-���F�&��6�5�!�'+�y�y�F�$��6�:�&�/3�~�~�F�,��6�8�$�-1�\�\�F�*��6�6�"�*0�+�+�F�'��6�9�%�$*�N�N�F�!��6�4� �28�)�)�F�/����$%��!���
����	�+�e�.@�.@�@�D�L��M�	�
�'���
�!�M���
��(�	��N�	��	�s;�E(�F�(	F�2E7�6F�7F�F�F�	F"�!F"c��|j}|j}|D]�}|dk(r d|_|||jfd�}||_�(|dk(r|||j
fd�}||_�F|dk(r6t|jd�r|||jfd�}n||fd	�}||_
��|d
k(r6t|jd�r|||jfd�}n||fd
�}||_��|dk(r|||fd�}||_
��|dk(r|||fd�}||_��td|z��y)Nr�rc�&�|||||�f�yr=r$)r(�	attrib_inr�r[r�s     r&�handlerz%XMLParser._setevents.<locals>.handler"s���E�5��i�#8�9�:r%r�c�$�||||�f�yr=r$)r(r�r[r�s    r&r�z%XMLParser._setevents.<locals>.handler's���E�3�s�8�,�-r%zstart-nsr�c�&�|||||�f�yr=r$)rrr�r[r�s     r&r�z%XMLParser._setevents.<locals>.handler.s����x���'<�=�>r%c�,�|||xsd|xsdff�y�Nr�r$)rrr�r[s    r&r�z%XMLParser._setevents.<locals>.handler2s������"�c�i�R�'@�A�Br%zend-nsr�c�$�||||�f�yr=r$)rr�r[r�s    r&r�z%XMLParser._setevents.<locals>.handler8s����v�f�~�6�7r%c��||df�yr=r$)rr�r[s   r&r�z%XMLParser._setevents.<locals>.handler<s����t�}�-r%r�c�J�|||jj|�f�yr=)r�r�)r>r�r[r3s    r&r�z%XMLParser._setevents.<locals>.handler@s���E�4�;�;�#6�#6�t�#<�=�>r%r�c�L�|||jj||�f�yr=)r�r�)�	pi_targetr�r�r[r3s     r&r�z%XMLParser._setevents.<locals>.handlerDs���E�4�;�;�>�>�)�T�#B�C�Dr%zunknown event %r)rsr[r�r�r�r�r�r)r�r�r�r�r�r�r�r�)r3�events_queue�events_to_reportr�r[�
event_namer�s       r&r�zXMLParser._seteventss5�������$�$��*�J��W�$�,-��)�2<�V�"&�+�+�;�.5��*��u�$�'1�&� $�	�	�.�,3��(��z�)��4�;�;�
�3�3=�f�)-���?�4>�f�C�3:��0��x�'��4�;�;��1�.8��'+�|�|�8�/9��.�18��.��y�(�(2�6��?�(/��%��t�#�3=�f�!%�E�7>��3� �!3�j�!@�A�A�U+r%c�x�t|�}|j|_|j|jf|_|�r=)r�code�lineno�offset�position)r3r|�errs   r&�_raiseerrorzXMLParser._raiseerrorKs0�������:�:����|�|�U�\�\�1����	r%c�z�	|j|}|S#t$r|}d|vrd|z}||j|<Y|SwxYw)Nr�r�)r��KeyError)r3rz�names   r&�_fixnamezXMLParser._fixnameQsU��	$��;�;�s�#�D�����	$��D��d�{��T�z��#�D�K�K�����	$�s��#:�:c�J�|jj|xsd|xsd�Sr�)r�r��r3rrs   r&r�zXMLParser._start_ns\s!���{�{�#�#�F�L�b�#�)��<�<r%c�@�|jj|xsd�Sr�)r�r�)r3rs  r&r�zXMLParser._end_ns_s���{�{�!�!�&�,�B�/�/r%c���|j}||�}i}|r/tdt|�d�D]}||dz||||�<�|jj	||�S)NrrFr)r��rangerCr�r�)r3r(�	attr_list�fixnamer1�is      r&r�zXMLParser._startbsg���-�-���c�l������1�c�)�n�a�0��09�!�A�#���w�y��|�,�-�1��{�{� � ��f�-�-r%c�V�|jj|j|��Sr=)r�r�r�r�s  r&r�zXMLParser._endns���{�{���t�}�}�S�1�2�2r%c��|dd}|dk(r1	|jj}	||j|dd�y|dk(r|dd	d
k(rg|_y|j��|dk(rd|_y|j�}|sy|jj!|�t#|j�}|dkDr�|jd}|d
k(r|dk(r|j\}}}	}
|	r$|	dd}	n|dk(r|dk(r|j\}}}
d}	nyt%|jd�r!|jj'||	|
dd�n&t%|d�rt)j*dt,�d|_yyy#t$rYywxYw#t$r�ddlm}|jd||jj|jjfz�}d|_|jj|_|jj|_
|�wxYw)NrrCrarr�z'undefined entity %s: line %d, column %d�r��	z	<!DOCTYPEr�rF�PUBLIC��SYSTEM��doctypezaThe doctype() method of XMLParser is ignored.  Define doctype() method on the TreeBuilder target.)r�r�r�r�r�r�r�r�r��ErrorLineNumber�ErrorColumnNumberr�r�r�r�rgr[rCr)rrIrJ�RuntimeWarning)r3r>r�data_handlerr�r��nrer��pubid�systems           r&r�zXMLParser._defaultqs���b�q����S�=�
�#�{�{�/�/��
��T�[�[��a���4�5��s�]�t�B�Q�x�;�6��D�M�
�]�]�
&���}� $��
���:�:�<�D����M�M� � ��&��D�M�M�"�A��1�u��}�}�Q�'���8�#��Q��04�
�
�-�D�$��v�� %�a�����X�%�!�q�&�)-���&�D�$�� �E���4�;�;�	�2��K�K�'�'��e�V�A�b�\�B��T�9�-��M�M�M�&�(�
!%��
�'�'��#"�
��
���

�-��k�k�=��4�;�;�6�6��K�K�1�1�3�3���
���!�[�[�8�8��
�!�[�[�:�:��
��	�

�s�E*�E9�*	E6�5E6�9BHc��	|jj|d�y#|j$r}|j|�Yd}~yd}~wwxYw)r�FN)r��Parser�r�)r3r�rs   r&r�zXMLParser.feed�s@��	 ��K�K���d�E�*���{�{�	 ����Q����	 �s��A	�A�A	c�.�	|jjdd�	|jj
}|�|`|`|`|`S#|j$r}|j|�Yd}~�Kd}~wwxYw#t$rYnwxYw	|`|`|`|`y#|`|`|`|`wxYw)z;Finish feeding data to parser and return element structure.r%TN)	r�rr�r�r�r�rsr�r�)r3r�
close_handlers   r&r�zXMLParser.close�s���	 ��K�K���c�4�(�		*� �K�K�-�-�M�!�?���T�\���T�\���{�{�	 ����Q����	 ���	��	���
��T�\���T�\����T�\���T�\�s?�A�A1�B
�A.�A)�)A.�1	A=�:B
�<A=�=B
�

Bc�x�|jj�}	|jjd�|jjdd�|jj|�y#|j$r}|j|�Yd}~�Ad}~wwxYw#|jj|�wxYw)NFr%)r��GetReparseDeferralEnabled�SetReparseDeferralEnabledrr�r�)r3�was_enabledrs   r&r�zXMLParser.flush�s����k�k�;�;�=��	?��K�K�1�1�%�8��K�K���c�5�)�
�K�K�1�1�+�>���{�{�	 ����Q����	 ��
�K�K�1�1�+�>�s)�7A/�/B�>B�B�B�B�B9)r r!r"r#r5r�r�r�r�r�r�r�r�r�r�r�r$r%r&rr�sN���"&��+�Z3B�j�	�=�0�
.�3�4%�l �*�"?r%r)�out�	from_filec�"�|�
|�td��d}|�tj�x}}tt	|j
fi|����}|�"|j
|�|j�n|�
t||��|�|j�SdS)a3Convert XML to its C14N 2.0 serialised form.

    If *out* is provided, it must be a file or file-like object that receives
    the serialised canonical XML output (text, not bytes) through its ``.write()``
    method.  To write to a file, open it in text mode with encoding "utf-8".
    If *out* is not provided, this function returns the output as text string.

    Either *xml_data* (an XML string) or *from_file* (a file path or
    file-like object) must be provided as input.

    The configuration options are the same as for the ``C14NWriterTarget``.
    Nz:Either 'xml_data' or 'from_file' must be provided as inputr�)r�)
r�r�rQrrr�r�r�rrS)�xml_datarr�options�sior�s      r&rr�s�����I�-��U�V�V�
�C�
�{��K�K�M�!��c�
�.�s�y�y�D�G�D�
E�F������H������	�	�
�i��'� �_�3�<�<�>�6�$�6r%z	^\w+:\w+$c��eZdZdZdddddddd�d�Zefd�Zd�Zdd�Zd	�Z	d
jfd�Zd�Zd
�Z
dd�Zd�Zd�Zd�Zy)ra�
    Canonicalization writer target for the XMLParser.

    Serialises parse events to XML C14N 2.0.

    The *write* function is used for writing out the resulting data stream
    as text (not bytes).  To write to a file, open it in text mode with encoding
    "utf-8" and pass its ``.write`` method.

    Configuration options:

    - *with_comments*: set to true to include comments
    - *strip_text*: set to true to strip whitespace before and after text content
    - *rewrite_prefixes*: set to true to replace namespace prefixes by "n{number}"
    - *qname_aware_tags*: a set of qname aware tag names in which prefixes
                          should be replaced in text content
    - *qname_aware_attrs*: a set of qname aware attribute names in which prefixes
                           should be replaced in text content
    - *exclude_attrs*: a set of attribute names that should not be serialised
    - *exclude_tags*: a set of tag names that should not be serialised
    FN)�
with_comments�
strip_text�rewrite_prefixes�qname_aware_tags�qname_aware_attrs�
exclude_attrs�exclude_tagsc�2�||_g|_||_||_|rt	|�nd|_|rt	|�nd|_||_|rt	|�|_nd|_|rt	|�j|_
nd|_
dgg|_g|_|s6|jjttj!���|jjg�i|_dg|_d|_d|_d|_d|_y)N)r?r�Fr)�_writer��_with_comments�_strip_textr}�_exclude_attrs�
_exclude_tags�_rewrite_prefixes�_qname_aware_tags�intersection�_find_qname_aware_attrs�_declared_ns_stack�	_ns_stackr[rrr��_prefix_map�_preserve_space�_pending_start�
_root_seen�
_root_done�_ignored_depth)	r3r�r%r&r'r(r)r*r+s	         r&r5zC14NWriterTarget.__init__s�������
�+���%���4A�c�-�0�t���2>�S��.�D���!1����%(�)9�%:�D�"�%)�D�"��+.�/@�+A�+N�+N�D�(�+/�D�(�
<�$
�#��������N�N�!�!�$�~�';�';�'=�">�?������b�!���� %�w���"�����������r%c#�DK�||�D]}|s�|Ed{����y7��wr=r$)r3�ns_stack�	_reversedrms    r&�_iter_namespacesz!C14NWriterTarget._iter_namespaces(s$����#�H�-�J��%�%�%�.�%�s� � �� c��|jdd�\}}|j|j�D]\}}||k(s�d|�d|��cStd|�d|�d���)Nr�rr�r�zPrefix z of QName "�" is not declared in scope)�splitrAr7r�)r3�
prefixed_namerr�r�ps      r&�_resolve_prefix_namez%C14NWriterTarget._resolve_prefix_name-sl��$�*�*�3��2�����+�+�D�N�N�;�F�C���F�{��C�5��4�&�)�)�<��7�6�(�+�m�_�D^�_�`�`r%c���|�%|dddk(r|ddjdd�nd|f\}}n|}t�}|j|j�D]/\}}||k(r||vr|r|�d|��n|||fcS|j	|��1|j
ro||jvr|j|}n'dt|j���x}|j|<|jdj||f�|�d|��||fS|s	d|vr|||fS|j|j�D]:\}}||k(s�|jdj||f�|r|�d|��n|||fcS|s|||fStd|�d	���)
Nrr�r�r�r�rrazNamespace "rC)rr}rAr6�addr2r8rCr[r7r�)r3rrr(�
prefixes_seen�urs       r&�_qnamezC14NWriterTarget._qname4s����;�38��!�9��3C�u�Q�R�y�'�'��Q�/�"�e��H�C���C���
��.�.�t�/F�/F�G�I�A�v��C�x�F�-�7�,2�&���3�%�(��S�#�E�E����f�%�H��!�!��d�&�&�&��)�)�#�.��34�S��9I�9I�5J�4K�1L�L���)�)�#�.��#�#�B�'�.�.��V�}�=��X�Q�s�e�$�c�3�.�.��r��.���S�=� ��.�.�t�~�~�>�I�A�v��C�x��'�'��+�2�2�C��=�A�,2�&���3�%�(��S�#�E�E�?�
���S�=� ��;�s�e�+E�F�G�Gr%c�T�|js|jj|�yyr=)r=r�r[r�s  r&r�zC14NWriterTarget.dataYs"���"�"��J�J���d�#�#r%r�c��||j�}|jdd�=|jr|jds|j�}|j�<|jdc}|_|r
t|�r|nd}|jg|�|���|�y|r(|jr|jt|��yyy�Nra)
r�r/r9rgr:�_looks_like_prefix_namer�r;r-�_escape_cdata_c14n)r3�
_join_textr�r��
qname_texts     r&r�zC14NWriterTarget._flush]s����$�*�*�%���J�J�q�M����D�$8�$8��$<��:�:�<�D����*�(,�(;�(;�T�%�D�$�%�!%�*A�$�*G��T�J��D�K�K�*��*�z�*��%���D�O�O��K�K�*�4�0�1�$�4r%c��|jry|jr|j�|jdj	||f�yrO)r=r�r�r7r[r�s   r&r�zC14NWriterTarget.start_nsks9�������:�:��K�K�M����r��!�!�3��-�0r%c�^�|j�0|js||jvr|xjdz
c_y|jr|j�g}|jj|�|j�||jvr|||f|_y|j|||�yr)	r1r=r�r�r6r[r3r:r�)r3r(r��new_namespacess    r&r�zC14NWriterTarget.startss������)��#�#�s�d�.@�.@�'@����1�$����:�:��K�K�M������&�&�~�6��!�!�-�#��9O�9O�2O�#&��~�">�D������C���/r%c��|j�4|r2|j�D��cic]\}}||jvs�||��}}}|h|�}i}|�'|j|�x}	||<|j|	�|j�X|rV|j	|�}
|
r@|
D]:}||}t|�s�|j|�x}	||<|j|	��<nd}
nd}
|j}
t|d���D�cic]}||
|���
}}|r.|D��cgc]\}}|rd|znd|f��}}}|j�ng}|rVt|j��D]:\}}|
�||
vr||vr|||d}||\}}}|j|r|n||f��<|jd�}|jj|r|dk(n|jd�|j}|d	||dz�|r:|d
j|D��cgc]\}}d|�dt|��d
���c}}��|d�|�|t|||d��d|_|j"jg�ycc}}wcc}wcc}}wcc}}w)Nc�&�|jdd�S)Nr�r)rD)rs r&r�z)C14NWriterTarget._start.<locals>.<lambda>�s��!�'�'�#�q�/r%rzxmlns:�xmlnsrz+{http://www.w3.org/XML/1998/namespace}space�preserverar�r�r�rrr�T)r0r�rGrIr5rPrLr�sortr[ryr9r-r��_escape_attrib_c14nrQr;r7)r3r(r�rVrSrrr��resolved_namesr�qattrs�	attr_namer|�parse_qnamer�
parsed_qnamesrrr�
attr_qname�space_behaviourr�s                      r&r�zC14NWriterTarget._start�s������*�u�&+�k�k�m�T�d�a��q��@S�@S�7S�Q��T�T�E�T���������!�15�1J�1J�:�1V�V�E�N�:�.��J�J�u���'�'�3���1�1�%�8�F��!'�I�!�)�,�E�.�u�5�8<�8Q�8Q�RW�8X�X���u� 5��
�
�5�)�	"(����F��k�k��4:��1�53�4�q��K��N�*�4�
�4��$2���C��'-��F�"�'�3�?��I��
�N�N���I���u�{�{�}�-���1��%�!�v�+�!�~�:M�%�n�Q�&7�8��;�A�-:�1�-=�*�
�I�s�� � ��*��A�!F�G�.� �)�)�$Q�R�����#�#�-<�O�z�)��%�%�b�)�	+�
����
�c�M�#�&�q�)�)�*���"�'�'�)�T�$�!�Q�Q�q�c��$7��$:�#;�1�=�T�U�V�
�c�
��!��$�]�>�*�3M�%N�q�%Q�R�S���������b�!��CU��04��
��8Us�I/�I/�3I5�I:�Jc��|jr|xjdzc_y|jr|j�|jd|j	|�d�d��|j
j
�t|j
�dk(|_|jj
�|jj
�y)Nrrrr�)r=r�r�r-rLr9r�rCr<r6r7r�s  r&r�zC14NWriterTarget.end�s���������1�$����:�:��K�K�M����b����S�)�!�,�-�Q�/�0���� � �"��d�2�2�3�q�8������#�#�%������r%c�<�|jsy|jry|jr|jd�n(|jr|j
r|j
�|jdt|��d��|js|jd�yy)Nr�z<!--z-->)r.r=r<r-r;r�r�rQr�s  r&r�zC14NWriterTarget.comment�sw���"�"�������?�?��K�K���
�_�_�����K�K�M����d�-�d�3�4�C�8�9�����K�K���r%c�8�|jry|jr|jd�n(|jr|jr|j�|j|rd|�dt
|��d�nd|�d��|js|jd�yy)Nr�z<?r�z?>)r=r<r-r;r�r�rQ)r3r�r�s   r&r�zC14NWriterTarget.pi�s��������?�?��K�K���
�_�_�����K�K�M����:>�b����,�T�2�3�2�6�b���PR�O�	U�����K�K���r%r=)r r!r"r#r5�reversedrArGrLr�r�r�r�r�r�r�r�r�r$r%r&rr�sj���, %���"&�$�#�$�# �J4<�&�
a�#H�J$�!#���2�1�0�"C"�J
��
r%rc��	d|vr|jdd�}d|vr|jdd�}d|vr|jdd�}d|vr|jdd�}|S#ttf$rt|�YywxYw)	NrCrDr�rEr�rFrL�&#xD;rGr�s r&rQrQ�s���)��$�;��<�<��W�-�D��$�;��<�<��V�,�D��$�;��<�<��V�,�D��4�<��<�<��g�.�D�����~�&�)�"�4�(�)�s�AA�A9�8A9c�P�	d|vr|jdd�}d|vr|jdd�}d|vr|jdd�}d|vr|jdd�}d	|vr|jd	d
�}d|vr|jdd�}|S#ttf$rt|�YywxYw)
NrCrDr�rErrKrMz&#x9;r�z&#xA;rLrirGr�s r&r\r\s���)��$�;��<�<��W�-�D��$�;��<�<��V�,�D��$�;��<�<��X�.�D��4�<��<�<��g�.�D��4�<��<�<��g�.�D��4�<��<�<��g�.�D�����~�&�)�"�4�(�)�s�BB�B%�$B%)r�)�_set_factoriesr=r�)z  r)@r#�__all__rrbr8rIr�r��collections.abcr�r�r�rr�rr	rrrrr
rr�contextmanagerr�r�rr2r0r�r�rrrrrr1rr�rVrrrrr
rrrrrrrr�compile�UNICODEr9rPrrQr\rd�_elementtreerkr�r$r%r&�<module>rrs��!�P��(��
�	��	������		��		�#�
^�^�B	$&��$�� ��+"�+"�`\/�\/�B���/+��/+�b;�z0(�d�
�0(�d�����
�!�*-2�$*�38�(.�(,�16�(,���%3��!�
�
)� )�8)��!�T�"&��0�b�'�'��"
�!%��&*�
��&/�l�5�p7�7�t�"�,�
�
�$v�v�th?�h?�Z7�t�t�7�<%�"�*�*�\�2�:�:�>�D�D����D)�&)�.3��K��+��7�1�2���	��	�s�
E,�,E4�3E4

Hacked By AnonymousFox1.0, Coded By AnonymousFox