Hacked By AnonymousFox

Current Path : /opt/alt/python39/lib64/python3.9/xml/etree/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/xml/etree/__pycache__/ElementTree.cpython-39.pyc

a

R�f�"�@s�dZgd�ZdZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZGdd�de�Z
d	d
�ZGdd�d�Zifd
d�Zd^dd�Zd_dd�ZeZGdd�d�ZGdd�d�Ze	jdd��Zd`dd�Zdd�ZdZzee�ZWne�y�Yn0dd�Zd d!�Zeeed"�Zd#d$�Z d%d&d'd(d)d*d+d,�Z!e!e _!d-d.�Z"d/d0�Z#d1d2�Z$d3d4�Z%daddd5d6�d7d8�Z&Gd9d:�d:ej'�Z(dbddd5d6�d;d<�Z)d=d>�Z*dcd@dA�Z+dddBdC�Z,dedDdE�Z-GdFdG�dG�Z.dfdHdI�Z/dgdJdK�Z0e/Z1dhdLdM�Z2GdNdO�dO�Z3GdPdQ�dQ�Z4didddR�dSdT�Z5e�6dUej7�j8Z9GdVdW�dW�Z:dXdY�Z;dZd[�Z<zeZ=dd\l>Tdd]l>m?Z?Wne@�yzYn0e?ee�dS)jaLightweight 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@seZdZdZdS)rz�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__�r"r"�:/opt/alt/python39/lib64/python3.9/xml/etree/ElementTree.pyrjsrcCs
t|d�S)z2Return True if *element* appears to be an Element.�tag)�hasattr)�elementr"r"r#rxsrc@seZdZdZdZdZdZdZifdd�Zdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd7d!d"�Zd8d#d$�Zd9d%d&�Zd:d'd(�Zd)d*�Zd;d+d,�Zd-d.�Zd/d0�Zd1d2�Zd<d3d4�Z d5d6�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

    NcKs:t|t�std|jjf��||_i|�|�|_g|_dS)Nzattrib must be dict, not %s)�
isinstance�dict�	TypeError�	__class__rr$�attrib�	_children)�selfr$r+�extrar"r"r#�__init__�s
�zElement.__init__cCsd|jj|jt|�fS)Nz<%s %r at %#x>)r*rr$�id�r-r"r"r#�__repr__�szElement.__repr__cCs|�||�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.

        )r*)r-r$r+r"r"r#�makeelement�s	zElement.makeelementcCst�dt�|��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__r1r"r"r#�copy�s
�zElement.copycCs0|�|j|j�}|j|_|j|_||dd�<|S�N)r3r$r+�text�tail)r-�elemr"r"r#r7�s
zElement.__copy__cCs
t|j�Sr9)�lenr,r1r"r"r#�__len__�szElement.__len__cCstjdtdd�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)r4r5�
FutureWarningr=r,r1r"r"r#�__bool__�s
�zElement.__bool__cCs
|j|Sr9�r,�r-�indexr"r"r#�__getitem__�szElement.__getitem__cCs8t|t�r |D]}|�|�qn
|�|�||j|<dSr9)r'�slice�_assert_is_elementr,)r-rFr&�eltr"r"r#�__setitem__�s


zElement.__setitem__cCs|j|=dSr9rDrEr"r"r#�__delitem__�szElement.__delitem__cCs|�|�|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�rIr,�append�r-�
subelementr"r"r#rN�s
zElement.appendcCs$|D]}|�|�|j�|�qdS)zkAppend subelements from a sequence.

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

        NrM)r-�elementsr&r"r"r#�extend�s
zElement.extendcCs|�|�|j�||�dS)z(Insert *subelement* at position *index*.N)rIr,�insert)r-rFrPr"r"r#rSs
zElement.insertcCs t|t�stdt|�j��dS)Nzexpected an Element, not %s)r'�_Element_Pyr)�typer)r-�er"r"r#rIs
zElement._assert_is_elementcCs|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)r,�removerOr"r"r#rWs
zElement.removecCst�|||�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�r-�path�
namespacesr"r"r#rXs	zElement.findcCst�||||�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�r-rZ�defaultr[r"r"r#r\&szElement.findtextcCst�|||�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�findallrYr"r"r#r_4s	zElement.findallcCst�|||�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�iterfindrYr"r"r#r`?s	zElement.iterfindcCs |j��g|_d|_|_dS)z�Reset element.

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

        N)r+�clearr,r:r;r1r"r"r#raJs
z
Element.clearcCs|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.

        )r+�get)r-�keyr^r"r"r#rbUszElement.getcCs||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)r+)r-rc�valuer"r"r#�setbszElement.setcCs
|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()

        )r+�keysr1r"r"r#rflszElement.keyscCs
|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.

        )r+�itemsr1r"r"r#rgus	z
Element.itemsccsD|dkrd}|dus|j|kr$|V|jD]}|�|�EdHq*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$r,�iter)r-r$rVr"r"r#ri�s
zElement.iterccsX|j}t|t�s|durdS|j}|r,|V|D]"}|��EdH|j}|r0|Vq0dS)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;)r-r$�trVr"r"r#rk�szElement.itertext)N)NN)N)N)N)N)"rrr r!r$r+r:r;r/r2r3r8r7r>rCrGrKrLrNrRrSrIrWrXr\r_r`rarbrerfrgrirkr"r"r"r#r}s>	








	
rcKs&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.

    )r3rN)�parentr$r+r.r&r"r"r#r�s
rcCstt�}||_|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&r"r"r#r�s	rcCs&tt�}||_|r"|jd||_|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.

    � )rr
r:)�targetr:r&r"r"r#r
�s

r
c@sZeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�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.

    NcCs|rd||f}||_dS)Nz{%s}%s�r:)r-Ztext_or_urir$r"r"r#r/�szQName.__init__cCs|jSr9rpr1r"r"r#�__str__�sz
QName.__str__cCsd|jj|jfS)Nz<%s %r>)r*rr:r1r"r"r#r2�szQName.__repr__cCs
t|j�Sr9)�hashr:r1r"r"r#�__hash__�szQName.__hash__cCs t|t�r|j|jkS|j|kSr9�r'rr:�r-�otherr"r"r#�__le__�s
zQName.__le__cCs t|t�r|j|jkS|j|kSr9rtrur"r"r#�__lt__�s
zQName.__lt__cCs t|t�r|j|jkS|j|kSr9rtrur"r"r#�__ge__�s
zQName.__ge__cCs t|t�r|j|jkS|j|kSr9rtrur"r"r#�__gt__s
zQName.__gt__cCs t|t�r|j|jkS|j|kSr9rtrur"r"r#�__eq__s
zQName.__eq__)N)
rrr r!r/rqr2rsrwrxryrzr{r"r"r"r#r�s
rc@s~eZdZdZddd�Zdd�Zdd�Zdd	d
�Zddd�Zdd
d�Z	ddd�Z
d dd�Zd!dd�Zd"dd�dd�Z
dd�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.

    NcCs||_|r|�|�dSr9)�_rootr
)r-r&�filer"r"r#r/szElementTree.__init__cCs|jS)z!Return root element of this tree.�r|r1r"r"r#�getrootszElementTree.getrootcCs
||_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~)r-r&r"r"r#�_setroot"szElementTree._setrootcCs�d}t|d�st|d�}d}zt|durVt�}t|d�rV|�|�|_|jW|rT|��S|�d�}|sfqr|�|�qV|��|_|jW|r�|��Sn|r�|��0dS)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)r-�source�parser�close_source�datar"r"r#r
,s4


	�

��zElementTree.parsecCs|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|ri�r-r$r"r"r#riQs
zElementTree.itercCs:|dd�dkr,d|}tjd|tdd�|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 %rr?r@)r4r5rBr|rXrYr"r"r#rX]s��zElementTree.findcCs<|dd�dkr,d|}tjd|tdd�|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�r?r@)r4r5rBr|r\r]r"r"r#r\ss��zElementTree.findtextcCs:|dd�dkr,d|}tjd|tdd�|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�r?r@)r4r5rBr|r_rYr"r"r#r_�s��zElementTree.findallcCs:|dd�dkr,d|}tjd|tdd�|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�r?r@)r4r5rBr|r`rYr"r"r#r`�s��zElementTree.iterfindT��short_empty_elementscCs�|s
d}n|tvrtd|��|s4|dkr0d}nd}t||���\}}|dkr~|sp|dur~|��dkr~|��dvr~|d	|f�|d
kr�t||j�n,t|j|�\}	}
t|}|||j|	|
|d�Wd�n1s�0YdS)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='%s'?>
r:r�)�
_serialize�
ValueError�_get_writer�lower�_serialize_textr|�_namespaces)r-�file_or_filename�encoding�xml_declaration�default_namespace�methodr��writeZdeclared_encoding�qnamesr[Z	serializer"r"r#r��s4�
�
���zElementTree.writecCs|j|dd�S)Nr�)r�)r�)r-r}r"r"r#�
write_c14n�szElementTree.write_c14n)NN)N)N)N)NN)N)N)NNNN)rrr r!r/rr�r
rirXr\r_r`r�r�r"r"r"r#r
s$



%




��5rccs^z
|j}Wn^tyh|��dkr(d}t|d|dd��}|j|fVWd�n1sZ0YYn�0|��dkr�|t|dd�p�dfVn�t����}t|tj	�r�|}nft|tj
�r�t�|�}|�|j
�nBt�	�}dd�|_||_z|j|_|j|_Wnt�yYn0tj||dd	d
�}|�|j
�|j|fVWd�n1�sP0YdS)Nr�r��w�xmlcharrefreplace)r��errorsr�cSsdS�NTr"r"r"r"r#�<lambda>�z_get_writer.<locals>.<lambda>�
)r�r��newline)r��AttributeErrorr�r��getattr�
contextlib�	ExitStackr'�io�BufferedIOBase�	RawIOBase�BufferedWriter�callback�detach�writable�seekable�tell�
TextIOWrapper)r�r�r�r}�stackr"r"r#r��sB
�0


�r�csddi�i��rd��<���fdd�}|��D]�}|j}t|t�rZ|j�vr�||j�n<t|t�rv|�vr�||�n |dur�|tur�|tur�t|�|�	�D]F\}}t|t�r�|j}|�vr�||�t|t�r�|j�vr�||j�q�|j}t|t�r0|j�vr0||j�q0��fS)N�cs�z�|dd�dkr�|dd��dd�\}}��|�}|durjt�|�}|durZdt��}|dkrj|�|<|r�d||f�|<q�|�|<n�r�td��|�|<Wnty�t|�Yn0dS)Nr�{�}zns%dr�z%s:%sz<cannot use non-qualified names with default_namespace option)�rsplitrb�_namespace_mapr=r�r)�_raise_serialization_error)�qname�urir$�prefix�r�r[r�r"r#�	add_qname.s(


�z_namespaces.<locals>.add_qname)
rir$r'rr:rjrrr�rg)r<r�r�r$rcrdr:r"r�r#r�#s4




r�cKs�|j}|j}|tur$|d|��nv|tur<|d|��n^||}|dur||r\|t|��|D]}t|||d|d�q`�n|d|�t|���}	|	s�|�r2|r�t|��dd�d�D](\}
}|r�d|}|d	|t	|
�f�q�|	D]L\}}
t
|t�r�|j}t
|
t��r||
j}
nt	|
�}
|d
|||
f�q�|�sHt|��sH|�s�|d�|�rb|t|��|D]}t|||d|d��qf|d|d�n|d
�|j
�r�|t|j
��dS)N�	<!--%s-->�<?%s?>r��<cSs|dS�Nrr"��xr"r"r#r�vr�z _serialize_xml.<locals>.<lambda>�rc�:�
 xmlns%s="%s"� %s="%s"�>�</z />)r$r:rr
�
_escape_cdata�_serialize_xml�listrg�sorted�_escape_attribr'rr=r;)r�r<r�r[r��kwargsr$r:rVrg�v�kr"r"r#r�`s\
�
��


�
r�)
Zarea�baseZbasefont�br�col�frameZhrZimg�inputZisindex�link�metaZparamcKs�|j}|j}|tur(|dt|���n�|turD|dt|���nh||}|dur�|rd|t|��|D]}t|||d�qh�n,|d|�t|���}|s�|�r8|r�t|��dd�d�D](\}	}
|
r�d|
}
|d|
t	|	�f�q�|D]N\}
}	t
|
t��r|
j}
t
|	t��r||	j}	nt|	�}	|d	||
|	f�q�|d
�|�
�}|�rx|dk�sb|dk�rl||�n|t|��|D]}t|||d��q||tv�r�|d
|d
�|j�r�|t|j��dS)Nr�r�r�cSs|dSr�r"r�r"r"r#r��r�z!_serialize_html.<locals>.<lambda>r�r�r�r�r�ZscriptZstyler�)r$r:rr�r
�_serialize_htmlr�rgr�r�r'r�_escape_attrib_htmlr��
HTML_EMPTYr;)r�r<r�r[r�r$r:rVrgr�r�Zltagr"r"r#r��sX
��


r�cCs*|��D]}||�q|jr&||j�dSr9)rkr;)r�r<�partr"r"r#r��s
r�)r��htmlr:cCsLt�d|�rtd��tt���D]\}}||ks8||kr t|=q |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�r�r�rg)r�r�r�r�r"r"r#r�srr�r�ZrdfZwsdlZxsZxsiZdc)�$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/cCstd|t|�jf��dS)Nzcannot serialize %r (type %s))r)rUrrpr"r"r#r��s�r�c	CsfzBd|vr|�dd�}d|vr*|�dd�}d|vr>|�dd�}|WSttfy`t|�Yn0dS)N�&�&amp;r��&lt;r��&gt;��replacer)r�r�rpr"r"r#r�sr�c	Cs�z�d|vr|�dd�}d|vr*|�dd�}d|vr>|�dd�}d|vrR|�dd�}d	|vrf|�d	d
�}d|vrz|�dd�}d
|vr�|�d
d�}|WSttfy�t|�Yn0dS)Nr�r�r�r�r�r��"�&quot;�
z&#13;r�z&#10;�	z&#09;r�rpr"r"r#r�s$r�c	CsfzBd|vr|�dd�}d|vr*|�dd�}d|vr>|�dd�}|WSttfy`t|�Yn0dS)Nr�r�r�r�r�r�r�rpr"r"r#r�.sr�T)r�r�r�cCs:|dkrt��nt��}t|�j||||||d�|��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��streamr"r"r#r=s�rc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�_ListDataStreamz7An auxiliary stream accumulating into a list reference.cCs
||_dSr9)�lst)r-r�r"r"r#r/Wsz_ListDataStream.__init__cCsdSr�r"r1r"r"r#r�Zsz_ListDataStream.writablecCsdSr�r"r1r"r"r#r�]sz_ListDataStream.seekablecCs|j�|�dSr9)r�rN)r-�br"r"r#r�`sz_ListDataStream.writecCs
t|j�Sr9)r=r�r1r"r"r#r�csz_ListDataStream.tellN)	rrr r!r/r�r�r�r�r"r"r"r#r�Usr�cCs*g}t|�}t|�j||||||d�|S)Nr�)r�rr�)r&r�r�r�r�r�r�r�r"r"r#rfs�rcCsLt|t�st|�}|jtjdd�|��j}|r<|ddkrHtj�d�dS)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�stdoutrr;)r<r;r"r"r#rss

r�  cs`t|t�r|��}|dkr(td|����t|�s4dSd|�g����fdd���|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�cs�|d}z�|}Wn(ty<�|�}��|�Yn0|jrN|j��sT||_|D],}t|�rn�||�|jr~|j��sX||_qX|j��s��||_dSr�)�
IndexErrorrNr:�stripr=r;)r<�levelZchild_levelZchild_indentation�child��_indent_childrenZindentations�spacer"r#r�s

z indent.<locals>._indent_children)r'rrr�r=)�treerrr"rr#r�s
rcCst�}|�||�|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�rr"r"r#r
�s	r
csPt||d����fdd��G��fdd�dtjj�}|��d�_�~t���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�_parserc3s�d}ztt|d�st|d�}d}dV���EdH|�d�}|sBqN��|�q$���}���EdH|�_W|r�|��n|r�|��0dS)NFr�r�Ti@)r%r��read_eventsr�r��_close_and_return_root�rootr�)r�r�r�r)�it�
pullparserr"r#�iterator�s$



�ziterparse.<locals>.iteratorcseZdZ���jZdS)z$iterparse.<locals>.IterParseIteratorN)rrr �__next__r")rr�r"r#�IterParseIterator�srN)r�collections�abc�Iteratorr�next)r�rr�rr")rrr
r�r#r	�sr	c@sDeZdZddd�dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�ZdS)rN)rcCs<t��|_|ptt�d�|_|dur(d}|j�|j|�dS)N�ro)�end)r�deque�
_events_queuerrr�
_setevents)r-rrr"r"r#r/�s

zXMLPullParser.__init__c
Cs\|jdurtd��|rXz|j�|�Wn0tyV}z|j�|�WYd}~n
d}~00dS)�Feed encoded data to parser.Nz!feed() called after end of stream)rr�r��SyntaxErrorrrN)r-r��excr"r"r#r�
s
zXMLPullParser.feedcCs|j��}d|_|Sr9)rr�)r-rr"r"r#r
s
z$XMLPullParser._close_and_return_rootcCs|��dS)z�Finish feeding data to parser.

        Unlike XMLParser, does not return the root element. Use
        read_events() to consume elements from XMLPullParser.
        N)r
r1r"r"r#r�szXMLPullParser.closeccs.|j}|r*|��}t|t�r"|�q|VqdS)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)r-r�eventr"r"r#r	"s
zXMLPullParser.read_eventscCs |jdurtd��|j��dS)Nz"flush() called after end of stream)rr��flushr1r"r"r#r 0s
zXMLPullParser.flush)N)	rrr r/r�r
r�r	r r"r"r"r#r�s
rcCs"|stt�d�}|�|�|��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�r"r"r#r6s
rcCsR|stt�d�}|�|�|��}i}|��D]}|�d�}|r.|||<q.||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.

    rr0)rrr�r�rirb)r:r�rZidsr<r0r"r"r#rGs



rcCs,|stt�d�}|D]}|�|�q|��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.

    rr!)Zsequencer�r:r"r"r#r_s
	rc@sheZdZdZdddddd�dd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
ddd�Zdd�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_piscCsdg|_g|_d|_d|_d|_|dur*t}||_||_|durBt}||_	||_
|durZt}||_dSr9)
�_data�_elem�_lastr|�_tailr�_comment_factoryr$r
�_pi_factoryr%r�_factory)r-Zelement_factoryr"r#r$r%r"r"r#r/�s zTreeBuilder.__init__cCs.t|j�dksJd��|jdus(Jd��|jS)z;Flush builder buffers and return toplevel document Element.rzmissing end tagsNzmissing toplevel element)r=r'r|r1r"r"r#r��szTreeBuilder.closecCsf|jrb|jdur\d�|j�}|jr@|jjdus6Jd��||j_n|jjdusTJd��||j_g|_dS)Nr�zinternal error (tail)zinternal error (text))r&r(�joinr)r;r:�r-r:r"r"r#�_flush�s

zTreeBuilder._flushcCs|j�|�dS)zAdd text to current element.N)r&rN�r-r�r"r"r#r��szTreeBuilder.datacCsX|��|�||�|_}|jr2|jd�|�n|jdurB||_|j�|�d|_|S)z�Open new element and return it.

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

        r�Nr)r/r,r(r'rNr|r))r-r$�attrsr<r"r"r#�start�s
zTreeBuilder.startcCs@|��|j��|_|jj|ks4Jd|jj|f��d|_|jS)zOClose and return current Element.

        *tag* is the element name.

        z&end tag mismatch (expected %s, got %s)r)r/r'�popr(r$r)r�r"r"r#r�s��zTreeBuilder.endcCs|�|j|j|�S)z`Create a comment using the comment_factory.

        *text* is the text of the comment.
        )�_handle_singler*r$r.r"r"r#�comment�s
�zTreeBuilder.commentcCs|�|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 ''.
        )r4r+r%)r-ror:r"r"r#�pi�s�zTreeBuilder.picGs:||�}|r6|��||_|jr0|jd�|�d|_|S)Nr�r)r/r(r'rNr))r-�factoryrS�argsr<r"r"r#r4�szTreeBuilder._handle_single)N)N)
rrr r!r/r�r/r�r2rr5r6r4r"r"r"r#rqs�
	rc@sxeZdZdZddd�dd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�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)ror�cCs^zddlm}Wn:tyJzddl}WntyDtd��Yn0Yn0|�|d�}|durft�}||_|_||_|_	|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|_ d|_!i|_"zd
|j#|_$Wnt%�yXYn0dS)Nr��expatz7No module named expat; use SimpleXMLTreeBuilder insteadr�r2r�start_ns�end_nsr�r5r6rzExpat %d.%d.%d)&�xml.parsersr:�ImportErrorZpyexpatZParserCreaterr�rro�_target�error�_error�_names�_defaultZDefaultHandlerExpandr%�_start�StartElementHandler�_end�EndElementHandler�	_start_ns�StartNamespaceDeclHandler�_end_ns�EndNamespaceDeclHandlerr�ZCharacterDataHandlerr5�CommentHandlerr6�ProcessingInstructionHandlerZbuffer_text�ordered_attributes�specified_attributes�_doctype�entity�version_info�versionr�)r-ror�r:r�r"r"r#r/�sP�




zXMLParser.__init__cCs8|j}|j}|D�] }|dkrDd|_d|_|||jfdd�}||_q|dkrf|||jfdd�}||_q|dkr�t|j	d�r�|||j
fd	d�}n||fd
d�}||_q|dkr�t|j	d�r�|||jfd
d�}n||fdd�}||_
q|dk�r|||fdd�}||_q|dk�r&|||fdd�}||_qtd|��qdS)Nr2rcSs|||||�f�dSr9r")r$Z	attrib_inrrNr2r"r"r#�handler0sz%XMLParser._setevents.<locals>.handlerrcSs||||�f�dSr9r")r$rrNrr"r"r#rT5szstart-nsr;cSs|||||�f�dSr9r")r�r�rrNr;r"r"r#rT<scSs|||p
d|pdff�dS�Nr�r")r�r�rrNr"r"r#rT@szend-nsr<cSs||||�f�dSr9r")r�rrNr<r"r"r#rTFscSs||df�dSr9r")r�rrNr"r"r#rTJsr5cSs|||j�|�f�dSr9)ror5)r:rrNr-r"r"r#rTNsr6cSs|||j�||�f�dSr9)ror6)Z	pi_targetr�rrNr-r"r"r#rTRszunknown event %r)rrNrNrOrDrErFrGr%rorHrIrJrKrLrMr�)r-Zevents_queueZevents_to_reportr�rNZ
event_namerTr"r"r#r#sL
�
�
��

�
zXMLParser._seteventscCs&t|�}|j|_|j|jf|_|�dSr9)r�code�lineno�offsetZposition)r-rd�errr"r"r#�_raiseerrorYszXMLParser._raiseerrorcCsDz|j|}Wn0ty>|}d|vr0d|}||j|<Yn0|S)Nr�r�)rB�KeyError)r-rc�namer"r"r#�_fixname_szXMLParser._fixnamecCs|j�|pd|pd�SrU)ror;�r-r�r�r"r"r#rHjszXMLParser._start_nscCs|j�|pd�SrU)ror<)r-r�r"r"r#rJmszXMLParser._end_nscCsR|j}||�}i}|rDtdt|�d�D]}||d||||�<q&|j�||�S)Nrr?r)r]�ranger=ror2)r-r$�	attr_listZfixnamer+�ir"r"r#rDpszXMLParser._startcCs|j�|�|��Sr9)rorr]r�r"r"r#rF|szXMLParser._endc	Cs�|dd�}|dkr�z|jj}Wnty4YdS0z||j|dd��WnXty�ddlm}|�d||jj	|jj
f�}d|_|jj	|_|jj
|_
|�Yn0�n"|dkr�|dd	�d
kr�g|_�n|jdu�r�|dkr�d|_dS|��}|�sdS|j�|�t|j�}|dk�r�|jd}|d
k�r`|dk�r`|j\}}}	}
|	�r�|	dd�}	n*|dk�r�|dk�r�|j\}}}
d}	ndSt|jd��r�|j�||	|
dd��nt|d��r�t�dt�d|_dS)Nrr�r�rr9z'undefined entity %s: line %d, column %d�r��	z	<!DOCTYPEr�r?ZPUBLIC�ZSYSTEM��doctypezaThe doctype() method of XMLParser is ignored.  Define doctype() method on the TreeBuilder target.)ror�r�rQr[r=r:r@r�ZErrorLineNumberZErrorColumnNumberrVrWrXrPrrNr=r%rfr4r5�RuntimeWarning)r-r:r�Zdata_handlerr:rY�nrUr\Zpubid�systemr"r"r#rCsd���





�zXMLParser._defaultc
CsHz|j�|d�Wn0|jyB}z|�|�WYd}~n
d}~00dS)rFN)r��ParserArZ)r-r�r�r"r"r#r��szXMLParser.feedc
Cs�z|j�dd�Wn0|jyB}z|�|�WYd}~n
d}~00zLz|jj}WntydYn0|�W|`|`|`|`SW|`|`|`|`n|`|`|`|`0dS)z;Finish feeding data to parser and return element structure.r�TN)	r�rjrArZror�r�rr?)r-r�Z
close_handlerr"r"r#r��s  �
�zXMLParser.closec
Cs~|j��}z`z|j�d�|j�dd�Wn0|jyZ}z|�|�WYd}~n
d}~00W|j�|�n|j�|�0dS)NFr�)r�ZGetReparseDeferralEnabledZSetReparseDeferralEnabledrjrArZ)r-Zwas_enabledr�r"r"r#r �s
"zXMLParser.flush)rrr r!r/rrZr]rHrJrDrFrCr�r�r r"r"r"r#r�s	.66r)�out�	from_filecKs�|dur|durtd��d}|dur0t��}}tt|jfi|��d�}|durd|�|�|��n|durxt||d�|dur�|�	�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�r�rrr�r�r�r
r�)Zxml_datarkrlZoptionsZsior�r"r"r#r�s


rz	^\w+:\w+$c@s�eZdZdZdddddddd�dd�Zefdd�Zd	d
�Zddd�Zd
d�Z	dj
fdd�Zdd�Zdd�Z
ddd�Zdd�Zdd�Zdd�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	Cs�||_g|_||_||_|r$t|�nd|_|r6t|�nd|_||_|rRt|�|_nd|_|rjt|�j	|_
nd|_
dgg|_g|_|s�|j�
tt����|j�
g�i|_dg|_d|_d|_d|_d|_dS)N)r�r�Fr)�_writer&�_with_comments�_strip_textre�_exclude_attrs�
_exclude_tags�_rewrite_prefixes�_qname_aware_tags�intersection�_find_qname_aware_attrs�_declared_ns_stack�	_ns_stackrNr�r�rg�_prefix_map�_preserve_space�_pending_start�
_root_seen�
_root_done�_ignored_depth)	r-r�rmrnrorprqrrrsr"r"r#r/s2�zC14NWriterTarget.__init__ccs ||�D]}|r|EdHqdSr9r")r-Zns_stackZ	_reversedr[r"r"r#�_iter_namespaces6sz!C14NWriterTarget._iter_namespacescCs\|�dd�\}}|�|j�D]$\}}||krd|�d|��Sqtd|�d|�d���dS)Nr�rr�r�zPrefix z of QName "�" is not declared in scope)�splitr�r~r�)r-Z
prefixed_namer�r\r��pr"r"r#�_resolve_prefix_name;s
z%C14NWriterTarget._resolve_prefix_namecCs�|dur:|dd�dkr,|dd��dd�nd|f\}}n|}t�}|�|j�D]B\}}||kr�||vr�|rz|�d|��n|||fS|�|�qP|jr�||jvr�|j|}ndt|j���}|j|<|jd�||f�|�d|��||fS|�sd|v�r|||fS|�|j	�D]J\}}||k�r|jd�||f�|�rR|�d|��n|||fS�q|�st|||fSt
d|�d	���dS)
Nrr�r�r�r�rhr�zNamespace "r�)r�rer�r}�addryrr=rNr~r�)r-r�r�r$Z
prefixes_seen�ur�r"r"r#�_qnameBs.2 


&
zC14NWriterTarget._qnamecCs|js|j�|�dSr9)r�r&rNr0r"r"r#r�gszC14NWriterTarget.datar�cCs�||j�}|jdd�=|jr.|jds.|��}|jdurz|jd}|_|rVt|�rV|nd}|jg|�|�R�|durzdS|r�|jr�|�t	|��dS�Nr�)
r&rvr�rr��_looks_like_prefix_namerDr�rt�_escape_cdata_c14n)r-Z
_join_textr�r8�
qname_textr"r"r#r/ks


zC14NWriterTarget._flushcCs0|jr
dS|jr|��|jd�||f�dSr�)r�r&r/r~rNr^r"r"r#r;ys
zC14NWriterTarget.start_nscCs�|jdur,|js||jvr,|jd7_dS|jr:|��g}|j�|�|jdurn||jvrn|||f|_dS|�|||�dSr�)	rxr�r&r/r}rNrzr�rD)r-r$r1�new_namespacesr"r"r#r2�s
��zC14NWriterTarget.startcs�jdur$|r$�fdd�|��D�}|h|�}i}|durV��|�}||<|�|��jdur�|r���|�}|r�|D]0}	||	}
t|
�rv��|
�}||
<|�|�qvq�d}nd}�j��fdd�t|dd�d�D�}|r�dd�|D�}|��ng}|�rjt|���D]^\}
}|du�r@|
|v�r@||v�r@|||d	}||
\}}	}|�	|�r\|n|	|f��q
|�
d
�}�j�	|�r�|dkn�jd��j}|d
||d	�|�r�|d�
dd�|D���|d�|du�r�|t|||d	��d�_�j�	g�dS)Ncs i|]\}}|�jvr||�qSr")rw��.0r�r�r1r"r#�
<dictcomp>�r�z+C14NWriterTarget._start.<locals>.<dictcomp>csi|]}|�|��qSr"r")r�rh)�parse_qnamer"r#r��r�cSs|�dd�S)Nr�r)r�)rhr"r"r#r��r�z)C14NWriterTarget._start.<locals>.<lambda>r�cSs$g|]\}}|rd|nd|f�qS)zxmlns:Zxmlnsr")r�r�r�r"r"r#�
<listcomp>�s�z+C14NWriterTarget._start.<locals>.<listcomp>rz+{http://www.w3.org/XML/1998/namespace}spaceZpreserver�r�r�cSs&g|]\}}d|�dt|��d��qS)rnz="r�)�_escape_attrib_c14nr�r"r"r#r��r�r�T)rwrgr�r�r|r�r�r��sortrNrbr�rtr-r�r�r~)r-r$r1r�r�r�Zresolved_namesr�ZqattrsZ	attr_namerdZ
parsed_qnamesr`r�r�Z
attr_qnamer�Zspace_behaviourr�r")r�r-r#rD�s^


�
�

�
zC14NWriterTarget._startcCst|jr|jd8_dS|jr&|��|�d|�|�d�d��|j��t|j�dk|_|j	��|j
��dS)Nrr�rr�)r�r&r/rtr�r�r3r=r�r}r~r�r"r"r#r�s

zC14NWriterTarget.endcCsd|js
dS|jrdS|jr&|�d�n|jr:|jr:|��|�dt|��d��|js`|�d�dS)Nr�z<!--z-->)rur�r�rtr�r&r/r�r.r"r"r#r5�szC14NWriterTarget.commentcCsp|jr
dS|jr|�d�n|jr0|jr0|��|�|rNd|�dt|��d�n
d|�d��|jsl|�d�dS)Nr�z<?rnz?>)r�r�rtr�r&r/r�)r-ror�r"r"r#r6�s$�zC14NWriterTarget.pi)N)N)rrr r!r/�reversedr�r�r�r�r-r/r;r2rDrr5r6r"r"r"r#r�s �%
%
E
rc	CszzVd|vr|�dd�}d|vr*|�dd�}d|vr>|�dd�}d|vrR|�dd�}|WSttfytt|�Yn0dS)	Nr�r�r�r�r�r�r��&#xD;r�rpr"r"r#r��sr�c	Cs�z~d|vr|�dd�}d|vr*|�dd�}d|vr>|�dd�}d|vrR|�dd�}d	|vrf|�d	d
�}d|vrz|�dd�}|WSttfy�t|�Yn0dS)
Nr�r�r�r�r�r�r�z&#x9;r�z&#xA;r�r�r�rpr"r"r#r�s r�)rh)�_set_factories)N)N)N)NN)NN)r�r)N)NN)N)N)N)N)Ar!�__all__rr�r�r4r�r�collections.abcr�r�rrrrrrrr
rrr�contextmanagerr�r�r�r�re�	NameErrorr�r�r�rr�r�r�r�r�rr�r�rrrr
r	rrrrrrrr�compile�UNICODEr�r�rr�r�rTZ_elementtreer�r>r"r"r"r#�<module>s�H/

0e
1
=22�	�
��

6

2:


zp

Hacked By AnonymousFox1.0, Coded By AnonymousFox