OwlCyberSecurity - MANAGER
Edit File: ElementTree.cpython-310.opt-1.pyc
o ����S�gL"���������������������@���s���d�Z�g�d�ZdZddlZddlZddlZddlZddlZddlZddl Z ddl mZ�G�dd��de�Z d d ��ZG�dd��d�Zi�fd d�Zd^dd�Zd^dd�ZeZG�dd��d�ZG�dd��d�Ze jdd���Zd^dd�Zdd��ZdZzee�ZW�n �ey~���Y�nw�dd��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%d_ddd5d6�d7d8�Z&G�d9d:��d:ej'�Z(d_ddd5d6�d;d<�Z)d=d>��Z*d`d@dA�Z+d^dBdC�Z,d_dDdE�Z-G�dFdG��dG�Z.d^dHdI�Z/d^dJdK�Z0e/Z1d^dLdM�Z2G�dNdO��dO�Z3G�dPdQ��dQ�Z4d^dddR�dSdT�Z5e�6dUej7�j8Z9G�dVdW��dW�Z:dXdY��Z;dZd[��Z<zeZ=dd\l>T�dd]l>m?Z?�W�n�e@�y=���Y�dS�w�e?ee��dS�)aa��Lightweight 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�������������������@���s���e�Zd�ZdZdS�)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__��r"���r"����</opt/alt/python310/lib64/python3.10/xml/etree/ElementTree.pyr���j���s����r���c�����������������C���s ���t�|�d�S�)z2Return True if *element* appears to be an Element.�tag)�hasattr)�elementr"���r"���r#���r���x���s��� r���c�������������������@���s��e�Zd�ZdZdZ �dZ �dZ �dZ �i�fdd�Zdd��Z dd��Z d d ��Zdd��Zd d��Z dd��Zdd��Zdd��Zdd��Zdd��Zdd��Zdd��Zdd��Zdd ��Zd7d!d"�Zd8d#d$�Zd7d%d&�Zd7d'd(�Zd)d*��Zd7d+d,�Zd-d.��Zd/d0��Zd1d2��Zd7d3d4�Z d5d6��Z!dS�)9r���ah��An 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�����������������K���s:���t�|t�std|jjf���||�_i�|�|�|�_g�|�_d�S�)Nzattrib must be dict, not %s)� isinstance�dict� TypeError� __class__r���r$����attrib� _children)�selfr$���r+����extrar"���r"���r#����__init__����s��� � zElement.__init__c�����������������C���s���d|�j�j|�jt|��f�S�)Nz<%s %r at %#x>)r*���r���r$����id�r-���r"���r"���r#����__repr__��������zElement.__repr__c�����������������C���s���|���||�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.makeelementc�����������������C���s���t��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__r1���r"���r"���r#����copy����s ����zElement.copyc�����������������C���s0���|���|�j|�j�}|�j|_|�j|_|�|d�d��<�|S��N)r4���r$���r+����text�tail)r-����elemr"���r"���r#���r8�������s ���zElement.__copy__c�����������������C���� ���t�|�j�S�r:���)�lenr,���r1���r"���r"���r#����__len__�������� zElement.__len__c�����������������C���s���t�jdtdd��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���)r5���r6���� FutureWarningr?���r,���r1���r"���r"���r#����__bool__����s ����zElement.__bool__c�����������������C���s ���|�j�|�S�r:����r,����r-����indexr"���r"���r#����__getitem__����rA���zElement.__getitem__c�����������������C���s8���t�|t�r|D�]}|��|��qn|��|��||�j|<�d�S�r:���)r'����slice�_assert_is_elementr,���)r-���rI���r&����eltr"���r"���r#����__setitem__����s��� � zElement.__setitem__c�����������������C���s���|�j�|=�d�S�r:���rG���rH���r"���r"���r#����__delitem__����s���zElement.__delitem__c�����������������C���s���|���|��|�j�|��dS�)a��Add *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�rL���r,����append�r-���� subelementr"���r"���r#���rQ�������s��� zElement.appendc�����������������C���s$���|D�] }|���|��|�j�|��qdS�)zkAppend subelements from a sequence. *elements* is a sequence with zero or more elements. NrP���)r-����elementsr&���r"���r"���r#����extend����s��� �zElement.extendc�����������������C���s���|���|��|�j�||��dS�)z(Insert *subelement* at position *index*.N)rL���r,����insert)r-���rI���rS���r"���r"���r#���rV�����s��� zElement.insertc�����������������C���s ���t�|t�stdt|�j���d�S�)Nzexpected an Element, not %s)r'����_Element_Pyr)����typer���)r-����er"���r"���r#���rL�����s��� �zElement._assert_is_elementc�����������������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)r,����removerR���r"���r"���r#���r[�����s��� zElement.removec�����������������C�������t��|�||�S�)a��Find 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#���r]��������� zElement.findc�����������������C���s���t��|�|||�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-���r_����defaultr`���r"���r"���r#���rb���&��s���zElement.findtextc�����������������C���r\���)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. Returns list containing all matching elements in document order. )r����findallr^���r"���r"���r#���re���4��ra���zElement.findallc�����������������C���r\���)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����iterfindr^���r"���r"���r#���rf���?��ra���zElement.iterfindc�����������������C���s ���|�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<���r1���r"���r"���r#���rg���J��s��� z Element.clearc�����������������C���s���|�j��||�S�)ag��Get 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-����keyrd���r"���r"���r#���rh���U��s���zElement.getc�����������������C���s���||�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-���ri����valuer"���r"���r#����setb��s���zElement.setc�����������������C���� ���|�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+����keysr1���r"���r"���r#���rm���l��s��� zElement.keysc�����������������C���rl���)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+����itemsr1���r"���r"���r#���rn���u��s��� z Element.itemsc�����������������c���sF�����|dkrd}|du�s|�j�|kr|�V��|�jD�] }|�|�E�dH��qdS�)a��Create 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$���rY���r"���r"���r#���rp������s���� �zElement.iterc�����������������c���sZ�����|�j�}t|t�s|durdS�|�j}|r|V��|�D�]}|���E�dH��|j}|r*|V��qdS�)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$����trY���r"���r"���r#���rr������s������zElement.itertextr:����NN)"r���r���r ���r!���r$���r+���r;���r<���r/���r2���r4���r9���r8���r@���rF���rJ���rN���rO���rQ���rU���rV���rL���r[���r]���rb���re���rf���rg���rh���rk���rm���rn���rp���rr���r"���r"���r"���r#���r���}���sH���� r���c�����������������K���s&���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. )r4���rQ���)�parentr$���r+���r.���r&���r"���r"���r#���r������s��� r���c�����������������C���s���t�t�}|�|_|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. )r���r���r;���)r;���r&���r"���r"���r#���r������s��� r���c�����������������C���s&���t�t�}|�|_|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. � )r���r ���r;���)�targetr;���r&���r"���r"���r#���r ������s ��� r ���c�������������������@���sZ���e�Zd�ZdZddd�Zdd��Zdd��Zd d ��Zdd��Zd d��Z dd��Z dd��Zdd��ZdS�)r���a���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�����������������C���s���|rd||f�}||�_�d�S�)Nz{%s}%s�r;���)r-���Ztext_or_urir$���r"���r"���r#���r/������s��� zQName.__init__c�����������������C�������|�j�S�r:���rx���r1���r"���r"���r#����__str__���s���z QName.__str__c�����������������C���s���d|�j�j|�jf�S�)Nz<%s %r>)r*���r���r;���r1���r"���r"���r#���r2����������zQName.__repr__c�����������������C���r>���r:���)�hashr;���r1���r"���r"���r#����__hash__���rA���zQName.__hash__c�����������������C���s ���t�|t�r|�j|jkS�|�j|kS�r:����r'���r���r;����r-����otherr"���r"���r#����__le__������� zQName.__le__c�����������������C���s ���t�|t�r|�j|jk�S�|�j|k�S�r:���r~���r���r"���r"���r#����__lt__���r����zQName.__lt__c�����������������C���s ���t�|t�r|�j|jkS�|�j|kS�r:���r~���r���r"���r"���r#����__ge__���r����zQName.__ge__c�����������������C���s ���t�|t�r|�j|jkS�|�j|kS�r:���r~���r���r"���r"���r#����__gt__��r����zQName.__gt__c�����������������C���s ���t�|t�r|�j|jkS�|�j|kS�r:���r~���r���r"���r"���r#����__eq__��r����zQName.__eq__r:���) r���r���r ���r!���r/���rz���r2���r}���r����r����r����r����r����r"���r"���r"���r#���r������s���� r���c�������������������@���s����e�Zd�ZdZddd�Zdd��Zdd��Zdd d �Zddd�Zdd d�Z ddd�Z ddd�Zddd�Z ddd�dd�Z dd��ZdS�)r���a%��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�����������������C���s���||�_�|r|��|��d�S�d�S�r:���)�_rootr ���)r-���r&����filer"���r"���r#���r/�����s����zElementTree.__init__c�����������������C���ry���)z!Return root element of this tree.�r����r1���r"���r"���r#����getroot��s���zElementTree.getrootc�����������������C���s ���||�_�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"��s��� zElementTree._setrootc�����������������C���s����d}t�|d�st|d�}d}z<|du�r,t��}t�|d�r,|�|�|�_|�jW�|r+|����S�S� �|�d�}|s5n|�|��q-|���|�_|�jW�|rJ|����S�S�|rR|����w�w�)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%����openr���r����r�����closer�����feed)r-����source�parser�close_source�datar"���r"���r#���r ���,��s4��� �� � � �zElementTree.parsec�����������������C���s���|�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����rp����r-���r$���r"���r"���r#���rp���Q��s��� zElementTree.iterc�����������������C����:���|dd��dkrd|�}t�jd|�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 %rrB���rC���)r5���r6���rE���r����r]���r^���r"���r"���r#���r]���]��������zElementTree.findc�����������������C���s<���|dd��dkrd|�}t�jd|�tdd��|�j�|||�S�)ae��Find 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. Nr���r����r����r����rB���rC���)r5���r6���rE���r����rb���rc���r"���r"���r#���rb���s��s�����zElementTree.findtextc�����������������C���r����)aa��Find 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. Nr���r����r����r����rB���rC���)r5���r6���rE���r����re���r^���r"���r"���r#���re������r����zElementTree.findallc�����������������C���r����)ag��Find 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. Nr���r����r����r����rB���rC���)r5���r6���rE���r����rf���r^���r"���r"���r#���rf������r����zElementTree.iterfindT��short_empty_elementsc����������������C���s����|sd}n |t�vrtd|���|s|dkrd}nd}t||��Q\}}|dkr?|s8|du�r?|���dkr?|���dvr?|d |f���|d krJt||�j��nt|�j|�\} } t�|�}|||�j| | |d��W�d����dS�W�d����dS�1�ssw���Y��dS�)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.writec�����������������C���s���|�j�|dd�S�)Nr����)r����)r����)r-���r����r"���r"���r#���� write_c14n���s���zElementTree.write_c14nrt���r:���)NNNN)r���r���r ���r!���r/���r����r����r ���rp���r]���rb���re���rf���r����r����r"���r"���r"���r#���r��� ��s&���� % ��5r���c�����������������c���sf����z|�j�}W�n2�ty8���|���dkrd}t|�d|dd��}|j�|fV��W�d�����Y�d�S�1�s0w���Y��Y�d�S�w�|���dkrL|t|�dd��pGdfV��d�S�t����Y}t|�tj �rZ|�}n2t|�tj �rlt�|��}|�|j ��n t� ��}dd��|_||_�z |�j|_|�j|_W�n �ty����Y�nw�tj||dd d �}|�|j ��|j�|fV��W�d�����d�S�1�s�w���Y��d�S�)Nr����r�����w�xmlcharrefreplace)r�����errorsr����c�������������������S�������dS��NTr"���r"���r"���r"���r#����<lambda>��s����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�������sL���� �&�� ��"�r����c��������������������s��d�d�i�i����rd���<�����fdd�}|�����D�]m}�|�j}t|t�r-|j�vr,||j��nt|t�r;|�vr:||��n|d�urK|turK|turKt|��|�� ��D�]#\}}t|t�r[|j}|�vrc||��t|t�rr|j�vrr||j��qO|�j}t|t�r�|j�vr�||j��q��fS�)N��c��������������������s����zU|�d�d��dkrI|�dd�����dd�\}}��|�}|d�u�r5t�|�}|d�u�r-dt���}|dkr5|�|<�|rBd||f��|�<�W�d�S�|�|�<�W�d�S���rOtd��|��|�<�W�d�S��tyc���t|���Y�d�S�w�)Nr����{�}zns%dr����z%s:%sz<cannot use non-qualified names with default_namespace option)�rsplitrh����_namespace_mapr?���r����r)����_raise_serialization_error)�qname�urir$����prefix�r����r`���r����r"���r#���� add_qname.��s*��� ��z_namespaces.<locals>.add_qname) rp���r$���r'���r���r;���rq���r���r���r����rn���)r=���r����r����r$���ri���rj���r;���r"���r����r#���r����#��s<��� � � � �r����c�����������������K���s���|j�}|j}|tu�r|�d|���n�|tu�r|�d|���n�||�}|d�u�r;|r,|�t|���|D�]}t|�||d�|d��q.n�|�d|���t|����} | sK|r�|rlt|���dd��d�D�]\} }|rad|�}|�d |t | �f���qW| D�]%\}} t |t�rz|j}t | t�r�|| j�} nt | �} |�d ||�| f���qn|s�t|�s�|s�|�d��|r�|�t|���|D�]}t|�||d�|d��q�|�d|�d���n|�d ��|j r�|�t|j ���d�S�d�S�)N� <!--%s-->�<?%s?>r�����<c�����������������S�������|�d�S��Nr���r"�����xr"���r"���r#���r����v�������z _serialize_xml.<locals>.<lambda>�ri����:� xmlns%s="%s"� %s="%s"�>�</z />)r$���r;���r���r ���� _escape_cdata�_serialize_xml�listrn����sorted�_escape_attribr'���r���r?���r<���)r����r=���r����r`���r�����kwargsr$���r;���rY���rn����v�kr"���r"���r#���r����`��s`��� ��� � ��r����) Zarea�baseZbasefont�br�col�frameZhrZimg�inputZisindex�link�metaZparamc�����������������K���s���|j�}|j}|tu�r|�dt|����n�|tu�r |�dt|����n�||�}|d�u�r=|r0|�t|���|D�] }t|�||d���q2n�|�d|���t|����}|sM|r�|rnt|���dd��d�D�]\} } | rcd| �} |�d| t | �f���qY|D�]%\} } t | t�r|| j} t | t�r�|| j�} nt| �} |�d || �| f���qp|�d ��|� ��}|r�|dks�|dkr�|�|��n|�t|���|D�] }t|�||d���q�|tvr�|�d |�d ���|jr�|�t|j���d�S�d�S�)Nr����r����r����c�����������������S���r����r����r"���r����r"���r"���r#���r�������r����z!_serialize_html.<locals>.<lambda>r����r����r����r����r����ZscriptZstyler����)r$���r;���r���r����r ����_serialize_htmlr����rn���r����r����r'���r����_escape_attrib_htmlr����� HTML_EMPTYr<���)r����r=���r����r`���r����r$���r;���rY���rn���r����r����Zltagr"���r"���r#���r�������s\����� � �r����c�����������������C���s.���|����D�]}|�|��q|jr|�|j��d�S�d�S�r:���)rr���r<���)r����r=����partr"���r"���r#���r�������s ��� �r����)r�����htmlr;���c�����������������C���sL���t��d|��r td��tt����D�]\}}||ks||�krt|=�q|�t|<�dS�)at��Register 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����rn���)r����r����r����r����r"���r"���r#���r������s����r���r����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/c�����������������C���s���t�d|�t|��jf���)Nzcannot serialize %r (type %s))r)���rX���r���rx���r"���r"���r#���r�������s����r����c�������������� ���C����d���z!d|�v�r|���dd�}�d|�v�r|���dd�}�d|�v�r|���dd�}�|�W�S��ttfy1���t|���Y�d�S�w�)N�&�&r�����<r�����>��replacer)���r����r����rx���r"���r"���r#���r������s����r����c�������������� ���C���s����zId|�v�r|���dd�}�d|�v�r|���dd�}�d|�v�r|���dd�}�d|�v�r)|���dd�}�d |�v�r3|���d d �}�d|�v�r=|���dd�}�d |�v�rG|���d d�}�|�W�S��ttfyY���t|���Y�d�S�w�)Nr����r����r����r����r����r�����"�"� z r����z � z	r����rx���r"���r"���r#���r������s&����r����c�������������� ���C���r����)Nr����r����r����r����r����r���r����rx���r"���r"���r#���r����.��s����r����T)r����r����r����c����������������C���s:���|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�BytesIOr���r�����getvalue)r&���r����r����r����r����r�����streamr"���r"���r#���r���=��s����r���c�������������������@���s8���e�Zd�ZdZdd��Zdd��Zdd��Zdd ��Zd d��ZdS�) �_ListDataStreamz7An auxiliary stream accumulating into a list reference.c�����������������C���s ���||�_�d�S�r:���)�lst)r-���r ��r"���r"���r#���r/���W��rA���z_ListDataStream.__init__c�����������������C���r����r����r"���r1���r"���r"���r#���r����Z������z_ListDataStream.writablec�����������������C���r����r����r"���r1���r"���r"���r#���r����]��r ��z_ListDataStream.seekablec�����������������C���s���|�j��|��d�S�r:���)r ��rQ���)r-����br"���r"���r#���r����`������z_ListDataStream.writec�����������������C���r>���r:���)r?���r ��r1���r"���r"���r#���r����c��rA���z_ListDataStream.tellN) r���r���r ���r!���r/���r����r����r����r����r"���r"���r"���r#���r��U��s����r��c����������������C���s*���g�}t�|�}t|��j||||||d��|S�)Nr��)r��r���r����)r&���r����r����r����r����r����r ��r��r"���r"���r#���r���f��s����r���c�����������������C���sP���t�|�t�s t|��}�|�jtjdd��|����j}|r|d�dkr&tj�d��dS�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'���r���r�����sys�stdoutr����r<���)r=���r<���r"���r"���r#���r���s��s��� �r���� c��������������������s`���t�|�t�r |����}�|dk�rtd|�����t|��sdS�d|���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. r���z,Initial indentation level must be >= 0, got Nr����c��������������������s����|d�}z�|�}W�n�t�y����|���}��|��Y�nw�|�jr'|�j���s*||�_|�D�]}t|�r7��||��|jr?|j���sB||_q,|j���sO�|�|_d�S�d�S�r����)� IndexErrorrQ���r;����stripr?���r<���)r=����levelZchild_levelZchild_indentation�child��_indent_childrenZindentations�spacer"���r#���r�����s$���� � �z indent.<locals>._indent_children)r'���r���r����r����r?���)�treer��r��r"���r��r#���r������s��� r���c�����������������C���s���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. )r���r ���)r����r����r��r"���r"���r#���r ������s��� r ���c��������������������sP���t�||d�����fdd��G���fdd�dtjj�}|����d��_�~t������S�)aJ��Incrementally 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�_parserc�����������������3���s������d}z>t�|�d�st|�d�}�d}d�V�� �����E�d�H��|��d�}|s#n��|��q����}����E�d�H��|��_W�|r@|�����d�S�d�S�|rI|�����w�w�)NFr����r����Ti�@��)r%���r�����read_eventsr����r�����_close_and_return_root�rootr����)r����r����r����r��)�it� pullparserr"���r#����iterator���s,���� �� �ziterparse.<locals>.iteratorc�����������������������s���e�Zd�Z����jZdS�)z$iterparse.<locals>.IterParseIteratorN)r���r���r ����__next__r"���)r ��r����r"���r#����IterParseIterator���s����r"��N)r����collections�abc�Iteratorr���next)r����r��r����r"��r"���)r��r ��r��r����r#���r ������s���r ���c�������������������@���sD���e�Zd�Zddd�dd�Zdd��Zdd��Zd d ��Zdd��Zd d��ZdS�)r���N)r��c����������������C���s<���t����|�_|ptt��d�|�_|d�u�rd}|�j�|�j|��d�S�)N�rw���)�end)r#���deque� _events_queuer���r���r��� _setevents)r-���r��r��r"���r"���r#���r/������s ��� zXMLPullParser.__init__c�������������� ���C���s`���|�j�du�r td��|r.z |�j��|��W�dS��ty-�}�z |�j�|��W�Y�d}~dS�d}~ww�dS�)�Feed encoded data to parser.Nz!feed() called after end of stream)r��r����r�����SyntaxErrorr*��rQ���)r-���r�����excr"���r"���r#���r���� ��s��� ���zXMLPullParser.feedc�����������������C���s���|�j����}d�|�_�|S�r:���)r��r����)r-���r��r"���r"���r#���r����s��� z$XMLPullParser._close_and_return_rootc�����������������C���s���|������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��r1���r"���r"���r#���r������s���zXMLPullParser.closec�����������������c���s4�����|�j�}|r|���}t|t�r|�|V��|sdS�dS�)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_eventsc�����������������C���s ���|�j�d�u�r td��|�j�����d�S�)Nz"flush() called after end of stream)r��r�����flushr1���r"���r"���r#���r2��0��s��� zXMLPullParser.flushr:���) r���r���r ���r/���r����r��r����r��r2��r"���r"���r"���r#���r������s���� r���c�����������������C���s"���|st�t��d�}|�|���|���S�)a��Parse 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'���r���r���r����r����)r;���r����r"���r"���r#���r���6��s��� r���c�����������������C���sR���|st�t��d�}|�|���|���}i�}|���D�] }|�d�}|r$|||<�q||fS�)a��Parse 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'��r0���)r���r���r����r����rp���rh���)r;���r����r��Zidsr=���r0���r"���r"���r#���r���G��s��� �r���c�����������������C���s,���|st�t��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. r'��r3��)Zsequencer����r;���r"���r"���r#���r���_��s ��� r���c�������������������@���sh���e�Zd�ZdZdddddd�dd�Zdd��Zd d ��Zdd��Zd d��Zdd��Z dd��Z ddd�Zdd��ZdS�)r���a8��Generic 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����������������C���sd���g�|�_�g�|�_d�|�_d�|�_d�|�_|d�u�rt}||�_||�_|d�u�r!t}||�_ ||�_ |d�u�r-t}||�_d�S�r:���) �_data�_elem�_lastr�����_tailr����_comment_factoryr6��r ����_pi_factoryr7��r����_factory)r-���Zelement_factoryr4��r5��r6��r7��r"���r"���r#���r/������s ��� zTreeBuilder.__init__c�����������������C���ry���)z;Flush builder buffers and return toplevel document Element.r����r1���r"���r"���r#���r�������s���zTreeBuilder.closec�����������������C���sB���|�j�r|�jd�urd�|�j��}|�jr||�j_n||�j_g�|�_�d�S�d�S��Nr����)r8��r:���joinr;��r<���r;����r-���r;���r"���r"���r#����_flush���s��� �zTreeBuilder._flushc�����������������C���rZ���)zAdd text to current element.N)r8��rQ����r-���r����r"���r"���r#���r�������s���zTreeBuilder.datac�����������������C���sX���|������|��||��|�_}|�jr|�jd��|��n|�jdu�r!||�_|�j�|��d|�_|S�)z�Open new element and return it. *tag* is the element name, *attrs* is a dict containing element attributes. r ��Nr���)rB��r>��r:��r9��rQ���r����r;��)r-���r$����attrsr=���r"���r"���r#����start���s��� zTreeBuilder.startc�����������������C���s ���|������|�j���|�_d|�_|�jS�)zOClose and return current Element. *tag* is the element name. r���)rB��r9���popr:��r;��r����r"���r"���r#���r(�����s���zTreeBuilder.endc�����������������C���s���|���|�j|�j|�S�)z`Create a comment using the comment_factory. *text* is the text of the comment. )�_handle_singler<��r6��rA��r"���r"���r#����comment���s��� �zTreeBuilder.commentc�����������������C���s���|���|�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 ''. )rG��r=��r7��)r-���rw���r;���r"���r"���r#����pi���s����zTreeBuilder.pic�����������������G���s:���||��}|r|������||�_|�jr|�jd��|��d|�_|S�)Nr ��r���)rB��r:��r9��rQ���r;��)r-����factoryrV����argsr=���r"���r"���r#���rG�����s���zTreeBuilder._handle_singler:���) r���r���r ���r!���r/���r����rB��r����rE��r(��rH��rI��rG��r"���r"���r"���r#���r���q��s����� r���c�������������������@���sx���e�Zd�ZdZddd�dd�Zdd��Zdd ��Zd d��Zdd ��Zdd��Z dd��Z dd��Zdd��Zdd��Z dd��Zdd��ZdS�)r���aa��Element 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)rw���r����c����������������C���sN��zddl�m}�W�n�ty#���zdd�l}W�n�ty ���td��w�Y�nw�|�|d�}|d�u�r1t��}|�|�_|�_|�|�_|�_ |j |�_i�|�_|�j |_t|d�rQ|�j|_t|d�rZ|�j|_t|d�rc|�j|_t|d�rl|�j|_t|d �ru|j|_t|d �r~|j|_t|d�r�|j|_d|_d|_d�|�_ i�|�_!z d |j"�|�_#W�d�S��t$y����Y�d�S�w�)Nr�����expatz7No module named expat; use SimpleXMLTreeBuilder insteadr����rE��r(���start_ns�end_nsr����rH��rI��r���zExpat %d.%d.%d)%�xml.parsersrM���ImportErrorZpyexpatZParserCreater���r����r��rw����_target�error�_error�_names�_defaultZDefaultHandlerExpandr%����_start�StartElementHandler�_end�EndElementHandler� _start_ns�StartNamespaceDeclHandler�_end_ns�EndNamespaceDeclHandlerr����ZCharacterDataHandlerrH���CommentHandlerrI���ProcessingInstructionHandlerZbuffer_text�ordered_attributes�_doctype�entity�version_info�versionr����)r-���rw���r����rM��r����r"���r"���r#���r/������sV������� �zXMLParser.__init__c�����������������C���s*��|�j�}|j}|D�]�}|dkrd|_|||�jfdd�}||_q|dkr/|||�jfdd�}||_q|dkrNt|�jd�rC|||�j fd d�}n||fd d�}||_ q|dkrmt|�jd�rb|||�jfd d�}n||fdd�}||_q|dkr}|||�fdd�}||_ q|dkr�|||�fdd�}||_qtd|���d�S�)NrE��r���c�����������������S�������||||�|�f��d�S�r:���r"���)r$���Z attrib_inr1��rQ���rE��r"���r"���r#����handler.������z%XMLParser._setevents.<locals>.handlerr(��c�����������������S�������||||��f��d�S�r:���r"���)r$���r1��rQ���r(��r"���r"���r#���rg��3������zstart-nsrN��c�����������������S���rf��r:���r"���)r����r����r1��rQ���rN��r"���r"���r#���rg��:��rh��c�����������������S���s���|||�pd|pdff��d�S�r?��r"���)r����r����r1��rQ���r"���r"���r#���rg��>��s���zend-nsrO��c�����������������S���ri��r:���r"���)r����r1��rQ���rO��r"���r"���r#���rg��D��rj��c�����������������S���s���||d�f��d�S�r:���r"���)r����r1��rQ���r"���r"���r#���rg��H��r��rH��c�����������������S���s���|||j��|��f��d�S�r:���)rw���rH��)r;���r1��rQ���r-���r"���r"���r#���rg��L��r3���rI��c�����������������S���s���|||j��|�|�f��d�S�r:���)rw���rI��)Z pi_targetr����r1��rQ���r-���r"���r"���r#���rg��P��s���zunknown event %r)r��rQ���ra��rW��rX��rY��rZ��r%���rw���r[��r\��r]��r^��r_��r`��r����)r-���Zevents_queueZevents_to_reportr����rQ���Z event_namerg��r"���r"���r#���r+��"��sL��� � ��� ��zXMLParser._seteventsc�����������������C���s"���t�|�}|j|_|j|jf|_|�r:���)r����code�lineno�offsetZposition)r-���rj����errr"���r"���r#����_raiseerrorW��s���zXMLParser._raiseerrorc�����������������C���sD���z|�j�|�}W�|S��ty!���|}d|v�rd|�}||�j�|<�Y�|S�w�)Nr����r����)rU���KeyError)r-���ri����namer"���r"���r#����_fixname]��s�����zXMLParser._fixnamec�����������������C���s���|�j��|pd|p d�S�r?��)rw���rN���r-���r����r����r"���r"���r#���r[��h��s���zXMLParser._start_nsc�����������������C���s���|�j��|pd�S�r?��)rw���rO��)r-���r����r"���r"���r#���r]��k��r��zXMLParser._end_nsc�����������������C���sR���|�j�}||�}i�}|r"tdt|�d�D�]}||d��||||��<�q|�j�||�S�)Nr���rB���r���)rr���ranger?���rw���rE��)r-���r$���� attr_listZfixnamer+����ir"���r"���r#���rW��n��s���zXMLParser._startc�����������������C���s���|�j��|��|��S�r:���)rw���r(��rr��r����r"���r"���r#���rY��z��r{���zXMLParser._endc�������������� ���C���s���|d�d��}|dkrTz|�j�j}W�n �ty���Y�d�S�w�z||�j|dd�����W�d�S��tyS���ddlm}�|�d||�jj |�jj f��}d|_|�jj |_|�jj |_ |�w�|dkre|d�d ��d kreg�|�_d�S�|�jd�ur�|dkrsd�|�_d�S�|���}|s{d�S�|�j�|��t|�j�}|dkr�|�jd�}|d kr�|dkr�|�j\}}} } | r�| dd��} n|dkr�|dkr�|�j\}}} d�} nd�S�t|�j�d�r�|�j��|| | dd����nt|�d�r�t�dt��d�|�_d�S�d�S�d�S�)Nr���r����r ��r���rL��z'undefined entity %s: line %d, column %d����r����� ���z <!DOCTYPEr����rB���ZPUBLIC����ZSYSTEM�����doctypezaThe doctype() method of XMLParser is ignored. Define doctype() method on the TreeBuilder target.)rw���r����r����rc��rp��rP��rM��rS��r����ZErrorLineNumberZErrorColumnNumberrk��rl��rm��rb��r��rQ���r?���r%���r{��r5���r6����RuntimeWarning)r-���r;���r����Zdata_handlerrM��rn���nrX���rq��Zpubid�systemr"���r"���r#���rV��}��sn������� � � � � zXMLParser._defaultc�������������� ���C���sH���z |�j��|d��W�dS��|�jy#�}�z|��|��W�Y�d}~dS�d}~ww�)r,��FN)r�����ParserT��ro��)r-���r����r����r"���r"���r#���r�������s�����zXMLParser.feedc�������������� ���C���s����z |�j��dd��W�n�|�jy!�}�z|��|��W�Y�d}~nd}~ww�z'z|�jj}W�n �ty2���Y�n w�|��W�|�`�|�`|�`|�`S�W�|�`�|�`|�`|�`dS�|�`�|�`|�`|�`w�)z;Finish feeding data to parser and return element structure.�����TN) r����r��rT��ro��rw���r����r����r��rR��)r-���r����Z close_handlerr"���r"���r#���r�������s&������ �� zXMLParser.closec�������������� ���C���s����|�j����}z:z|�j��d��|�j��dd��W�n�|�jy-�}�z|��|��W�Y�d�}~nd�}~ww�W�|�j��|��d�S�W�|�j��|��d�S�|�j��|��w�)NFr���)r����ZGetReparseDeferralEnabledZSetReparseDeferralEnabledr��rT��ro��)r-���Zwas_enabledr����r"���r"���r#���r2�����s��� ����zXMLParser.flush)r���r���r ���r!���r/���r+��ro��rr��r[��r]��rW��rY��rV��r����r����r2��r"���r"���r"���r#���r������s���� -56r���)�out� from_filec����������������K���s����|�du�r|du�rt�d��d}|du�rt����}}tt|jfi�|��d�}|�dur2|�|���|����n |dur<t||d��|durD|� ��S�dS�)a3��Convert 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��r���r���r����r����r����r ���r��)Zxml_datar���r���ZoptionsZsior����r"���r"���r#���r������s��� r���z ^\w+:\w+$c�������������������@���s����e�Zd�ZdZdddddddd�dd�Zefdd�Zd d ��Zddd�Zd d��Z dj fdd�Zdd��Zdd��Z ddd�Zdd��Zdd��Zdd��ZdS�)r���a��� 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���������� ������C���s����||�_�g�|�_||�_||�_|rt|�nd�|�_|rt|�nd�|�_||�_|r)t|�|�_nd�|�_|r5t|�j |�_ nd�|�_ dgg|�_g�|�_|sL|�j� tt������|�j� g���i�|�_dg|�_d�|�_d|�_d|�_d|�_d�S�)N)r����r����Fr���)�_writer8���_with_comments�_strip_textrk����_exclude_attrs� _exclude_tags�_rewrite_prefixes�_qname_aware_tags�intersection�_find_qname_aware_attrs�_declared_ns_stack� _ns_stackrQ���r����r����rn����_prefix_map�_preserve_space�_pending_start� _root_seen� _root_done�_ignored_depth) r-���r����r���r���r���r���r���r���r���r"���r"���r#���r/�����s2���� zC14NWriterTarget.__init__c�����������������c���s"�����||�D�] }|r|E�d�H��qd�S�r:���r"���)r-���Zns_stackZ _reversedr`���r"���r"���r#����_iter_namespaces4��s���� ��z!C14NWriterTarget._iter_namespacesc�����������������C���sX���|��dd�\}}|��|�j�D�]\}}||kr d|��d|�����S�qtd|��d|��d���)Nr����r���r����r����zPrefix z of QName "�" is not declared in scope)�splitr���r���r����)r-���Z prefixed_namer����rq��r�����pr"���r"���r#����_resolve_prefix_name9��s����z%C14NWriterTarget._resolve_prefix_namec�����������������C���sx��|d�u�r|d�d��dkr|dd�����dd�nd|f\}}n|}t��}|��|�j�D�]!\}}||krD||vrD|r=|��d|���n|||f��S�|�|��q(|�jry||�jv�rX|�j|�}n dt|�j�����}|�j|<�|�jd��||f��|��d|���||fS�|s�d|vr�|||fS�|��|�j �D�]"\}}||kr�|�jd��||f��|r�|��d|���n|||f��S�q�|s�|||fS�t d|��d ���) Nr���r����r����r����r����r}��r ��zNamespace "r���)r����rk���r���r����addr���r���r?���rQ���r���r����)r-���r����r����r$���Z prefixes_seen�ur����r"���r"���r#����_qname@��s0���2 � zC14NWriterTarget._qnamec�����������������C���s���|�j�s|�j�|��d�S�d�S�r:���)r���r8��rQ���rC��r"���r"���r#���r����e��s����zC14NWriterTarget.datar����c�����������������C���s����||�j��}|�j�d�d��=�|�jr|�jd�s|���}|�jd�ur=|�jd�}|�_|r+t|�r+|nd�}|�jg�|�|�R����|d�ur=d�S�|rK|�jrM|��t |���d�S�d�S�d�S��Nr ��) r8��r���r���r��r����_looks_like_prefix_namerW��r���r����_escape_cdata_c14n)r-���Z _join_textr����rK��� qname_textr"���r"���r#���rB��i��s��� �zC14NWriterTarget._flushc�����������������C���s0���|�j�rd�S�|�jr|�����|�jd��||f��d�S�r���)r���r8��rB��r���rQ���rs��r"���r"���r#���rN��w��s ���zC14NWriterTarget.start_nsc�����������������C���s����|�j�d�ur|�js ||�j�v�r|��jd7��_d�S�|�jr|�����g�}|�j�|��|�jd�ur7||�jv�r7|||f|�_d�S�|��|||��d�S�r����) r���r���r8��rB��r���rQ���r���r���rW��)r-���r$���rD���new_namespacesr"���r"���r#���rE����s��� � zC14NWriterTarget.startc��������������������s����j�d�ur|r�fdd�|���D��}|h|�}i�}|d�ur+��|��}||<�|�|���jd�urX|rX��|�}|rU|D�]} || �} t| �rS��| ��}|| <�|�|��q;nd�}nd�}�j����fdd�t|dd��d�D��}|rzdd��|D��}|����ng�}|r�t|����D�]*\} }|d�ur�| |v�r�||v�r�|||��d �}|| �\}} }|� |r�|n| |f��q�|� d �}�j� |r�|dkn�jd����j}|d ||�d ����|r�|d� dd��|D�����|d��|d�ur�|t|||��d ����d�_�j� g���d�S�)Nc��������������������s ���i�|�]\}}|��j�vr||�qS�r"���)r�����.0r����r����r1���r"���r#���� <dictcomp>���s��� �z+C14NWriterTarget._start.<locals>.<dictcomp>c��������������������s���i�|�]}|��|��qS�r"���r"���)r���r}��)�parse_qnamer"���r#���r������s����c�����������������S���s���|���dd�S�)Nr����r���)r���)r}��r"���r"���r#���r�������s����z)C14NWriterTarget._start.<locals>.<lambda>r����c�����������������S���s$���g�|�]\}}|rd�|�nd|f�qS�)zxmlns:Zxmlnsr"���)r���r����r����r"���r"���r#���� <listcomp>���s������z+C14NWriterTarget._start.<locals>.<listcomp>r���z+{http://www.w3.org/XML/1998/namespace}spaceZpreserver ��r����r����c�����������������S���s&���g�|�]\}}d�|��dt�|���d��qS�)rv���z="r����)�_escape_attrib_c14nr���r"���r"���r#���r������s���&�r����T)r���rn���r���r���r���r���r���r�����sortrQ���rh���r���r���r@��r���r���r���)r-���r$���rD��r���r���r����Zresolved_namesr����ZqattrsZ attr_namerj���Z parsed_qnamesru��r����r����Z attr_qnamer����Zspace_behaviourr����r"���)r���r-���r#���rW�����sb��� �� �� �zC14NWriterTarget._startc�����������������C���st���|�j�r|��j�d8��_�d�S�|�jr|�����|��d|��|�d���d���|�j����t|�j�dk|�_|�j ����|�j ����d�S�)Nr���r����r���r����)r���r8��rB��r���r���r���rF��r?���r���r���r���r����r"���r"���r#���r(�����s��� zC14NWriterTarget.endc�����������������C���sh���|�j�sd�S�|�jr d�S�|�jr|��d��n |�jr|�jr|�����|��dt|���d���|�js2|��d��d�S�d�S�)Nr����z<!--z-->)r���r���r���r���r���r8��rB��r���rA��r"���r"���r#���rH�����s����zC14NWriterTarget.commentc�����������������C���st���|�j�rd�S�|�jr|��d��n |�jr|�jr|�����|��|r'd|��dt|���d�nd|��d���|�js8|��d��d�S�d�S�)Nr����z<?rv���z?>)r���r���r���r���r8��rB��r���)r-���rw���r����r"���r"���r#���rI�����s���$��zC14NWriterTarget.pir:���)r���r���r ���r!���r/����reversedr���r���r���r����r@��rB��rN��rE��rW��r(��rH��rI��r"���r"���r"���r#���r������s"�����% % E r���c�������������� ���C���sx���z+d|�v�r|���dd�}�d|�v�r|���dd�}�d|�v�r|���dd�}�d|�v�r)|���dd�}�|�W�S��ttfy;���t|���Y�d�S�w�) Nr����r����r����r����r����r����r���
r����rx���r"���r"���r#���r������s����r���c�������������� ���C���s����z?d|�v�r|���dd�}�d|�v�r|���dd�}�d|�v�r|���dd�}�d|�v�r)|���dd�}�d |�v�r3|���d d �}�d|�v�r=|���dd�}�|�W�S��ttfyO���t|���Y�d�S�w�) Nr����r����r����r����r����r���r��z	r����z
r��r���r����rx���r"���r"���r#���r�����s"����r���)ro���)�_set_factoriesr:���rt���)r��r���)Ar!����__all__r���r��r����r5���r����r#��Zcollections.abcr����r����r���r-��r���r���r���r���r���r ���r���r���r����contextmanagerr����r����r����r����rk���� NameErrorr����r����r����r���r����r����r����r����r����r���r����r��r���r���r���r ���r ���r���r���r���r���r���r���r���r����compile�UNICODEr����r���r���r���r���rW���Z_elementtreer���rQ��r"���r"���r"���r#����<module>���s�����H��/ 0�e 1=2�2� � �� 6 2 : z�n���