Hacked By AnonymousFox

Current Path : /proc/thread-self/root/proc/self/root/opt/alt/python311/lib64/python3.11/xml/etree/__pycache__/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/opt/alt/python311/lib64/python3.11/xml/etree/__pycache__/ElementTree.cpython-311.pyc

�

c��f�"���dZgd�ZdZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZGd�de
��Zd	�ZGd
�d��Zifd�ZdDd
�ZdDd�ZeZGd�d��ZGd�d��Ze	jd���ZdDd�Zd�Zhd�Zd�Zd�Zeeed�Zd�Zdddddd d!d"�Z e e_ d#�Z!d$�Z"d%�Z#d&�Z$dEddd'd(�d)�Z%Gd*�d+ej&��Z'dEddd'd(�d,�Z(d-�Z)dFd/�Z*dDd0�Z+dEd1�Z,Gd2�d3��Z-dDd4�Z.dDd5�Z/e.Z0dDd6�Z1Gd7�d8��Z2Gd9�d:��Z3dDddd;�d<�Z4ej5d=ej6��j7Z8Gd>�d?��Z9d@�Z:dA�Z;	eZ<ddBl=TddCl=m>Z>e>ee��dS#e?$rYdSwxYw)GaLightweight 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��eZdZdZdS)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/python311/lib64/python3.11/xml/etree/ElementTree.pyrrks��������	�Dr%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�Zd�Zdd�Zdd�Zdd�Zdd�Zd�Zdd�Zd�Zd�Zd�Zdd�Z d�Z!dS)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��std|jj�����||_i|�|�|_g|_dS)Nzattrib must be dict, not )�
isinstance�dict�	TypeError�	__class__r r(�attrib�	_children)�selfr(r1�extras    r&�__init__zElement.__init__�s\���&�$�'�'�	-��)�� �)�)�,�-�-�
-����)��)�5�)�������r%c�J�d|jj|jt|��fzS)Nz<%s %r at %#x>)r0r r(�id�r3s r&�__repr__zElement.__repr__�s!���4�>�#:�D�H�b��h�h�"O�O�Or%c�.�|�||��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�^�tjdt��|���S)z�Return copy of current element.

        This creates a shallow copy. Subelements will be shared with the
        original tree.

        z7elem.copy() is deprecated. Use copy.copy(elem) instead.)�warnings�warn�DeprecationWarning�__copy__r8s r&�copyzElement.copy�s.��	�
�E��	�	�	��}�}���r%c��|�|j|j��}|j|_|j|_||dd�<|S�N)r;r(r1�text�tail)r3�elems  r&r@zElement.__copy__�s?�������$�+�6�6���I��	��I��	���Q�Q�Q���r%c�*�t|j��SrC)�lenr2r8s r&�__len__zElement.__len__�s���4�>�"�"�"r%c�j�tjdtd���t|j��dkS)NzyThe behavior of this method will change in future versions.  Use specific 'len(elem)' or 'elem is not None' test instead.���
stacklevelr)r=r>�
FutureWarningrHr2r8s r&�__bool__zElement.__bool__�s=���
�
K��a�	�	�	�	�
�4�>�"�"�a�'�'r%c��|j|SrC�r2�r3�indexs  r&�__getitem__zElement.__getitem__�s���~�e�$�$r%c��t|t��r|D]}|�|���n|�|��||j|<dSrC)r-�slice�_assert_is_elementr2)r3rSr*�elts    r&�__setitem__zElement.__setitem__�sg���e�U�#�#�	-��
-�
-���'�'��,�,�,�,�
-�
�#�#�G�,�,�,� '���u���r%c��|j|=dSrCrQrRs  r&�__delitem__zElement.__delitem__�s���N�5�!�!�!r%c�d�|�|��|j�|��dS)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�rWr2�append�r3�
subelements  r&r^zElement.append�s4��	
���
�+�+�+�����j�)�)�)�)�)r%c�n�|D]1}|�|��|j�|���2dS)zkAppend subelements from a sequence.

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

        Nr])r3�elementsr*s   r&�extendzElement.extend�sJ�� �	+�	+�G��#�#�G�,�,�,��N�!�!�'�*�*�*�*�	+�	+r%c�f�|�|��|j�||��dS)z(Insert *subelement* at position *index*.N)rWr2�insert)r3rSr`s   r&rezElement.inserts4�����
�+�+�+�����e�Z�0�0�0�0�0r%c�x�t|t��s$tdt|��jz���dS)Nzexpected an Element, not %s)r-�_Element_Pyr/�typer )r3�es  r&rWzElement._assert_is_elements@���!�[�)�)�	N��9�D��G�G�<L�L�M�M�M�	N�	Nr%c�:�|j�|��dS)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&rkzElement.remove
s ��	
����j�)�)�)�)�)r%c�.�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&rmzElement.finds�����d�J�7�7�7r%c�0�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�r3ro�defaultrps    r&rrzElement.findtext's���#�D�$���D�D�Dr%c�.�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�findallrns   r&rvzElement.findall5s���"�4��z�:�:�:r%c�.�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�iterfindrns   r&rxzElement.iterfind@s���#�D�$�
�;�;�;r%c�b�|j���g|_dx|_|_dS)z�Reset element.

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

        N)r1�clearr2rDrEr8s r&rzz
Element.clearKs1��	
���������� $�$��	�D�I�I�Ir%c�8�|j�||��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�keyrts   r&r|zElement.getVs���{���s�G�,�,�,r%c��||j|<dS)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)r3r}�values   r&�setzElement.setcs��!���C���r%c�4�|j���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&r�zElement.keysms���{���!�!�!r%c�4�|j���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.itemsvs���{� � �"�"�"r%c#�K�|dkrd}|�|j|kr|V�|jD]}|�|��Ed{V���dS)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(ris   r&r�zElement.iter�sn�����#�:�:��C��;�$�(�c�/�/��J�J�J���	#�	#�A��v�v�c�{�{�"�"�"�"�"�"�"�"�	#�	#r%c#�K�|j}t|t��s|�dS|j}|r|V�|D])}|���Ed{V��|j}|r|V��*dS)z�Create text iterator.

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

        N)r(r-�strrD�itertextrE)r3r(�tris    r&r�zElement.itertext�s������h���#�s�#�#�	����F��I���	��G�G�G��	�	�A��z�z�|�|�#�#�#�#�#�#�#���A��
������		�	r%rC�NN)"r r!r"r#r(r1rDrEr5r9r;rAr@rIrOrTrYr[r^rcrerWrkrmrrrvrxrzr|r�r�r�r�r�r$r%r&rr~s���������(�C��
�F�1��D���D��$&�����P�P�P�	+�	+�	+�������#�#�#�(�(�(�%�%�%�(�(�(�"�"�"�	*�	*�	*�+�+�+�1�1�1�
N�N�N�
*�
*�
*�	8�	8�	8�	8�E�E�E�E�	;�	;�	;�	;�	<�	<�	<�	<�	%�	%�	%�-�-�-�-�!�!�!�"�"�"�	#�	#�	#�#�#�#�#�,����r%rc�h�i|�|�}|�||��}|�|��|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�s?��!��
 �%�
 �F�� � ��f�-�-�G�
�M�M�'�����Nr%c�<�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.

    )rrrD)rDr*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.

    � )rrrD)�targetrDr*s   r&rr�s9���+�,�,�G��G�L��1��|�c�)�D�0����Nr%c�J�eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�ZdS)
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|��}||_dS)N�{�}�rD)r3�text_or_urir(s   r&r5zQName.__init__�s*���	8�	8�&1�k�k�3�3�7�K���	�	�	r%c��|jSrCr�r8s r&�__str__z
QName.__str__�s
���y�r%c�2�d|jj�d|j�d�S)N�<r��>)r0r rDr8s r&r9zQName.__repr__�s ��� �N�3�3�3�T�Y�Y�Y�?�?r%c�*�t|j��SrC)�hashrDr8s r&�__hash__zQName.__hash__�s���D�I���r%c�b�t|t��r|j|jkS|j|kSrC�r-rrD�r3�others  r&�__le__zQName.__le__��0���e�U�#�#�	+��9��
�*�*��y�E�!�!r%c�b�t|t��r|j|jkS|j|kSrCr�r�s  r&�__lt__zQName.__lt__��0���e�U�#�#�	*��9�u�z�)�)��y�5� � r%c�b�t|t��r|j|jkS|j|kSrCr�r�s  r&�__ge__zQName.__ge__�r�r%c�b�t|t��r|j|jkS|j|kSrCr�r�s  r&�__gt__zQName.__gt__r�r%c�b�t|t��r|j|jkS|j|kSrCr�r�s  r&�__eq__zQName.__eq__r�r%rC)
r r!r"r#r5r�r9r�r�r�r�r�r�r$r%r&rr�s��������� � � � ����@�@�@����"�"�"�!�!�!�"�"�"�!�!�!�"�"�"�"�"r%rc�r�eZdZdZdd�Zd�Zd�Zdd�Zdd�Zdd�Z	dd	�Z
dd
�Zdd�Z				ddd
�d�Z
d�ZdS)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�F�||_|r|�|��dSdSrC)�_rootr)r3r*�files   r&r5zElementTree.__init__s3����
��	��J�J�t������	�	r%c��|jS)z!Return root element of this tree.�r�r8s r&�getrootzElementTree.getroots
���z�r%c��||_dS)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._setroot#s����
�
�
r%c��d}t|d��st|d��}d}	|�Vt��}t|d��r8|�|��|_|j|r|���SS	|�d��}|sn|�|���.|���|_|j|r|���SS#|r|���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�rbTN�_parse_wholei)r)�openrr�r��closer��feed)r3�source�parser�close_source�datas     r&rzElementTree.parse-s�����v�v�&�&�	 ��&�$�'�'�F��L�	��~�"�����6�>�2�2�&�
"(�!4�!4�V�!<�!<�D�J��:��
��������
�
"��{�{�5�)�)��������D�!�!�!�	
"�
 �����D�J��:��
��������
��|�
��������
���s�AC$�>AC$�$C=c�6�|j�|��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.iterRs���z���s�#�#�#r%c��|dd�dkr$d|z}tjd|ztd���|j�||��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 %rrKrL)r=r>rNr�rmrns   r&rmzElementTree.find^sc������8�s�?�?���:�D��M�-�/3�4��!�	
�
�
�
��z���t�Z�0�0�0r%c��|dd�dkr$d|z}tjd|ztd���|j�|||��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�rKrL)r=r>rNr�rrrss    r&rrzElementTree.findtexttsg������8�s�?�?���:�D��M�-�/3�4��!�	
�
�
�
��z�"�"�4��*�=�=�=r%c��|dd�dkr$d|z}tjd|ztd���|j�||��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�rKrL)r=r>rNr�rvrns   r&rvzElementTree.findall�se������8�s�?�?���:�D��M�-�/3�4��!�	
�
�
�
��z�!�!�$�
�3�3�3r%c��|dd�dkr$d|z}tjd|ztd���|j�||��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�rKrL)r=r>rNr�rxrns   r&rxzElementTree.iterfind�se������8�s�?�?���:�D��M�-�/3�4��!�	
�
�
�
��z�"�"�4��4�4�4r%T��short_empty_elementsc���|sd}n|tvrtd|z���|s|dkrd}nd}t||��5\}}|dkrA|s0|�=|���dkr%|���dvr|d	|�d
���|dkrt	||j��n:t
|j|��\}	}
t|}|||j|	|
|���ddd��dS#1swxYwYdS)
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'?>
rDr�)�
_serialize�
ValueError�_get_writer�lower�_serialize_textr��_namespaces)r3�file_or_filename�encoding�xml_declaration�default_namespace�methodr��write�declared_encoding�qnamesrp�	serializes            r&r�zElementTree.write�s���:�	;��F�F�
�:�
%�
%��0�6�9�:�:�:��	&�����"���%��
�)�8�
4�
4�
	E�8R��@Q�����O��$�,��^�^�%�%��2�2�&�,�,�.�.�6K�K�K����%�%�%�(�)�)�)�������t�z�2�2�2�2�%0���=N�%O�%O�"��
�&�v�.�	��	�%���V�Z�/C�E�E�E�E�
	E�
	E�
	E�
	E�
	E�
	E�
	E�
	E�
	E�
	E�
	E�
	E����
	E�
	E�
	E�
	E�
	E�
	Es�B!C,�,C0�3C0c�0�|�|d���S)Nr�)r�)r�)r3r�s  r&�
write_c14nzElementTree.write_c14n�s���z�z�$�v�z�.�.�.r%r�rC)NNNN)r r!r"r#r5r�r�rr�rmrrrvrxr�r�r$r%r&rrs������	�	�����������#�#�#�#�J
$�
$�
$�
$�1�1�1�1�,>�>�>�>�,4�4�4�4�,5�5�5�5�.�"� $��	3E�
$(�3E�3E�3E�3E�3E�j/�/�/�/�/r%rc#�xK�	|j}|���dkr|t|dd��pdfV�dStj��5}t|tj��r|}n�t|tj��r/t
j	|��}|�
|j��nLt
j��}d�|_||_	|j
|_
|j|_n#t$rYnwxYwt
j||dd���}|�
|j��|j|fV�ddd��dS#1swxYwYdS#t$rV|���dkrd}t#|d|d�	��5}|j|fV�ddd��YdS#1swxYwYYdSwxYw)
Nr�r�r�c��dS�NTr$r$r%r&�<lambda>z_get_writer.<locals>.<lambda>s��D�r%�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�D�O��O�O�O�O�O�O��%�'�'�
+�5��.��0A�B�B��+�D�D�� 0�"�,�?�?���,�-=�>�>�D��N�N�4�;�/�/�/�/��,�.�.�D�$0�L�D�M�!&�D�J��)9�(A��
�$4�$9��	�	��)�����������'��19�/B�04�6�6�6�����t�{�+�+�+��j�(�*�*�*�*�9
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+����
+�
+�
+�
+�
+�
+���'�'�'��>�>���y�(�(��H�
�"�C�(�,�.�.�.�	'�15��*�h�&�&�&�&�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'����	'�	'�	'�	'�	'�	'�	'�	'���sm�E�B	E�C2�1E�2
C?�<E�>C?�?AE�E�E�7F9�F*�F9�*F.	�.F9�1F.	�2F9�8F9c�����ddi�i��rd��<���fd�}|���D�])}|j}t|t��r|j�vr||j��nHt|t
��r|�vr||��n#|�!|tur|turt|��|�	��D]^\}}t|t��r|j}|�vr||��t|t��r|j�vr||j���_|j}t|t��r|j�vr||j����+��fS)N�c���	|dd�dkr�|dd��dd��\}}��|��}|�9t�|��}|�dt���z}|dkr|�|<|r|�d|���|<dS|�|<dS�rt	d���|�|<dS#t
$rt
|��YdSwxYw)Nrr�r�zns%dr��:z<cannot use non-qualified names with default_namespace option)�rsplitr|�_namespace_maprHr�r/�_raise_serialization_error)�qname�urir(�prefixr�rpr�s    ���r&�	add_qnamez_namespaces.<locals>.add_qname/s���	.��R�a�R�y�C��� ����9�+�+�C��3�3���S�#����,�,���>�+�/�/��4�4�F��~�!'�#�j�/�/�!9������*0�
�3���(�/5�v�v�s�s�$;�F�5�M�M�M�$'�F�5�M�M�M�$��$�3����!&��u�
�
�
���	.�	.�	.�&�u�-�-�-�-�-�-�	.���s�BB/�B/�B/�/C�C)
r�r(r-rrDr�rr
rr�)	rFr�rr(r}rrDrpr�s	 `     @@r&r�r�$s�������D�\�F��J��+�(*�
�$�%�.�.�.�.�.�.�.�8�	�	���!�!���h���c�5�!�!�	,��x�v�%�%��	�#�(�#�#�#��
��S�
!�
!�	,��&� � ��	�#�����
�_��G�!3�!3��2�
�
�&�s�+�+�+��*�*�,�,�	&�	&�J�C���#�u�%�%�
��h���&� � ��	�#�����%��'�'�
&�E�J�f�,D�,D��	�%�*�%�%�%���y���d�E�"�"�	!�t�y��'>�'>��I�d�i� � � ���:��r%c	��|j}|j}|tur|d|z���n�|tur|d|z���n�||}|�5|r|t	|����|D]}t|||d|�����na|d|z��t
|�����}	|	s|r�|rPt|���d����D]+\}
}|rd|z}|d|�d	t|
���d
����,|	D]k\}}
t|t��r|j}t|
t��r||
j}
nt|
��}
|d||�d	|
�d
����l|st|��s|sP|d��|r|t	|����|D]}t|||d|����|d
|zdz��n|d��|j
r|t	|j
����dSdS)N�	<!--%s-->�<?%s?>r�r�c��|dS�Nrr$��xs r&r�z _serialize_xml.<locals>.<lambda>w�
��Q�q�T�r%�r}r� xmlns�="�"r�r��</z />)r(rDrr�
_escape_cdata�_serialize_xml�listr��sorted�_escape_attribr-rrHrE)r�rFr�rpr��kwargsr(rDrir��v�ks            r&rras���
�(�C��9�D�
�g�~�~�
��k�D� �!�!�!�!�	�%�	%�	%�
��h��o������S�k���;��
+���m�D�)�)�*�*�*��
J�
J���u�a���4H�J�J�J�J�J�
J�
�E�#��)����������&�&�E��
9�
�
9��� &�z�'7�'7�'9�'9�+9�>�!;�!;�!;�����1��(� #�a��A�����A�A�*�1�-�-�-�-������"�9�9�D�A�q�!�!�U�+�+�#��F��!�!�U�+�+�.�"�1�6�N���*�1�-�-���E�E�&��)�)�)�Q�Q�Q�7�8�8�8�8��	
�s�4�y�y�	
�(<�	
���c�
�
�
��/��E�-��-�-�.�.�.��N�N�A�"�5�!�V�T�8L�N�N�N�N�N���d�S�j�3�&�'�'�'�'���e�����y�(�
��m�D�I�&�&�'�'�'�'�'�(�(r%>�br�hr�col�img�wbr�area�base�link�meta�embed�frame�input�param�trackr��isindex�basefontc	�j�|j}|j}|tur|dt|��z���n�|tur|dt|��z���n�||}|�3|r|t|����|D]}t|||d����nu|d|z��t
|�����}|s|r�|rPt|���d����D]+\}	}
|
rd|
z}
|d|
�dt|	���d	����,|D]k\}
}	t|
t��r|
j}
t|	t��r||	j}	nt|	��}	|d
||
�d|	�d	����l|d��|�
��}|r0|dks|d
kr||��n|t|����|D]}t|||d���|tvr|d|zdz��|jr|t|j����dSdS)Nr
rr�c��|dSr
r$rs r&r�z!_serialize_html.<locals>.<lambda>�rr%rrrrrr�r��script�styler)r(rDrrr�_serialize_htmlrr�rrr-r�_escape_attrib_htmlr��
HTML_EMPTYrE)r�rFr�rprr(rDrir�rr�ltags            r&r2r2�s���
�(�C��9�D�
�g�~�~�
��k�M�$�/�/�/�0�0�0�0�	�%�	%�	%�
��h��t�,�,�,�-�-�-�-��S�k���;��
+���m�D�)�)�*�*�*��
8�
8����q�&�$�7�7�7�7�
8�
�E�#��)����������&�&�E��
9�
�
9��� &�z�'7�'7�'9�'9�+9�>�!;�!;�!;�����1��(� #�a��A�����A�A�*�1�-�-�-�-������"�9�9�D�A�q�!�!�U�+�+�#��F��!�!�U�+�+�3�"�1�6�N���/��2�2���E�E�&��)�)�)�Q�Q�Q�7�8�8�8�8��E�#�J�J�J��9�9�;�;�D��
/��8�#�#�t�w����E�$�K�K�K�K��E�-��-�-�.�.�.��
8�
8����q�&�$�7�7�7�7��:�%�%���d�S�j�3�&�'�'�'��y�(�
��m�D�I�&�&�'�'�'�'�'�(�(r%c�|�|���D]
}||���|jr||j��dSdSrC)r�rE)r�rF�parts   r&r�r��sT���
�
������
��d������y��
��d�i�������r%)r��htmlrDc���tjd|��rtd���tt�����D]\}}||ks||krt|=�|t|<dS)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�sy��
�x�	�6�"�"�D��B�C�C�C��^�)�)�+�+�,�,�"�"���1���8�8�q�F�{�{��q�!�� �N�3���r%r�r8�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�R�td|�dt|��j�d����)Nzcannot serialize z (type �))r/rhr r�s r&rr�s1��
�)�+/�4�4��d���1D�1D�1D�E�
�
�
r%c���	d|vr|�dd��}d|vr|�dd��}d|vr|�dd��}|S#ttf$rt|��YdSwxYw)N�&�&amp;r��&lt;r��&gt;��replacer/r�rr�s r&rr�s���)��$�;�;��<�<��W�-�-�D��$�;�;��<�<��V�,�,�D��$�;�;��<�<��V�,�,�D�����~�&�)�)�)�"�4�(�(�(�(�(�(�)�����AA� A6�5A6c���	d|vr|�dd��}d|vr|�dd��}d|vr|�dd��}d|vr|�dd��}d	|vr|�d	d
��}d|vr|�dd��}d
|vr|�d
d��}|S#ttf$rt|��YdSwxYw)NrErFr�rGr�rHr�&quot;�
z&#13;r�z&#10;�	z&#09;rIr�s r&rrs	��)��$�;�;��<�<��W�-�-�D��$�;�;��<�<��V�,�,�D��$�;�;��<�<��V�,�,�D��4�<�<��<�<��h�/�/�D��4�<�<��<�<��g�.�.�D��4�<�<��<�<��g�.�.�D��4�<�<��<�<��g�.�.�D�����~�&�)�)�)�"�4�(�(�(�(�(�(�)���s�B7B:�: C�Cc���	d|vr|�dd��}d|vr|�dd��}d|vr|�dd��}|S#ttf$rt|��YdSwxYw)NrErFr�rHrrMrIr�s r&r3r3+s���	)��$�;�;��<�<��W�-�-�D��$�;�;��<�<��V�,�,�D��4�<�<��<�<��h�/�/�D�����~�&�)�)�)�"�4�(�(�(�(�(�(�)���rKT)r�r�r�c���|dkrtj��ntj��}t|���||||||���|���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:sm�� '�)�3�3�R�[�]�]�]�����F�������v�x�/>�1B�&,�4H�	�J�J�J�
�?�?���r%c�0�eZdZdZd�Zd�Zd�Zd�Zd�ZdS)�_ListDataStreamz7An auxiliary stream accumulating into a list reference.c��||_dSrC)�lst)r3rZs  r&r5z_ListDataStream.__init__Ts
������r%c��dSr�r$r8s r&r�z_ListDataStream.writableW����tr%c��dSr�r$r8s r&r�z_ListDataStream.seekableZr\r%c�:�|j�|��dSrC)rZr^)r3�bs  r&r�z_ListDataStream.write]s�����������r%c�*�t|j��SrC)rHrZr8s r&r�z_ListDataStream.tell`s���4�8�}�}�r%N)	r r!r"r#r5r�r�r�r�r$r%r&rXrXRse������A�A�����������������r%rXc�x�g}t|��}t|���||||||���|S)NrR)rXrr�)r*r�r�r�r�r�rZrVs        r&rrcsU��
�C�
�S�
!�
!�F�������v�x�/>�1B�&,�4H�	�J�J�J�
�Jr%c� �t|t��st|��}|�tjd���|���j}|r|ddkr!tj�d��dSdS)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�rE)rFrEs  r&rrps����d�K�(�(�!��4� � ���J�J�s�z�I�J�.�.�.��<�<�>�>��D���4��8�t�#�#��
���������$�#r%�  c������t|t��r|���}|dkrtd|�����t	|��sdSd|�zzg����fd���|d��dS)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}	�|}n0#t$r#�|�z}��|��YnwxYw|jr|j���s||_|D]D}t	|��r�||��|jr|j���s||_�E|j���s�||_dSdSr
)�
IndexErrorr^rD�striprHrE)rF�level�child_level�child_indentation�child�_indent_children�indentations�spaces     ���r&roz indent.<locals>._indent_children�s����a�i��	3� ,�[� 9�����	3�	3�	3� ,�U� 3�e� ;����� 1�2�2�2�2�2�	3�����y�	*��	��� 1� 1�	*�)�D�I��	/�	/�E��5�z�z�
5� � ���4�4�4��:�
/�U�Z�%5�%5�%7�%7�
/�.��
���z���!�!�	-�%�e�,�E�J�J�J�	-�	-s��*>�>)r-rr�r�rH)�treerqrkrorps ` @@r&rr�s�������$��$�$���|�|�~�~���q�y�y��O��O�O�P�P�P��t�9�9�����5�5�=�(�)�L�-�-�-�-�-�-�-�,��T�1�����r%c�N�t��}|�||��|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�rrs   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�		����Ed{V��|�d��}|sn��|���H����}����Ed{V�����}|�||_�r|���dSdS#�r|���wwxYw)NTi@)�read_eventsr�r��_close_and_return_root�rootr�)r�r�rz�itr��
pullparser�wrs    ���r&�iteratorziterparse.<locals>.iterator�s������	�
&�%�1�1�3�3�3�3�3�3�3�3�3��{�{�9�-�-���������%�%�%�

&��4�4�6�6�D�!�-�-�/�/�/�/�/�/�/�/�/�����B��~�����
���������
�
��|�
��������
���s�B
B)�)Cc�<��eZdZ����jZ��fd�ZdS)�$iterparse.<locals>.IterParseIteratorc�8���r����dSdSrC)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��sE��������8�F�#�#�,��	�	�	�	�	�	�	�	r%r�N)	rr)r��collections�abc�Iteratorrz�weakref�ref)	r�rur�r�r{r�r~r|r}s	`    @@@@r&r
r
�s��������"�f�f�=�=�=�J��6�6�"�"���f�d�#�#��������������$���������K�O�4����
�	�	�	�B��B�G�	��R���B�
�Ir%c�:�eZdZd	dd�d�Zd�Zd�Zd�Zd�Zd�ZdS)
rN)rvc���tj��|_|ptt	�����|_|�d}|j�|j|��dS)N�r�)�end)r��deque�
_events_queuerrrv�
_setevents)r3rurvs   r&r5zXMLPullParser.__init__s[��
)�.�0�0����A�)�;�=�=�"A�"A�"A����>��F������ 2�F�;�;�;�;�;r%c���|j�td���|rO	|j�|��dS#t$r%}|j�|��Yd}~dSd}~wwxYwdS)�Feed encoded data to parser.Nz!feed() called after end of stream)rvr�r��SyntaxErrorr�r^)r3r��excs   r&r�zXMLPullParser.feed
s����<���@�A�A�A��	/�
/���!�!�$�'�'�'�'�'���
/�
/�
/��"�)�)�#�.�.�.�.�.�.�.�.�.�����
/����	/�	/s�6�
A%�A � A%c�F�|j���}d|_|SrC)rvr�)r3rzs  r&ryz$XMLPullParser._close_and_return_roots!���|�!�!�#�#������r%c�.�|���dS)z�Finish feeding data to parser.

        Unlike XMLParser, does not return the root element. Use
        read_events() to consume elements from XMLPullParser.
        N)ryr8s r&r�zXMLPullParser.closes��	
�#�#�%�%�%�%�%r%c#�K�|j}|r3|���}t|t��r|�|V�|�1dSdS)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)r3ru�events   r&rxzXMLPullParser.read_events%se�����#���	��N�N�$�$�E��%��+�+�
��������	�	�	�	�	r%c�d�|j�td���|j���dS)Nz"flush() called after end of stream)rvr��flushr8s r&r�zXMLPullParser.flush3s3���<���A�B�B�B���������r%rC)	r r!r"r5r�ryr�rxr�r$r%r&rr�s������
<�t�
<�
<�
<�
<�
<�/�/�/����&�&�&��������r%rc��|stt�����}|�|��|���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�)rDr�s  r&rr9s@���1��+�-�-�0�0�0��
�K�K������<�<�>�>�r%c��|stt�����}|�|��|���}i}|���D]}|�d��}|r|||<�||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�r|)rDr�rr�idsrFr7s      r&rrJs����1��+�-�-�0�0�0��
�K�K������<�<�>�>�D�
�C��	�	������
�X�X�d�^�^��
�	��C��G����9�r%c��|stt�����}|D]}|�|���|���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�rDs   r&rrbsR���1��+�-�-�0�0�0���������D������<�<�>�>�r%c�X�eZdZdZdddddd�d�Zd�Zd�Zd�Zd	�Zd
�Z	d�Z
dd�Zd
�ZdS)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}||_dSrC)
�_data�_elem�_lastr��_tailr�_comment_factoryr�r�_pi_factoryr�r�_factory)r3�element_factoryr�r�r�r�s      r&r5zTreeBuilder.__init__�sr����
���
���
���
���
��"�%�O� /���.�����.�J�%���$����"�%�O�'��
�
�
r%c�v�t|j��dks
Jd���|j�
Jd���|jS)z;Flush builder buffers and return toplevel document Element.rzmissing end tagsNzmissing toplevel element)rHr�r�r8s r&r�zTreeBuilder.close�sC���4�:���!�#�#�#�%7�#�#�#��z�%�%�'A�%�%�%��z�r%c��|jrv|j�fd�|j��}|jr#|jj�
Jd���||j_n"|jj�
Jd���||j_g|_dSdS)Nr�zinternal error (tail)zinternal error (text))r�r��joinr�rErD�r3rDs  r&�_flushzTreeBuilder._flush�s����:�		��z�%��w�w�t�z�*�*���:�+��:�?�2�2�4K�2�2�2�&*�D�J�O�O��:�?�2�2�4K�2�2�2�&*�D�J�O��D�J�J�J�		�		r%c�:�|j�|��dS)zAdd text to current element.N)r�r^�r3r�s  r&r�zTreeBuilder.data�s���
���$�����r%c��|���|�||��x|_}|jr!|jd�|��n|j�||_|j�|��d|_|S)z�Open new element and return it.

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

        rcNr)r�r�r�r�r^r�r�)r3r(�attrsrFs    r&�startzTreeBuilder.start�s���	
���
�
�
� �M�M�#�u�5�5�5��
�T��:�	��J�r�N�!�!�$�'�'�'�'�
�Z�
��D�J��
���$������
��r%c���|���|j���|_|jj|ksJd|jj�d|�d����d|_|jS)zOClose and return current Element.

        *tag* is the element name.

        zend tag mismatch (expected z, got rCr)r�r��popr�r(r�r�s  r&r�zTreeBuilder.end�sk��	
���
�
�
��Z�^�^�%�%��
��z�~��$�$�$�$��:�>�>�>�3�3�3�(�%�$�$���
��z�r%c�D�|�|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��?�?�	?r%c�F�|�|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�rDs   r&�pizTreeBuilder.pi�s*���"�"���d�o�v�t�=�=�	=r%c��||�}|rI|���||_|jr |jd�|��d|_|S)Nrcr)r�r�r�r^r�)r3�factoryre�argsrFs     r&r�zTreeBuilder._handle_single�sY���w��~���	��K�K�M�M�M��D�J��z�
,��
�2��%�%�d�+�+�+��D�J��r%rC)
r r!r"r#r5r�r�r�r�r�r�r�r�r$r%r&rrts���������&(�!%�$�!&�5�(�(�(�(�(�(���
�
�
� � � ����"���?�?�?�=�=�=�=�����r%rc�b�eZdZdZddd�d�Zd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�Zd�ZdS)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�@�	ddlm}n3#t$r&	ddl}n#t$rtd���wxYwYnwxYw|�|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|j|_t|d
��r|j|_t|d��r|j|_d|_d|_d|_ i|_!	d
|j"z|_#dS#tH$rYdSwxYw)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�rvr��_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���	�)�)�)�)�)�)�)���	�	�	�
�'�'�'�'�'���
�
�
�!�M����
����(�'�	�����#�#�H�c�2�2���>� �]�]�F�%+�+���d�l�%+�+���d�l��k������&*�m��#��6�7�#�#�	5�)-��F�&��6�5�!�!�	1�'+�y�F�$��6�:�&�&�	>�/3�~�F�,��6�8�$�$�	:�-1�\�F�*��6�6�"�"�	6�*0�+�F�'��6�9�%�%�	3�$*�N�F�!��6�4� � �	<�28�)�F�/����$%��!���
����	�+�e�.@�@�D�L�L�L���	�	�	��D�D�	���s.�	�
9��9�3�9�9�>F�
F�Fc���|j}|j}|D]�}|dkrd|_|||jfd�}||_�#|dkr|||jfd�}||_�=|dkr0t|jd��r
|||j	fd�}n||fd	�}||_
�s|d
kr0t|jd��r
|||jfd�}n||fd
�}||_��|dkr|||fd�}||_
��|dkr|||fd�}||_��td|z���dS)Nr�rc�4�|||||��f��dSrCr$)r(�	attrib_inr�r^r�s     r&�handlerz%XMLParser._setevents.<locals>.handler1s)���F�E�5�5��i�#8�#8�9�:�:�:�:�:r%r�c�2�||||��f��dSrCr$)r(r�r^r�s    r&r�z%XMLParser._setevents.<locals>.handler6s%���F�E�3�3�s�8�8�,�-�-�-�-�-r%zstart-nsr�c�4�|||||��f��dSrCr$)rrr�r^r�s     r&r�z%XMLParser._setevents.<locals>.handler=s)�����x�x���'<�'<�=�>�>�>�>�>r%c�,�|||pd|pdff��dS�Nr�r$)rrr�r^s    r&r�z%XMLParser._setevents.<locals>.handlerAs*�������"�c�i�R�'@�A�B�B�B�B�Br%zend-nsr�c�2�||||��f��dSrCr$)rr�r^r�s    r&r�z%XMLParser._setevents.<locals>.handlerGs%�����v�v�f�~�~�6�7�7�7�7�7r%c� �||df��dSrCr$)rr�r^s   r&r�z%XMLParser._setevents.<locals>.handlerKs�����t�}�-�-�-�-�-r%r�c�P�|||j�|��f��dSrC)r�r�)rDr�r^r3s    r&r�z%XMLParser._setevents.<locals>.handlerOs-���F�E�4�;�#6�#6�t�#<�#<�=�>�>�>�>�>r%r�c�R�|||j�||��f��dSrC)r�r�)�	pi_targetr�r�r^r3s     r&r�z%XMLParser._setevents.<locals>.handlerSs-���F�E�4�;�>�>�)�T�#B�#B�C�D�D�D�D�Dr%zunknown event %r)rvr^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._setevents%s�������$��*�*	B�*	B�J��W�$�$�,-��)�2<�V�"&�+�;�;�;�;�.5��*�*��u�$�$�'1�&� $�	�.�.�.�.�,3��(�(��z�)�)��4�;�
�3�3�C�3=�f�)-��?�?�?�?�?�4>�f�C�C�C�C�3:��0�0��x�'�'��4�;��1�1�.�.8��'+�|�8�8�8�8�8�/9��.�.�.�.�18��.�.��y�(�(�(2�6��?�?�?�?�(/��%�%��t�#�#�3=�f�!%�E�E�E�E�7>��3�3� �!3�j�!@�A�A�A�U*	B�*	Br%c�b�t|��}|j|_|j|jf|_|�rC)r�code�lineno�offset�position)r3r�errs   r&�_raiseerrorzXMLParser._raiseerrorZs-��������:����|�U�\�1����	r%c�n�	|j|}n%#t$r|}d|vrd|z}||j|<YnwxYw|S)Nr�r�)r��KeyError)r3r}�names   r&�_fixnamezXMLParser._fixname`s`��	$��;�s�#�D�D���	$�	$�	$��D��d�{�{��T�z��#�D�K�����		$����
�s�
�2�2c�@�|j�|pd|pd��Sr�)r�r��r3rrs   r&r�zXMLParser._start_nsks"���{�#�#�F�L�b�#�)��<�<�<r%c�:�|j�|pd��Sr�)r�r�)r3rs  r&r�zXMLParser._end_nsns���{�!�!�&�,�B�/�/�/r%c���|j}||��}i}|r>tdt|��d��D]}||dz||||��<� |j�||��S)NrrKr)r�rangerHr�r�)r3r(�	attr_list�fixnamer1�is      r&r�zXMLParser._startqs����-���g�c�l�l�����	?��1�c�)�n�n�a�0�0�
?�
?��09�!�A�#���w�w�y��|�,�,�-�-��{� � ��f�-�-�-r%c�\�|j�|�|����SrC)r�r�rr�s  r&r�zXMLParser._end}s"���{���t�}�}�S�1�1�2�2�2r%c��|dd�}|dkr�	|jj}n#t$rYdSwxYw	||j|dd���dS#t$raddlm}|�d||jj	|jj
fz��}d|_|jj	|_|jj
|_
|�wxYw|dkr|dd	�d
kr	g|_dS|j��|dkr	d|_dS|���}|sdS|j�|��t#|j��}|dkr�|jd}|d
kr|dkr|j\}}}	}
|	r
|	dd�}	n|dkr|dkr|j\}}}
d}	ndSt%|jd��r%|j�||	|
dd���n*t%|d��rt)jdt,��d|_dSdSdS)NrrErcrr�z'undefined entity %s: line %d, column %d�r��	z	<!DOCTYPEr�rK�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�rjr^rHr)rr=r>�RuntimeWarning)r3rDr�data_handlerr�r��nrhr��pubid�systems           r&r�zXMLParser._default�s}���b�q�b����S�=�=�
�#�{�/����!�
�
�
����
����
���T�[��a��d��4�5�5�5�5�5���

�

�

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

�����s�]�]�t�B�Q�B�x�;�6�6��D�M�M�M�
�]�
&���}�}� $��
����:�:�<�<�D��
����M� � ��&�&�&��D�M�"�"�A��1�u�u��}�Q�'���8�#�#��Q���04�
�-�D�$��v��,� %�a��d�����X�%�%�!�q�&�&�)-��&�D�$�� �E�E��F��4�;�	�2�2�(��K�'�'��e�V�A�b�D�\�B�B�B�B��T�9�-�-�(��M�M�&�(�(�(�
!%��
�
�
�;'�
&��us��
-�-�A�A+B<c��	|j�|d��dS#|j$r }|�|��Yd}~dSd}~wwxYw)r�FN)r��Parser�r�)r3r�rs   r&r�zXMLParser.feed�sl��	 ��K���d�E�*�*�*�*�*���{�	 �	 �	 ����Q��������������	 ���s��
A	�A�A	c�"�	|j�dd��n,#|j$r}|�|��Yd}~nd}~wwxYw	|jj}|��|`|`|`|`S#t$rYnwxYw	|`|`|`|`dS#|`|`|`|`wxYw)z;Finish feeding data to parser and return element structure.r%TN)	r�rr�r�r�r�rvr�r�)r3r�
close_handlers   r&r�zXMLParser.close�s���	 ��K���c�4�(�(�(�(���{�	 �	 �	 ����Q�������������	 ����		*� �K�-�M�!�=�?�?���T�\���T�\�\���	�	�	��D�	�����
��T�\���T�\�\�\����T�\���T�\�)�)�)�)s>��
A�A�A�A)�	B�)
A6�3B�5A6�6B�
Bc�p�|j���}	|j�d��|j�dd��n,#|j$r}|�|��Yd}~nd}~wwxYw|j�|��dS#|j�|��wxYw)NFr%)r��GetReparseDeferralEnabled�SetReparseDeferralEnabledrr�r�)r3�was_enabledrs   r&r�zXMLParser.flush�s����k�;�;�=�=��	?��K�1�1�%�8�8�8��K���c�5�)�)�)�)���{�	 �	 �	 ����Q�������������	 ����
�K�1�1�+�>�>�>�>�>��D�K�1�1�+�>�>�>�>���s/�5A�B�
A:�A5�0B�5A:�:B�B5)r r!r"r#r5r�r�rr�r�r�r�r�r�r�r�r$r%r&rr�s���������"&��+�+�+�+�+�Z3B�3B�3B�j���	�	�	�=�=�=�0�0�0�
.�
.�
.�3�3�3�4%�4%�4%�l � � �*�*�*�"?�?�?�?�?r%r)�out�	from_filec�H�|�|�td���d}|�tj��x}}tt	|jfi|�����}|�*|�|��|���n|�t||���|�|�	��ndS)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�rSrrr�r�r�rrU)�xml_datar!r"�options�sior�s      r&rr�s�����I�-��U�V�V�V�
�C�
�{��K�M�M�!��c�
�.�s�y�D�D�G�D�D�
E�
E�
E�F������H�����������	�	�
�i��'�'�'�'� �_�3�<�<�>�>�>�$�6r%z	^\w+:\w+$c��eZdZdZdddddddd�d�Zefd�Zd�Zdd�Zd	�Z	d
j
fd�Zd�Zd
�Z
dd�Zd�Zd�Zd�ZdS)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�X�||_g|_||_||_|rt	|��nd|_|rt	|��nd|_||_|rt	|��|_nd|_|rt	|��j	|_
nd|_
dgg|_g|_|s>|j�
tt�������|j�
g��i|_dg|_d|_d|_d|_d|_dS)N)rAr�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__sE�������
�+���%���4A�K�c�-�0�0�0�t���2>�H�S��.�.�.�D���!1����	*�%(�)9�%:�%:�D�"�"�%)�D�"��	0�+.�/@�+A�+A�+N�D�(�(�+/�D�(�
<�$
�#�������	@��N�!�!�$�~�';�';�'=�'=�">�">�?�?�?�����b�!�!�!���� %�w���"�������������r%c#�:K�||��D]}|r|Ed{V���
dSrCr$)r3�ns_stack�	_reversedrps    r&�_iter_namespacesz!C14NWriterTarget._iter_namespaces7sJ����#�)�H�-�-�	&�	&�J��
&�%�%�%�%�%�%�%�%��	&�	&r%c��|�dd��\}}|�|j��D]\}}||kr
d|�d|��cS�td|�d|�d����)Nrrr�r�zPrefix z of QName "�" is not declared in scope)�splitrDr:r�)r3�
prefixed_namerr�r�ps      r&�_resolve_prefix_namez%C14NWriterTarget._resolve_prefix_name<s���$�*�*�3��2�2�����+�+�D�N�;�;�	*�	*�F�C���F�{�{�)�C�)�)�4�)�)�)�)�)���_�6�_�_�m�_�_�_�`�`�`r%c��|�4|dd�dkr|dd��dd��nd|f\}}n|}t��}|�|j��D]4\}}||kr||vr|r|�d|��n|||fcS|�|���5|jrd||jvr|j|}n!dt|j����x}|j|<|jd�||f��|�d|��||fS|s	d|vr|||fS|�|j	��D]=\}}||kr2|jd�||f��|r|�d|��n|||fcS�>|s|||fStd|�d	����)
Nrr�r�r�rrrczNamespace "rF)rr�rDr9�addr5r;rHr^r:r�)r3rrr(�
prefixes_seen�urs       r&�_qnamezC14NWriterTarget._qnameCs$���;�38��!��9��3C�3C�u�Q�R�R�y�'�'��Q�/�/�/�"�e��H�C����C����
��.�.�t�/F�G�G�	&�	&�I�A�v��C�x�x�F�-�7�7�,2�;�&�(�(�3�(�(�(��S�#�E�E�E�E����f�%�%�%�%��!�	/��d�&�&�&��)�#�.���1L�S��9I�5J�5J�1L�1L�L���)�#�.��#�B�'�.�.��V�}�=�=�=��$�$�s�$�$�c�3�.�.��	!�r��.�.���S�=� ��.�.�t�~�>�>�	F�	F�I�A�v��C�x�x��'��+�2�2�C��=�A�A�A�,2�;�&�(�(�3�(�(�(��S�#�E�E�E�E���	!���S�=� ��F�s�F�F�F�G�G�Gr%c�L�|js|j�|��dSdSrC)r@r�r^r�s  r&r�zC14NWriterTarget.datahs3���"�	$��J���d�#�#�#�#�#�	$�	$r%r�c�d�||j��}|jdd�=|jr!|jds|���}|j�7|jdc}|_|rt|��r|nd}|jg|�|�R�|�dS|r+|jr&|�t|����dSdSdS�Nrc)
r�r2r<rjr=�_looks_like_prefix_namer�r>r0�_escape_cdata_c14n)r3�
_join_textr�r��
qname_texts     r&r�zC14NWriterTarget._flushls����z�$�*�%�%���J�q�q�q�M���	 �D�$8��$<�	 ��:�:�<�<�D���*�(,�(;�T�%�D�$�%�!%�Q�*A�$�*G�*G�Q���T�J��D�K�*��*�z�*�*�*�*��%����	2�D�O�	2��K�K�*�4�0�0�1�1�1�1�1�	2�	2�	2�	2r%c��|jrdS|jr|���|jd�||f��dSrR)r@r�r�r:r^rs   r&r�zC14NWriterTarget.start_nszsN����	��F��:�	��K�K�M�M�M���r��!�!�3��-�0�0�0�0�0r%c�,�|j�"|js	||jvr|xjdz
c_dS|jr|���g}|j�|��|j�||jvr|||f|_dS|�|||��dSr
)	r4r@r�r�r9r^r6r=r�)r3r(r��new_namespacess    r&r�zC14NWriterTarget.start�s�����)��#�*�'*�d�.@�'@�'@����1�$����F��:�	��K�K�M�M�M�����&�&�~�6�6�6��!�-�#��9O�2O�2O�#&��~�">�D���F����C���/�/�/�/�/r%c������j�"|r �fd�|���D��}|h|�}i}|�/��|��x}||<|�|���j�h|rf��|��}|rL|D]H}	||	}
t|
��r/��|
��x}||
<|�|���Ind}nd}�j��fd�t|d����D��}|r!d�|D��}|���ng}|rlt|�����D]J\}
}|�|
|vr||vr|||d}||
\}}	}|�	|r|n|	|f���K|�
d��}�j�	|r|dkn�jd	���j}|d
||dz��|r(|d�
d�|D������|d
��|�*|t|||d����d�_�j�	g��dS)Nc�.��i|]\}}|�jv�||��Sr$)r3)�.0rrr3s   �r&�
<dictcomp>z+C14NWriterTarget._start.<locals>.<dictcomp>�s,���T�T�T�d�a��q��@S�7S�7S�Q��7S�7S�7Sr%c�(��i|]}|�|����Sr$r$)r\r�parse_qnames  �r&r]z+C14NWriterTarget._start.<locals>.<dictcomp>�s/���4�4�4�q��K�K��N�N�4�4�4r%c�.�|�dd��S)Nr�r)rG)rs r&r�z)C14NWriterTarget._start.<locals>.<lambda>�s��!�'�'�#�q�/�/�r%rc�*�g|]\}}|rd|znd|f��S)zxmlns:�xmlnsr$)r\rrs   r&�
<listcomp>z+C14NWriterTarget._start.<locals>.<listcomp>�s@������C��'-�9��F�"�"�'�3�?���r%rz+{http://www.w3.org/XML/1998/namespace}space�preservercr�r�c�@�g|]\}}d|�dt|���d���S)r�rr)�_escape_attrib_c14n)r\rrs   r&rcz+C14NWriterTarget._start.<locals>.<listcomp>�s9��T�T�T�$�!�Q�=�q�=�=�$7��$:�$:�=�=�=�T�T�Tr%r�T)r3r�rJrLr8rSrOr�sortr^r|r<r0r�rTr>r:)r3r(r�rYrVr��resolved_namesr�qattrs�	attr_namer�
parsed_qnamesrrr�
attr_qnamer�space_behaviourr�r_s`                  @r&r�zC14NWriterTarget._start�s6������*�u�*�T�T�T�T�e�k�k�m�m�T�T�T�E���������!�15�1J�1J�:�1V�1V�V�E�N�:�.��J�J�u�����'�3��3��1�1�%�8�8�F��
�!'�*�*�I�!�)�,�E�.�u�5�5�*�8<�8Q�8Q�RW�8X�8X�X���u� 5��
�
�5�)�)�)��	*�����F��k��4�4�4�4�F��1�1�53�53�53�4�4�4�
��	���#1����I�
�N�N������I��	H��u�{�{�}�}�-�-�
H�
H���1��%�!�v�+�+�!�~�:M�:M�%�n�Q�&7�8��;�A�-:�1�-=�*�
�I�s�� � ��"B�*�*��A�!F�G�G�G�G� �)�)�$Q�R�R����#�#�-<�
*�O�z�)�)��%�b�)�	+�	+�	+�
���
��c�M�#�&�q�)�)�*�*�*��	W��E�"�'�'�T�T�)�T�T�T�U�U�V�V�V�
��c�
�
�
��!��E�$�]�>�*�3M�%N�q�%Q�R�R�S�S�S��������b�!�!�!�!�!r%c��|jr|xjdzc_dS|jr|���|�d|�|��d�d���|j���t|j��dk|_|j	���|j
���dS)Nrrrr�)r@r�r�r0rOr<r�rHr?r9r:r�s  r&r�zC14NWriterTarget.end�s�����	����1�$����F��:�	��K�K�M�M�M����/����S�)�)�!�,�/�/�/�0�0�0��� � �"�"�"��d�2�3�3�q�8�����#�#�%�%�%���������r%c�0�|jsdS|jrdS|jr|�d��n"|jr|jr|���|�dt|���d���|js|�d��dSdS)Nr�z<!--z-->)r1r@r?r0r>r�r�rTr�s  r&r�zC14NWriterTarget.comment�s����"�	��F���	��F��?�	��K�K������
�_�	���	��K�K�M�M�M����8�-�d�3�3�8�8�8�9�9�9���	��K�K�������	�	r%c�4�|jrdS|jr|�d��n"|jr|jr|���|�|rd|�dt
|���d�nd|�d���|js|�d��dSdS)Nr�z<?r�z?>)r@r?r0r>r�r�rT)r3r�r�s   r&r�zC14NWriterTarget.pi�s�����	��F��?�	��K�K������
�_�	���	��K�K�M�M�M����:>�S�6��6�6�,�T�2�2�6�6�6�6�O��O�O�O�	U�	U�	U���	��K�K�������	�	r%rC)r r!r"r#r5�reversedrDrJrOr�r�r�r�r�r�r�r�r�r$r%r&rr�s��������, %���"&�$�#�$�# �# �# �# �# �J4<�&�&�&�&�
a�a�a�#H�#H�#H�#H�J$�$�$�!#��2�2�2�2�1�1�1�0�0�0�"C"�C"�C"�C"�J
�
�
����
�
�
�
�
r%rc�&�	d|vr|�dd��}d|vr|�dd��}d|vr|�dd��}d|vr|�dd��}|S#ttf$rt|��YdSwxYw)	NrErFr�rGr�rHrN�&#xD;rIr�s r&rTrT�s���)��$�;�;��<�<��W�-�-�D��$�;�;��<�<��V�,�,�D��$�;�;��<�<��V�,�,�D��4�<�<��<�<��g�.�.�D�����~�&�)�)�)�"�4�(�(�(�(�(�(�)���s�A)A,�, B�Bc��	d|vr|�dd��}d|vr|�dd��}d|vr|�dd��}d|vr|�dd��}d	|vr|�d	d
��}d|vr|�dd��}|S#ttf$rt|��YdSwxYw)
NrErFr�rGrrMrOz&#x9;r�z&#xA;rNrsrIr�s r&rfrfs���)��$�;�;��<�<��W�-�-�D��$�;�;��<�<��V�,�,�D��$�;�;��<�<��X�.�.�D��4�<�<��<�<��g�.�.�D��4�<�<��<�<��g�.�.�D��4�<�<��<�<��g�.�.�D�����~�&�)�)�)�"�4�(�(�(�(�(�(�)���s�BB �  C�C)r�)�_set_factoriesrCr�)rfr)@r#�__all__rrdr:r=r�r��collections.abcr�r�r�rr�rr	rrrrr
rr�contextmanagerr�r�rr4r2r�r�rrrrrr3rr�rXrrrrr
rrrrrrrr�compile�UNICODEr;rSrrTrfrg�_elementtreerur�r$r%r&�<module>r|s'��!�!�P����(��
�
�
�
�	�	�	�	�����	�	�	�	�����������������������		�		�		�		�		��		�		�		�#�#�#�
j�j�j�j�j�j�j�j�Z	$&�����$�������� ��+"�+"�+"�+"�+"�+"�+"�+"�`_/�_/�_/�_/�_/�_/�_/�_/�H��/+�/+���/+�b;�;�;�;�z0(�0(�0(�d���
�0(�0(�0(�d��������
�!�!�!�*-2�$*�38�(.�(,�16�(,����%3��!�
�
�
�
)�)�)� )�)�)�8)�)�)��!�T�"&������0�����b�'����"
�!%��&*�
�
�
�
�
����&/�/�/�/�l����5�5�5�5�p7�7�7�7�7�7�7�7�t����"����,�
�
�
�
�
�$v�v�v�v�v�v�v�v�th?�h?�h?�h?�h?�h?�h?�h?�Z7�t�t�7�7�7�7�7�<%�"�*�\�2�:�>�>�D����������D)�)�)�&)�)�)�.3��K�����+�+�+�+�+�+��N�7�1�2�2�2�2�2���	�	�	��D�D�	���s�E7�7F�?F

Hacked By AnonymousFox1.0, Coded By AnonymousFox