%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.12/xml/dom/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.12/xml/dom/__pycache__/expatbuilder.cpython-312.pyc

�

���fm����dZddlmZmZmZddlmZmZmZddlm	Z	ddl
mZmZddl
mZejZej Zej"Zej$j&Zej$j(Zej$j*Zej$j,Zej.�Zej2dd�ej2dd	�ej2dd
�ej2dd�ej2dd�ej2dd
�ej2dd�ej2dd�ej2dd�d�	ZGd�de�Zd�Zd�ZGd�d�ZeeefZ Gd�de�Z!Gd�de�Z"Gd�de"�Z#Gd�de"�Z$d Z%d!e%zZ&Gd"�d#e�Z'Gd$�d%�Z(Gd&�d'e(e�Z)Gd(�d)e(e'�Z*Gd*�d+e+�Z,Gd,�d-e�Z-d3d.�Z.d3d/�Z/d3d0�Z0d3d1�Z1d2�Z2y)4z�Facility to use the Expat parser to load a minidom instance
from a string or file.

This avoids all the overhead of SAX and pulldom to gain performance.
�)�
xmlbuilder�minidom�Node)�EMPTY_NAMESPACE�EMPTY_PREFIX�XMLNS_NAMESPACE)�expat)�
_append_child�_set_attribute_node)�
NodeFilterN�cdata�enumeration�entity�entities�id�idref�idrefs�nmtoken�nmtokens)	�CDATA�ENUM�ENTITY�ENTITIES�ID�IDREF�IDREFS�NMTOKEN�NMTOKENSc�H�eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zy)
�ElementInfo��
_attr_info�_model�tagNameNc�.�||_g|_||_y�N)r$r"r#)�selfr$�models   �+/usr/lib/python3.12/xml/dom/expatbuilder.py�__init__zElementInfo.__init__?s�����������c�H�|j|j|jfSr&r!�r's r)�__getstate__zElementInfo.__getstate__Ds��������T�\�\�9�9r+c�.�|\|_|_|_yr&r!)r'�states  r)�__setstate__zElementInfo.__setstate__Gs��5:�2�����d�lr+c��|jD]0}|d|k(s�|d}|ddk(rtdcSt|dcStjS)N����r�(r)r"�
_typeinfo_mapr�_no_type)r'�aname�info�ts    r)�getAttributeTypezElementInfo.getAttributeTypeJs]���O�O�	3�D��A�w�%����H���Q�4�3�;�(��0�0�(��b��2�2�
	3����r+c�"�tjSr&)rr7)r'�namespaceURI�	localNames   r)�getAttributeTypeNSzElementInfo.getAttributeTypeNSTs�����r+c��|jrE|jd}|tjjtjjfvSy�NrF)r#r	r(�
XML_CTYPE_ANY�XML_CTYPE_MIXED)r'�types  r)�isElementContentzElementInfo.isElementContentWsF���;�;��;�;�q�>�D����� 9� 9� %��� ;� ;� =�=�
=�r+c�p�|jr*|jdtjjk(SyrA)r#r	r(�XML_CTYPE_EMPTYr-s r)�isEmptyzElementInfo.isEmpty_s)���;�;��;�;�q�>�U�[�[�%@�%@�@�@�r+c�J�|jD]}|d|k(s�|ddk(cSy)Nr3r4rF)r")r'r8r9s   r)�isIdzElementInfo.isIdes5���O�O�	(�D��A�w�%���B�x�4�'�'�	(�r+c�(�|j||f�Sr&)rJ)r'�euri�ename�aurir8s     r)�isIdNSzElementInfo.isIdNSks���y�y�$���'�'r+r&)
�__name__�
__module__�__qualname__�	__slots__r*r.r1r;r?rErHrJrO�r+r)r r <s4��1�I��
:�;� � ����(r+r c�&�|j||�Sr&)�_intern_setdefault)�builder�ss  r)�_internrYos���%�%�a��+�+r+c�6�d|vsJ�|jd�}|j}t|�dk(r)|\}}}|||�}|�d|��}|||�}|||�}n3t|�dk(r|\}}t}|||�x}}nt	d|z��|||�|||fS)N� ��:�z4Unsupported syntax: spaces in URIs not supported: %r)�splitrV�lenr�
ValueError)rW�name�parts�intern�uri�	localname�prefix�qnames        r)�_parse_ns_namerirs����$�;��;��J�J�s�O�E�
�
'�
'�F�
�5�z�Q��!&���Y�����'��!�9�-���u�e�$���9�i�0�	�	�U��q�����Y���"�9�i�8�8��	��O�RV�V�W�W��#�s��Y���5�5r+c��eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy) �ExpatBuilderzPDocument builder that uses Expat to build a ParsedXML.DOM document
    instance.Nc��|�tj�}||_|jj�%t	|jj�|_nd|_t|_d|_|j�yr&)
r�Options�_options�filter�FilterVisibilityController�_filterr�_finish_start_element�_parser�reset)r'�optionss  r)r*zExpatBuilder.__init__�sc���?� �(�(�*�G���
��=�=���+�5�d�m�m�6J�6J�K�D�L��D�L�*,�D�&�����
�
�r+c�*�tj�S)zCreate a new parser object.)r	�ParserCreater-s r)�createParserzExpatBuilder.createParser�s���!�!�#�#r+c�B�|js�|j�|_|jjj|_d|j_d|j_d|j_|j|j�|jS)z7Return the parser object, creating a new one if needed.T)	rsrxrd�
setdefaultrV�buffer_text�ordered_attributes�specified_attributes�installr-s r)�	getParserzExpatBuilder.getParser�so���|�|��,�,�.�D�L�&*�l�l�&9�&9�&D�&D�D�#�'+�D�L�L�$�.2�D�L�L�+�04�D�L�L�-��L�L����&��|�|�r+c��tjtdd�|_|j|_|jj
|_d|_y)z6Free all data structures used during DOM construction.NF)�theDOMImplementation�createDocumentr�document�curNode�
_elem_info�_cdatar-s r)rtzExpatBuilder.reset�s>��,�;�;��T�4�)��
��}�}����-�-�2�2�����r+c��|j|_|j|_|j|_|j|_|jjr|j|_|j|_
|jjr|j|_|jj"r4|j$|_|j(|_|j,|_n|j0|_|j2|_|j6|_|j:|_|j>|_ y)z>Install the callbacks needed to build the DOM into the parser.N)!�start_doctype_decl_handler�StartDoctypeDeclHandler�first_element_handler�StartElementHandler�end_element_handler�EndElementHandler�
pi_handler�ProcessingInstructionHandlerrnr�entity_decl_handler�EntityDeclHandler�notation_decl_handler�NotationDeclHandler�comments�comment_handler�CommentHandler�cdata_sections�start_cdata_section_handler�StartCdataSectionHandler�end_cdata_section_handler�EndCdataSectionHandler�character_data_handler_cdata�CharacterDataHandler�character_data_handler�external_entity_ref_handler�ExternalEntityRefHandler�xml_decl_handler�XmlDeclHandler�element_decl_handler�ElementDeclHandler�attlist_decl_handler�AttlistDeclHandler�r'�parsers  r)r~zExpatBuilder.install�s���*.�)H�)H��&�%)�%?�%?��"�#'�#;�#;�� �.2�o�o��+��=�=�!�!�'+�'?�'?�F�$�%)�%?�%?��"��=�=�!�!�$(�$8�$8�F�!��=�=�'�'�.2�.N�.N�F�+�,0�,J�,J�F�)�*.�*K�*K�F�'�*.�*E�*E�F�'�*.�*J�*J��'� $� 5� 5���$(�$=�$=��!�$(�$=�$=��!r+c�|�|j�}d}	|jd�x}rQ|j|d�|r'|jjr|j|�d}|jd�x}r�Q|jdd�|j}|j�d|_|S#t$rY�0wxYw)zIParse a document from a file object, returning the document
        node.Ti@Fr+N)	r�read�Parser��documentElement�
_setup_subset�ParseEscapertrs)r'�filer��first_buffer�buffer�docs      r)�	parseFilezExpatBuilder.parseFile�s������!����	� �I�I�g�.�.�&�.����V�U�+��D�M�M�$A�$A��&�&�v�.�$��	!�I�I�g�.�.�&�.�

�L�L��d�#��m�m���
�
������
���	��	�s�A#B/�8B/�/	B;�:B;c���|j�}	|j|d�|j|�|j}|j�d|_|S#t$rY�0wxYw)z<Parse a document from a string, returning the document node.TN)rr�r�r�r�rtrs)r'�stringr�r�s    r)�parseStringzExpatBuilder.parseString�sc�����!��	��L�L���&����v�&��m�m���
�
������
���	��	�s�#A�	A&�%A&c��|jjrGt�}|j|�|j	�}||jj_yy)z/Load the internal subset if there might be one.N)r��doctype�InternalSubsetExtractorr��	getSubset�internalSubset)r'r��	extractor�subsets    r)r�zExpatBuilder._setup_subset�sJ���=�=� � �/�1�I��!�!�&�)��(�(�*�F�39�D�M�M�!�!�0�	!r+c�~�|jjj|||�}|j|_t	|j|�||j_|jrn|jj|�tk(rLd|j_|jjd=d}d|j_d|j_|rb|�"g|j_g|j_d|j_d|j_|j$|j_yy�N���)r��implementation�createDocumentType�
ownerDocumentr
r�rq�
acceptNode�
FILTER_REJECT�
childNodesrsr�r�r�_seq�	notationsr�r��end_doctype_decl_handler�EndDoctypeDeclHandler)r'�doctypeName�systemId�publicId�has_internal_subsetr�s      r)r�z'ExpatBuilder.start_doctype_decl_handler�s����-�-�.�.�A�A���8�-�� $�
�
����d�m�m�W�-� '��
�
���<�<�D�L�L�3�3�G�<�
�M�$(�D�M�M�!��
�
�(�(��,��G�-1�D�L�L�*�/3�D�L�L�,���"�(*�� � �%�)+��!�!�&�*.�D�L�L�'�8<�D�L�L�5�15�1N�1N�D�L�L�.�
r+c���|jjr|j|j_|j
|j_|js|jst|_
yyyr&)rnr�r�rsr�r�r�r�rqr�_finish_end_elementr-s r)r�z%ExpatBuilder.end_doctype_decl_handlersM���=�=�!�!�*.�*>�*>�D�L�L�'�48�O�O����1����4�<�<�')�D�$�$0�r+c��|jj||�}t|j|�|jr?|jj|�tk(r|jj|�yyyr&)r��createProcessingInstructionr
r�rqr�r��removeChild)r'�target�data�nodes    r)r�zExpatBuilder.pi_handler	s]���}�}�8�8���F���d�l�l�D�)��<�<�D�L�L�3�3�D�9�]�J��L�L�$�$�T�*�K�<r+c���|jj}|jrZ|jr+|djt
k(r|dj
|�y|jj|�}d|_n`|r2|djtk(r|d}|j|z}||_
ytj�}||_
|j|_
t|j|�y)Nr�T)r�r�r��_cdata_continue�nodeType�CDATA_SECTION_NODE�
appendDatar��createCDATASection�	TEXT_NODEr�r�Textr�r
)r'r�r�r��values     r)r�z)ExpatBuilder.character_data_handler_cdatas����\�\�,�,�
��;�;��&�&� ��n�-�-�1C�C��2��)�)�$�/���=�=�3�3�D�9�D�#'�D� �
�J�r�N�3�3�y�@��b�>�D��I�I��$�E��D�I���<�<�>�D��D�I�!%���D���d�l�l�D�)r+c�2�|jj}|r0|djtk(r|d}|j|z|_ytj�}|j|z|_|j|_t|j|�yr�)
r�r�r�r�r�rr�r�r�r
)r'r�r�r�s    r)r�z#ExpatBuilder.character_data_handler#sv���\�\�,�,�
��*�R�.�1�1�Y�>��b�>�D��	�	�D�(�D�I���|�|�~���I�I��$��	�!�]�]����d�l�l�D�)r+c��|ry|jjsy|jj||||�}|�6|jj	|�}	|j
j
|	�|jjjjj
|�|jrO|jj|�tk(r,|jjjjd=yyyr�)rnrr��_create_entity�createTextNoder��appendr�r�rqr�r�)
r'�
entityName�is_parameter_entityr��baser�r��notationNamer��childs
          r)r�z ExpatBuilder.entity_decl_handler.s������}�}�%�%���}�}�+�+�J��,4�l�D�����M�M�0�0��7�E��O�O�"�"�5�)��
�
���&�&�+�+�2�2�4�8��<�<�D�L�L�3�3�D�9�]�J��
�
�%�%�.�.�3�3�B�7�K�<r+c�f�|jj|||�}|jjjjj|�|jrO|jj|�tk(r,|jjjjd=yyyr�)	r��_create_notationr�r�r�r�rqr��
FILTER_ACCEPT)r'r�r�r�r�r�s      r)r�z"ExpatBuilder.notation_decl_handler@s����}�}�-�-�l�H�h�O���
�
���'�'�,�,�3�3�D�9��<�<�D�L�L�3�3�D�9�]�J��
�
�%�%�/�/�4�4�R�8�K�<r+c��|jj|�}t|j|�|jr?|jj|�tk(r|jj|�yyyr&)r��
createCommentr
r�rqr�r�r�)r'r�r�s   r)r�zExpatBuilder.comment_handlerFs[���}�}�*�*�4�0���d�l�l�D�)��<�<�D�L�L�3�3�D�9�]�J��L�L�$�$�T�*�K�<r+c� �d|_d|_y)NTF�r�r�r-s r)r�z(ExpatBuilder.start_cdata_section_handlerLs�����$��r+c� �d|_d|_y)NFr�r-s r)r�z&ExpatBuilder.end_cdata_section_handlerPs�����$��r+c��y�Nr3rT)r'�contextr�r�r�s     r)r�z(ExpatBuilder.external_entity_ref_handlerTs��r+c��|j�|jst|_|j|j�_|j	||�yr&)rqr�rr��start_element_handlerrr�)r'rb�
attributess   r)r�z"ExpatBuilder.first_element_handlerWs?���<�<�����')�D�$�/3�/I�/I�����,��"�"�4��4r+c��|jj|�}t|j|�||_|rjt	dt|�d�D]Q}t
j||tdt�}||dz}||_
|j|_t||��S||jjur|j|�yy)Nrr^r3)r��
createElementr
r��ranger`r�Attrrrr�r�rr�rr)r'rbr�r��i�ar�s       r)r�z"ExpatBuilder.start_element_handler]s����}�}�*�*�4�0���d�l�l�D�)������1�c�*�o�q�1�
-���L�L��A���!%�|�5��"�1�Q�3������"&�-�-���#�D�!�,�

-��t�}�}�4�4�4��&�&�t�,�5r+c�T�|jr�||jjury|jj|�}|tk(rt|�n|tk(rt|�ny|j|_	|jj|�|j�yyr&)rqr�r��startContainerr��Rejecter�FILTER_SKIP�Skipper�
parentNoder�r��unlink)r'r��filts   r)rrz"ExpatBuilder._finish_start_elementns����<�<��t�}�}�4�4�4���<�<�.�.�t�4�D��}�$������$���
���?�?�D�L��O�O�'�'��-��K�K�M�#r+c�`�|j}|j|_|j|�yr&)r�rr�)r'rbr�s   r)r�z ExpatBuilder.end_element_handler�s&���,�,���)�)���� � ��)r+c�^�|jj|j�}|r|j||�|jrh||j
jury|jj|�tk(r,|jj|�|j�yyyr&)r��getr$�_handle_white_text_nodesrqr�r�r�r�r�r�r)r'r�r9s   r)r�z ExpatBuilder._finish_end_element�s������"�"�7�?�?�3����)�)�'�4�8��<�<��$�-�-�7�7�7���|�|�&�&�w�/�=�@����(�(��1���� �A�r+c�(�|jjs|j�syg}|jD]B}|jt
k(s�|jj�r�2|j|��D|D]}|j|��yr&)
rn�whitespace_in_element_contentrEr�r�r�r��stripr�r�)r'r�r9�Lr�s     r)r	z%ExpatBuilder._handle_white_text_nodes�s}���M�M�7�7��(�(�*��

���_�_�	 �E��~�~��*�5�:�:�3C�3C�3E������	 �
�	$�E����U�#�	$r+c��|jj|�}|�t||�|j|<y|j�J�||_yr&)r�rr r#)r'rbr(r9s    r)r�z!ExpatBuilder.element_decl_handler�sG�����"�"�4�(���<�$/��e�$<�D�O�O�D�!��;�;�&�&�&��D�Kr+c
��|jj|�}|�t|�}||j|<|jj	d|dd|d||g�y�Nr)r�rr r"r�)r'�elemrbrD�default�requiredr9s       r)r�z!ExpatBuilder.attlist_decl_handler�sZ�����"�"�4�(���<��t�$�D�$(�D�O�O�D�!������
�4��t�W�a��x�@�	Br+c��||j_||j_|dk\r&|rd|j_yd|j_yy)NrTF)r��version�encoding�
standalone)r'rrrs    r)r�zExpatBuilder.xml_decl_handler�sA�� '��
�
��!)��
�
����?��+/��
�
�(�+0��
�
�(�	r+r&) rPrQrR�__doc__r*rxrrtr~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�r�r	r�r�r�rTr+r)rkrk�s�����$�	��>�.�&�:�O�**�+�*�(	*�8�$9�+�%�%��5�-�"�.*�
	!�$�" �B�1r+rkc�:�eZdZdZdZd�Zd�Zd�Zeje
jeje
jeje
jej e
j"ej$e
j&ej(e
j*ej,e
j.ej0e
j2ej4e
j6ej8e
j:ej<e
j>ej@e
jBiZ"y)rpzoWrapper around a DOMBuilderFilter which implements the checks
    to make the whatToShow filter attribute work.�roc��||_yr&r)r'ros  r)r*z#FilterVisibilityController.__init__�s	����r+c��|j|j}|jj|zrK|jj	|�}|t
k(rt�|tvrtdt|�z��|StS)Nz)startContainer() returned illegal value: )�_nodetype_maskr�ro�
whatToShowr��FILTER_INTERRUPTr��_ALLOWED_FILTER_RETURNSra�reprr�)r'r��mask�vals    r)r�z)FilterVisibilityController.startContainer�sz���"�"�4�=�=�1���;�;�!�!�D�(��+�+�,�,�T�2�C��&�&�!�!��1�1� �A�D��I�M�O�O��J� � r+c��|j|j}|jj|zr�|jj	|�}|t
k(rt�|tk(r7|j}|jddD]}|j|��tS|tvrtdt|�z��|StS)Nz%acceptNode() returned illegal value: )rr�rorr�rr�rrr��appendChildr�r rar!r�)r'r�r"r#�parentr�s      r)r�z%FilterVisibilityController.acceptNode�s����"�"�4�=�=�1���;�;�!�!�D�(��+�+�(�(��.�C��&�&�!�!��k�!�����!�_�_�Q�/�.�E��&�&�u�-�.�%�$��1�1� �=��S�	�I�K�K��J� � r+N)#rPrQrRrrSr*r�r�r�ELEMENT_NODEr�SHOW_ELEMENT�ATTRIBUTE_NODE�SHOW_ATTRIBUTEr��	SHOW_TEXTr��SHOW_CDATA_SECTION�ENTITY_REFERENCE_NODE�SHOW_ENTITY_REFERENCE�ENTITY_NODE�SHOW_ENTITY�PROCESSING_INSTRUCTION_NODE�SHOW_PROCESSING_INSTRUCTION�COMMENT_NODE�SHOW_COMMENT�
DOCUMENT_NODE�
SHOW_DOCUMENT�DOCUMENT_TYPE_NODE�SHOW_DOCUMENT_TYPE�DOCUMENT_FRAGMENT_NODE�SHOW_DOCUMENT_FRAGMENT�
NOTATION_NODE�
SHOW_NOTATIONrrTr+r)rprp�s���5��I��!�!�*	
���*�*A�*A����*�*C�*C����*�*>�*>����*�*G�*G��"�"�*�*J�*J����*�*@�*@��(�(�*�*P�*P����*�*A�*A����*�*B�*B����*�*G�*G��#�#�*�*K�*K����*�*B�*B�

�Nr+rpc��eZdZdZd�Zy)�FilterCrutch)�_builder�_level�
_old_start�_old_endc��d|_||_|j}|j|_|j
|_|j|_|j|_yr)	r@r?rsr�rAr�rBr�r�)r'rWr�s   r)r*zFilterCrutch.__init__sO�������
����� �4�4����0�0��
�%)�%?�%?��"�#'�#;�#;�� r+N)rPrQrRrSr*rTr+r)r>r>�s��>�I�<r+r>c�"�eZdZdZd�Zd�Zd�Zy)rrTc�p�tj||�|j}dD]}t||d��y)N)r�r�r�r�r�r�)r>r*rs�setattr)r'rWr�rbs    r)r*zRejecter.__init__s:�����d�G�,������	(�D�
�F�D�$�'�	(r+c�,�|jdz|_yr�)r@�r'�argss  r)r�zRejecter.start_element_handlers���k�k�A�o��r+c���|jdk(rT|jj}|jj|�|j|_|j|_y|jdz
|_y�Nrr3)r@r?rsr~rAr�rBr�)r'rIr�s   r)r�zRejecter.end_element_handlersV���;�;�!���]�]�*�*�F��M�M�!�!�&�)�)-���F�&�'+�}�}�F�$��+�+��/�D�Kr+N)rPrQrRrSr*r�r�rTr+r)rrs���I�
(�&�*r+rc��eZdZdZd�Zd�Zy)rrTc��|jj}|j|�|jj|ur|jdz|_yyr�)r?r�rAr@)r'rIr�s   r)r�zSkipper.start_element_handler*sE���}�}�$�$���������=�=� � ��,��+�+��/�D�K�-r+c��|jdk(rR|j|jj_|j
|jj_d|_y|jdz
|_|j
|�yrK)r@rAr?rsr�rBr�rHs  r)r�zSkipper.end_element_handler0s`���;�;�!��9=���D�M�M�!�!�5�6:�m�m�D�M�M�!�!�3� �D�M��+�+��/�D�K��D�M�M�4� r+N)rPrQrRrSr�r�rTr+r)rr's���I�*�	!r+rz8http://xml.python.org/entities/fragment-builder/internalz�<!DOCTYPE wrapper
  %%s [
  <!ENTITY fragment-builder-internal
    SYSTEM "%s">
%%s
]>
<wrapper %%s
>&fragment-builder-internal;</wrapper>c�<�eZdZdZd
d�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
y)�FragmentBuilderz�Builder which constructs document fragments given XML source
    text and a context node.

    The context node is expected to provide information about the
    namespace declarations which are in scope at the start of the
    fragment.
    Nc��|jtk(r||_||_n|j|_||_t
j
||�yr&)r�r5�originalDocumentr�r�rkr*)r'r�rus   r)r*zFragmentBuilder.__init__XsD�����}�,�$+�D�!�"�D�L�$+�$9�$9�D�!�"�D�L����d�G�,r+c�<�tj|�d|_yr&)rkrt�fragmentr-s r)rtzFragmentBuilder.resetas�����4� ���
r+c�@�|j|j��S)zRParse a document fragment from a file object, returning the
        fragment node.)r�r��r'r�s  r)r�zFragmentBuilder.parseFilees������	�	��,�,r+c��||_|j�}|jj}d}|rd|jxs|j�}|jrd|j�d|j�d�}n|jrd|jz}nd}|j�}t|||fz}	|j|d�|j}|j�|S#|j��xYw)zMParse a document fragment from a string, returning the
        fragment node.�zPUBLIC "z" "�"zSYSTEM "%s"T)
�_sourcerrRr�r��_getDeclarationsr�r��_getNSattrs�_FRAGMENT_BUILDER_TEMPLATEr�rtrT)	r'r�r�r��identr��nsattrsr�rTs	         r)r�zFragmentBuilder.parseStringjs���������!���'�'�/�/������+�+�F�t�/D�/D�/F�F����#�,�,�g�.>�.>�@���!�!�%��(8�(8�8���F��"�"�$��-����0H�H��	��L�L��4�(��=�=���
�
�����
	��J�J�L��s�5C%�%C8c�:�|jjj}d}|�rut|jj
�D]s}|jj
|�}|r|dz}|�d|j��}|jr |�d|j�d|j�d�}�b|�d|j�d�}�ut|jj
�D]�}|jj
|�}|r|dz}|�d|j��}|jr |�d|j�d|j�d	�}n;|jr|�d|j�d	�}n|�d
|jj�d	�}|jr|�d|j��}|dz}��|S)
z�Re-create the internal subset from the DocumentType node.

        This is only needed if we don't already have the
        internalSubset as a string.
        rXz
  z<!NOTATION z	 PUBLIC "z"
             "z">z	 SYSTEM "z	<!ENTITY rYz "z
 NOTATION �>)r�r�r�r�r��length�item�nodeNamer�r�r�
firstChildr�r�)r'r�rXr��notationrs      r)r[z FragmentBuilder._getDeclarations�so���,�,�,�,�4�4������7�,�,�3�3�4�	
C��"�,�,�1�1�!�4����F�
�A�)*�H�,=�,=�>���$�$��h�/�/��1B�1B�D�A�./��0A�0A�B�A�	
C��7�+�+�2�2�3�
�� �)�)�.�.�q�1����F�
�A�'(�&�/�/�:���?�?��f�o�o�v���@�A��_�_�,-�v���?�A�%&��(9�(9�(>�(>�?�A��&�&�,-�v�/B�/B�C�A���G��
��r+c��y)NrXrTr-s r)r\zFragmentBuilder._getNSattrs�s��r+c���|tk(r�|j}|j}|jj	|�}|j
|_|jj
�|_|j|_	|j|jd�||_||_d|_	ytj|||||�S#||_||_d|_	wxYw)NTr�)�$_FRAGMENT_BUILDER_INTERNAL_SYSTEM_IDr�r�rs�ExternalEntityParserCreaterR�createDocumentFragmentrTr�rZrkr�)r'r�r�r�r��old_document�old_cur_noder�s        r)r�z+FragmentBuilder.external_entity_ref_handler�s����;�;� �=�=�L��<�<�L��\�\�<�<�W�E�F� �1�1�D�M� �M�M�@�@�B�D�M��=�=�D�L�
$����T�\�\�4�0�+��� ,��
�#�����;�;��g�t�X�x�9�
9�� ,��� ,��
�#���s�?C
�
C!r&)rPrQrRrr*rtr�r�r[r\r�rTr+r)rPrPOs+���-��-�
�8"�H�9r+rPc�6�eZdZdZd�Zd�Zd�Zd�Zd�Z	d�Z	y)	�
Namespacesz7Mix-in class for builders; adds support for namespaces.c��g|_yr&)�_ns_ordered_prefixesr-s r)�_initNamespaceszNamespaces._initNamespaces�s��%'��!r+c�@�tjd��}d|_|S)z'Create a new namespace-handling parser.r[)�namespace_separatorT)r	rw�namespace_prefixesr�s  r)rxzNamespaces.createParser�s���#�#��<��$(��!��
r+c��tj||�|jjr|j|_yy)z.Insert the namespace-handlers onto the parser.N)rkr~rn�namespace_declarations�start_namespace_decl_handler�StartNamespaceDeclHandlerr�s  r)r~zNamespaces.install�s5�����T�6�*��=�=�/�/��1�1�
�,�0r+c�>�|jj||f�y)z/Push this namespace declaration on our storage.N)rqr�)r'rgres   r)rxz'Namespaces.start_namespace_decl_handler�s���!�!�(�(�&�#��7r+c���d|vrt||�\}}}}nt}|}d}t}tj||||�}|j
|_t|j|�||_|jr�|jD]u\}}|r*tjt|d|z�t|d�}n tjdtdt�}||_
|j
|_t||��w|jdd�=|r�|j�|j }	|j"}
t%dt'|�d�D]�}||}||dz}
d|vr6t||�\}}}}tj||||�}||	|<||
||f<n0tj|t|t�}||	|<||
t|f<|j
|_|
|_
||_��yy)Nr[�xmlns:�xmlnsrr^r3)rirrr�Elementr�r�r
r�rqr�rYrr�r�_ensure_attributes�_attrs�_attrsNSr�r`�ownerElement)r'rbr�rerfrgrhr�r�r�r�r�r8r�s              r)r�z Namespaces.start_element_handler�s����$�;�,:�4��,F�)�C��F�E�!�C��E��I�!�F����u�c�6�9�=��!�]�]����d�l�l�D�)�����$�$�#�8�8�	
-��������W�T�8�f�3D�%E�%4�f�g�G�A� ���W�o�%,�l�<�A����"&�-�-���#�D�!�,�	
-��)�)�!�,���#�#�%��[�[�F��}�}�H��1�c�*�o�q�1�
&��"�1�
��"�1�Q�3����%�<�4B�4��4O�1�C��F�E����U�C��F�C�A�$%�F�5�M�12�H�c�9�-�.����U�O�%*�L�:�A�$%�F�5�M�9:�H�o�u�5�6�"&�-�-������!%���
&�	r+c�R�|j}d|vrEt||�\}}}}|j|k(r|j|k(r|j|k(s7Jd��|j
|k(sJd��|jtk(sJd��|j|_|j|�y)Nr[z$element stack messed up! (namespace)z&element stack messed up - bad nodeNamez*element stack messed up - bad namespaceURI)	r�rir=r>rgrdrrr�)r'rbr�rerfrgrhs       r)r�zNamespaces.end_element_handlers����l�l�G��d�{�0>�t�T�0J�-��Y����,�,��3�#�-�-��:�#�N�N�f�4�?�?�?�5�
�'�'�4�/�@�?�@�/��+�+��>�D�C�D�>�"�-�-�D�L��$�$�W�-r+N)
rPrQrRrrrrxr~rxr�r�rTr+r)roro�s)��A�'�
�3�8�-&�^�	.r+roc��eZdZdZd�Zy)�ExpatBuilderNSz*Document builder that supports namespaces.c�N�tj|�|j�yr&)rkrtrrr-s r)rtzExpatBuilderNS.reset&s�����4� ����r+N)rPrQrRrrtrTr+r)r�r�#s
��4�r+r�c��eZdZdZd�Zd�Zy)�FragmentBuilderNSz*Fragment builder that supports namespaces.c�N�tj|�|j�yr&)rPrtrrr-s r)rtzFragmentBuilderNS.reset.s�����d�#����r+c��d}|j}g}|rtt|d�rY|jj�D]<\}}||vr�|j	|�|rd|z}nd}|r|�d|�d|�d�}�4d|�d|�d�}�>|j
}|r�t|S)	zNReturn string of namespace attributes from this element and
        ancestors.rX�_ns_prefix_urir|r}z
    z='�'r[)r��hasattrr��itemsr�r)r'�attrsr�r
rgre�declnames       r)r\zFragmentBuilderNS._getNSattrs2s������,�,������w� 0�1�#*�#9�#9�#?�#?�#A�=�K�F�C���{� ��H�H�V�$��#+�f�#4��#*���5:�H�c� J���/7�� <��=��(�(�G�� �r+N)rPrQrRrrtr\rTr+r)r�r�+s��4��r+r�c��eZdZdZy)r�zEException raised to short-circuit parsing in InternalSubsetExtractor.N)rPrQrRrrTr+r)r�r�Ps��O�r+r�c�>�eZdZdZdZd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zy)
r�zBXML processor which can rip out the internal document type subset.Nc��|jS)z'Return the internal subset as a string.)r�r-s r)r�z!InternalSubsetExtractor.getSubsetYs���{�{�r+c�P�	tj||�y#t$rYywxYwr&)rkr�r�rVs  r)r�z!InternalSubsetExtractor.parseFile]s)��	��"�"�4��.���	��	����	%�%c�P�	tj||�y#t$rYywxYwr&)rkr�r�)r'r�s  r)r�z#InternalSubsetExtractor.parseStringcs)��	��$�$�T�6�2���	��	�r�c�H�|j|_|j|_yr&)r�r�r�r�r�s  r)r~zInternalSubsetExtractor.installis��)-�)H�)H��&�%)�%?�%?��"r+c��|rD|j�}g|_|jj|_|j|_yt
��r&)rr�r��DefaultHandlerr�r�r�)r'rbr�r�r�r�s      r)r�z2InternalSubsetExtractor.start_doctype_decl_handlerms@����^�^�%�F��D�K�$(�K�K�$6�$6�F�!�+/�+H�+H�F�(��-�r+c��dj|j�jdd�jdd�}||_t��)NrXz
�
�
)�joinr��replacer�)r'rXs  r)r�z0InternalSubsetExtractor.end_doctype_decl_handlerws=���G�G�D�K�K� �(�(���6�>�>�t�T�J������m�r+c��t��r&)r�)r'rbr�s   r)r�z-InternalSubsetExtractor.start_element_handler|s
���m�r+)rPrQrRrr�r�r�r�r~r�r�r�rTr+r)r�r�Ts.��L�
�F����@� ��
r+r�c���|rt�}n
t�}t|t�r(t	|d�5}|j|�}ddd�|S|j|�}|S#1swYSxYw)z{Parse a document, returning the resulting Document node.

    'file' may be either a file name or an open file object.
    �rbN)r�rk�
isinstance�str�openr�)r��
namespacesrW�fp�results     r)�parser��sq��
� �"���.���$���
�$��
�	+���&�&�r�*�F�	+��M��"�"�4�(���M�		+��M�s�A#�#A-c�R�|rt�}n
t�}|j|�S)zOParse a document from a string, returning the resulting
    Document node.
    )r�rkr�)r�r�rWs   r)r�r��s'��� �"���.�����v�&�&r+c���|rt|�}nt|�}t|t�r(t	|d�5}|j|�}ddd�|S|j|�}|S#1swYSxYw)z�Parse a fragment of a document, given the context from which it
    was originally extracted.  context should be the parent of the
    node(s) which are in the fragment.

    'file' may be either a file name or an open file object.
    r�N)r�rPr�r�r�r�)r�r�r�rWr�r�s      r)�
parseFragmentr��sv���#�G�,��!�'�*���$���
�$��
�	+���&�&�r�*�F�	+��M��"�"�4�(���M�		+��M�s�A%�%A/c�V�|rt|�}nt|�}|j|�S)z�Parse a fragment of a document from a string, given the context
    from which it was originally extracted.  context should be the
    parent of the node(s) which are in the fragment.
    )r�rPr�)r�r�r�rWs    r)�parseFragmentStringr��s,��
�#�G�,��!�'�*�����v�&�&r+c�F�|jrt|�St|�S)z,Create a builder based on an Options object.)r�r�rk)rus r)�makeBuilderr��s!������g�&�&��G�$�$r+)T)3r�xml.domrrrrrr�xml.parsersr	�xml.dom.minidomr
r�xml.dom.NodeFilterrr�r�r5�DOMBuilderFilterr�r�rr�getDOMImplementationr��TypeInfor6�objectr rYrirkr rpr>rrrir]rPror�r��	Exceptionr�r�r�r�r�r�r�rTr+r)�<module>r�s/���:.�-�B�B��>�)��N�N�	��,�,���"�"�
��+�+�9�9�
��+�+�9�9�
��)�)�5�5���.�.�?�?��3�w�3�3�5��!�� � ��w�/� �� � ��}�5� �� � ��x�0� �� � ��z�2� �� � ��t�,� �� � ��w�/� �� � ��x�0� �� � ��y�1� �� � ��z�2�
�
�1(�&�1(�f,�6�&y1�y1�|	)�-��E��7
��7
�t
<�6�
<�*�|�*�8!�l�!�2?�%�*�+�	+��r9�l�r9�j\.�\.�~�Z���"�
�O�"�J	�)�	�)�l�)�X�$'��(	'�%r+

Zerion Mini Shell 1.0