ok

Mini Shell

Direktori : /opt/alt/python311/lib64/python3.11/xml/dom/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/xml/dom/__pycache__/expatbuilder.cpython-311.opt-1.pyc

�

�f������dZddlmZmZmZddlmZmZmZddlm	Z	ddl
mZmZddl
mZejZejZejZejjZejjZejjZejjZej��Zejdd��ejdd	��ejdd
��ejdd��ejdd��ejdd
��ejdd��ejdd��ejdd��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-d4d/�Z.d4d0�Z/d4d1�Z0d4d2�Z1d3�Z2dS)5z�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�J�eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�ZdS)
�ElementInfo��
_attr_info�_model�tagNameNc�0�||_g|_||_dS�N)r$r"r#)�selfr$�models   �;/opt/alt/python311/lib64/python3.11/xml/dom/expatbuilder.py�__init__zElementInfo.__init__?s�������������c�*�|j|j|jfSr&r!�r's r)�__getstate__zElementInfo.__getstate__Ds������T�\�9�9r+c�0�|\|_|_|_dSr&r!)r'�states  r)�__setstate__zElementInfo.__setstate__Gs��5:�2�����d�l�l�lr+c��|jD]F}|d|kr8|d}|ddkrtdcSt|dcS�GtjS)N����r�(r)r"�
_typeinfo_mapr�_no_type)r'�aname�info�ts    r)�getAttributeTypezElementInfo.getAttributeTypeJsn���O�	3�	3�D��A�w�%�����H���Q�4�3�;�;�(��0�0�0�0�(��b��2�2�2�2� ���r+c��tjSr&)rr7)r'�namespaceURI�	localNames   r)�getAttributeTypeNSzElementInfo.getAttributeTypeNSTs����r+c�v�|jr1|jd}|tjjtjjfvSdS�NrF)r#r	r(�
XML_CTYPE_ANY�XML_CTYPE_MIXED)r'�types  r)�isElementContentzElementInfo.isElementContentWs?���;�	��;�q�>�D���� 9� %�� ;� =�=�
=��5r+c�T�|jr |jdtjjkSdSrA)r#r	r(�XML_CTYPE_EMPTYr-s r)�isEmptyzElementInfo.isEmpty_s'���;�	��;�q�>�U�[�%@�@�@��5r+c�N�|jD]}|d|kr|ddkcS�dS)Nr3r4rF)r")r'r8r9s   r)�isIdzElementInfo.isIdesA���O�	(�	(�D��A�w�%����B�x�4�'�'�'�'� ��ur+c�0�|�||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 <s�������1�I�����
:�:�:�;�;�;� � � � � � ����������(�(�(�(�(r+r c�.�|�||��Sr&)�_intern_setdefault)�builder�ss  r)�_internrYos���%�%�a��+�+�+r+c�d�|�d��}|j}t|��dkr2|\}}}|||��}|�d|��}|||��}|||��}n@t|��dkr|\}}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�O�E�
�
'�F�
�5�z�z�Q���!&���Y������'�'��!�6�6�9�9�-����u�e�$�$���F�9�i�0�0�	�	�	�U���q������Y���"�F�9�i�8�8�8��	�	��O�RV�V�W�W�W��6�#�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�ZdS) �ExpatBuilderzPDocument builder that uses Expat to build a ParsedXML.DOM document
    instance.Nc���|�tj��}||_|jj�t	|jj��|_nd|_t|_d|_|�	��dSr&)
r�Options�_options�filter�FilterVisibilityController�_filterr�_finish_start_element�_parser�reset)r'�optionss  r)r*zExpatBuilder.__init__�sf���?� �(�*�*�G���
��=��+�5�d�m�6J�K�K�D�L�L��D�L�*,�D�&�����
�
�����r+c�(�tj��S)zCreate a new parser object.)r	�ParserCreater-s r)�createParserzExpatBuilder.createParser�s���!�#�#�#r+c��|jsm|���|_|jjj|_d|j_d|j_d|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�si���|�	'��,�,�.�.�D�L�&*�l�&9�&D�D�#�'+�D�L�$�.2�D�L�+�04�D�L�-��L�L���&�&�&��|�r+c��t�tdd��|_|j|_|jj|_d|_dS)z6Free all data structures used during DOM construction.NF)�theDOMImplementation�createDocumentr�document�curNode�
_elem_info�_cdatar-s r)rtzExpatBuilder.reset�s@��,�;�;��T�4�)�)��
��}����-�2�������r+c��|j|_|j|_|j|_|j|_|jj	r|j
|_|j|_
|jjr|j|_|jjr%|j|_|j|_|j|_n|j|_|j|_|j|_|j|_|j|_ dS)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��&�%)�%?��"�#'�#;�� �.2�o��+��=�!�	@�'+�'?�F�$�%)�%?��"��=�!�	9�$(�$8�F�!��=�'�	F�.2�.N�F�+�,0�,J�F�)�*.�*K�F�'�'�*.�*E�F�'�*.�*J��'� $� 5���$(�$=��!�$(�$=��!�!�!r+c�p�|���}d}		|�d��}|sn<|�|d��|r!|jjr|�|��d}�T|�dd��n#t$rYnwxYw|j}|���d|_|S)zIParse a document from a file object, returning the document
        node.Tr3i@Fr+N)	r�read�Parser��documentElement�
_setup_subset�ParseEscapertrs)r'�filer��first_buffer�buffer�docs      r)�	parseFilezExpatBuilder.parseFile�s������!�!����	�
%����7�+�+��������V�U�+�+�+��/�D�M�$A�/��&�&�v�.�.�.�$��
%�
�L�L��d�#�#�#�#���	�	�	��D�	�����m���
�
��������
s�A+B�
B�Bc���|���}	|�|d��|�|��n#t$rYnwxYw|j}|���d|_|S)z<Parse a document from a string, returning the document node.TN)rr�r�r�r�rtrs)r'�stringr�r�s    r)�parseStringzExpatBuilder.parseString�s������!�!��	��L�L���&�&�&����v�&�&�&�&���	�	�	��D�	�����m���
�
��������
s�+A�
A�Ac��|jjrJt��}|�|��|���}||jj_dSdS)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�s\���=� �	:�/�1�1�I��!�!�&�)�)�)��(�(�*�*�F�39�D�M�!�0�0�0�		:�	:r+c���|jj�|||��}|j|_t	|j|��||j_|jrV|j�|��tkr3d|j_|jj	d=d}d|j
_d|j
_|rE|�g|j
_g|j_d|j
_d|j
_|j|j
_dSdS�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�W�-�-�-� '��
���<�	4�D�L�3�3�G�<�<�
�M�M�$(�D�M�!��
�(��,��G�-1�D�L�*�/3�D�L�,��	O��"�(*�� �%�)+��!�&�*.�D�L�'�8<�D�L�5�15�1N�D�L�.�.�.�
	O�	Or+c��|jjr|j|j_|j|j_|js|jst|_
dSdSdSr&)rnr�r�rsr�r�r�r�rqr�_finish_end_elementr-s r)r�z%ExpatBuilder.end_doctype_decl_handlers]���=�!�	?�*.�*>�D�L�'�48�O���1���	*�4�<�	*�')�D�$�$�$�	*�	*�	*�	*r+c��|j�||��}t|j|��|jr?|j�|��tkr|j�|��dSdSdSr&)r��createProcessingInstructionr
r�rqr�r��removeChild)r'�target�data�nodes    r)r�zExpatBuilder.pi_handlers{���}�8�8���F�F���d�l�D�)�)�)��<�	+�D�L�3�3�D�9�9�]�J�J��L�$�$�T�*�*�*�*�*�	+�	+�J�Jr+c��|jj}|jr\|jr3|djt
kr|d�|��dS|j�|��}d|_nY|r1|djtkr|d}|j
|z}||_
dStj��}||_
|j|_
t|j|��dS)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�C��2��)�)�$�/�/�/����=�3�3�D�9�9�D�#'�D� � �
�	/�J�r�N�3�y�@�@��b�>�D��I��$�E��D�I��F��<�>�>�D��D�I�!%��D���d�l�D�)�)�)�)�)r+c��|jj}|r/|djtkr|d}|j|z|_dStj��}|j|z|_|j|_t|j|��dSr�)
r�r�r�r�r�rr�r�r�r
)r'r�r�r�s    r)r�z#ExpatBuilder.character_data_handler&s|���\�,�
��	�*�R�.�1�Y�>�>��b�>�D��	�D�(�D�I��F��|�~�~���I��$��	�!�]����d�l�D�)�)�)�)�)r+c��|rdS|jjsdS|j�||||��}|�4|j�|��}	|j�|	��|jjjj�|��|j	r<|j	�
|��tkr|jjjjd=dSdSdSr�)rnrr��_create_entity�createTextNoder��appendr�r�rqr�r�)
r'�
entityName�is_parameter_entityr��baser�r��notationNamer��childs
          r)r�z ExpatBuilder.entity_decl_handler1s����	��F��}�%�	��F��}�+�+�J��,4�l�D�D�����M�0�0��7�7�E��O�"�"�5�)�)�)��
��&�+�2�2�4�8�8�8��<�	8�D�L�3�3�D�9�9�]�J�J��
�%�.�3�B�7�7�7�	8�	8�J�Jr+c��|j�|||��}|jjjj�|��|jr<|j�|��tkr|jjjjd=dSdSdSr�)	r��_create_notationr�r�r�r�rqr��
FILTER_ACCEPT)r'r�r�r�r�r�s      r)r�z"ExpatBuilder.notation_decl_handlerCs����}�-�-�l�H�h�O�O���
��'�,�3�3�D�9�9�9��<�	9�D�L�3�3�D�9�9�]�J�J��
�%�/�4�R�8�8�8�	9�	9�J�Jr+c���|j�|��}t|j|��|jr?|j�|��tkr|j�|��dSdSdSr&)r��
createCommentr
r�rqr�r�r�)r'r�r�s   r)r�zExpatBuilder.comment_handlerIsy���}�*�*�4�0�0���d�l�D�)�)�)��<�	+�D�L�3�3�D�9�9�]�J�J��L�$�$�T�*�*�*�*�*�	+�	+�J�Jr+c�"�d|_d|_dS)NTF�r�r�r-s r)r�z(ExpatBuilder.start_cdata_section_handlerOs�����$����r+c�"�d|_d|_dS)NFr�r-s r)r�z&ExpatBuilder.end_cdata_section_handlerSs�����$����r+c��dS�Nr3rT)r'�contextr�r�r�s     r)r�z(ExpatBuilder.external_entity_ref_handlerWs���qr+c��|j�|jst|_|j|���_|�||��dSr&)rqr�rr��start_element_handlerrr�)r'rb�
attributess   r)r�z"ExpatBuilder.first_element_handlerZsJ���<�����')�D�$�/3�/I������,��"�"�4��4�4�4�4�4r+c��|j�|��}t|j|��||_|rvt	dt|��d��D]W}t
j||tdt��}||dz}||_
|j|_t||���X||jj
ur|�|��dSdS)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�0���d�l�D�)�)�)�����	-��1�c�*�o�o�q�1�1�
-�
-���L��A���!%�|�5�5��"�1�Q�3������"&�-���#�D�!�,�,�,�,��t�}�4�4�4��&�&�t�,�,�,�,�,�5�4r+c�P�|jr�||jjurdS|j�|��}|tkrt|��n|tkrt|��ndS|j|_	|j�
|��|���dSdSr&)rqr�r��startContainerr��Rejecter�FILTER_SKIP�Skipper�
parentNoder�r��unlink)r'r��filts   r)rrz"ExpatBuilder._finish_start_elementqs����<�	��t�}�4�4�4����<�.�.�t�4�4�D��}�$�$���������$�$���
�
�
�
����?�D�L��O�'�'��-�-�-��K�K�M�M�M�M�M�#	�	r+c�V�|j}|j|_|�|��dSr&)r�rr�)r'rbr�s   r)r�z ExpatBuilder.end_element_handler�s-���,���)���� � ��)�)�)�)�)r+c�L�|j�|j��}|r|�||��|jrc||jjurdS|j�|��tkr2|j	�
|��|���dSdSdSr&)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�3���	9��)�)�'�4�8�8�8��<�	!��$�-�7�7�7����|�&�&�w�/�/�=�@�@���(�(��1�1�1���� � � � � �	!�	!�A�@r+c��|jjs|���sdSg}|jD]@}|jt
kr.|j���s|�|���A|D]}|�	|���dSr&)
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�7�	��(�(�*�*�	��F�

���_�	 �	 �E��~��*�*�5�:�3C�3C�3E�3E�*����������	$�	$�E����U�#�#�#�#�	$�	$r+c��|j�|��}|�t||��|j|<dS||_dSr&)r�rr r#)r'rbr(r9s    r)r�z!ExpatBuilder.element_decl_handler�sE����"�"�4�(�(���<�$/��e�$<�$<�D�O�D�!�!�!� �D�K�K�Kr+c
��|j�|��}|�t|��}||j|<|j�d|dd|d||g��dS�Nr)r�rr r"r�)r'�elemrbrD�default�requiredr9s       r)r�z!ExpatBuilder.attlist_decl_handler�sr����"�"�4�(�(���<��t�$�$�D�$(�D�O�D�!�����
�4��t�W�a��x�@�	B�	B�	B�	B�	Br+c�~�||j_||j_|dkr|rd|j_dSd|j_dSdS)NrTF)r��version�encoding�
standalone)r'rrrs    r)r�zExpatBuilder.xml_decl_handler�sN�� '��
��!)��
����?�?��
1�+/��
�(�(�(�+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�O�O�**�*�*�+�+�+�*�*�*�(	*�	*�	*�8�8�8�$9�9�9�+�+�+�%�%�%�%�%�%����5�5�5�-�-�-�"���.*�*�*�
	!�	!�	!�$�$�$�" � � �B�B�B�1�1�1�1�1r+rkc�L�eZdZdZdZd�Zd�Zd�Zej	e
jeje
j
eje
jeje
jeje
jeje
jeje
jeje
jeje
jeje
jeje
jej e
j!iZ"dS)rpzoWrapper around a DOMBuilderFilter which implements the checks
    to make the whatToShow filter attribute work.�roc��||_dSr&r)r'ros  r)r*z#FilterVisibilityController.__init__�s
������r+c��|j|j}|jj|zrV|j�|��}|t
krt�|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�s����"�4�=�1���;�!�D�(�		!��+�,�,�T�2�2�C��&�&�&�!�!��1�1�1� �A�D��I�I�M�O�O�O��J� � r+c�~�|j|j}|jj|zr�|j�|��}|t
krt�|tkr5|j}|j	dd�D]}|�
|���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�Q�Q�/�.�.�E��&�&�u�-�-�-�-�$�$��1�1�1� �=��S�	�	�I�K�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�5��I����!�!�!�!�!�!�*	
��*�*A���*�*C���*�*>���*�*G��"�*�*J���*�*@��(�*�*P���*�*A���*�*B���*�*G��#�*�*K���*�*B�

�N�N�Nr+rpc��eZdZdZd�ZdS)�FilterCrutch)�_builder�_level�
_old_start�_old_endc��d|_||_|j}|j|_|j|_|j|_|j|_dSr)	r@r?rsr�rAr�rBr�r�)r'rWr�s   r)r*zFilterCrutch.__init__sG�������
���� �4����0��
�%)�%?��"�#'�#;�� � � r+N)rPrQrRrSr*rTr+r)r>r>s(������>�I�<�<�<�<�<r+r>c�$�eZdZdZd�Zd�Zd�ZdS)rrTc�v�t�||��|j}dD]}t||d���dS)N)r�r�r�r�r�r�)r>r*rs�setattr)r'rWr�rbs    r)r*zRejecter.__init__sQ�����d�G�,�,�,�����	(�	(�D�
�F�D�$�'�'�'�'�	(�	(r+c�$�|jdz|_dSr�)r@�r'�argss  r)r�zRejecter.start_element_handlers���k�A�o����r+c��|jdkr@|jj}|j�|��|j|_|j|_dS|jdz
|_dS�Nrr3)r@r?rsr~rAr�rBr�)r'rIr�s   r)r�zRejecter.end_element_handler sZ���;�!����]�*�F��M�!�!�&�)�)�)�)-��F�&�'+�}�F�$�$�$��+��/�D�K�K�Kr+N)rPrQrRrSr*r�r�rTr+r)rrsF�������I�
(�
(�
(�&�&�&�*�*�*�*�*r+rc��eZdZdZd�Zd�ZdS)rrTc�p�|jj}|j|�|jj|ur|jdz|_dSdSr�)r?r�rAr@)r'rIr�s   r)r�zSkipper.start_element_handler-sD���}�$���������=� ��,�,��+��/�D�K�K�K�-�,r+c��|jdkr5|j|jj_|j|jj_d|_dS|jdz
|_|j|�dSrK)r@rAr?rsr�rBr�rHs  r)r�zSkipper.end_element_handler3s\���;�!���9=��D�M�!�5�6:�m�D�M�!�3� �D�M�M�M��+��/�D�K��D�M�4� � � � r+N)rPrQrRrSr�r�rTr+r)rr*s7�������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
dS)�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��|jtkr||_||_n|j|_||_t
�||��dSr&)r�r5�originalDocumentr�r�rkr*)r'r�rus   r)r*zFragmentBuilder.__init__[sO����}�,�,�$+�D�!�"�D�L�L�$+�$9�D�!�"�D�L����d�G�,�,�,�,�,r+c�H�t�|��d|_dSr&)rkrt�fragmentr-s r)rtzFragmentBuilder.resetds!�����4� � � ���
�
�
r+c�P�|�|�����S)zRParse a document fragment from a file object, returning the
        fragment node.)r�r��r'r�s  r)r�zFragmentBuilder.parseFilehs ������	�	���,�,�,r+c���||_|���}|jj}d}|rH|jp|���}|jrd|j�d|j�d�}n|jr
d|jz}nd}|���}t|||fz}	|�
|d��n#|����xYw|j}|���|S)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.parseStringms
��������!�!���'�/�����	��+�F�t�/D�/D�/F�/F�F���
9�
9�#�,�,�,�g�.>�.>�.>�@����!�
9�%��(8�8����F��"�"�$�$��-����0H�H��	��L�L��4�(�(�(�(��	��J�J�L�L�L������=���
�
�����s�B/�/Cc�b�|jjj}d}|�rt|jj��D]Y}|j�|��}|r|dz}|�d|j��}|jr|�d|j�d|j	�d�}�L|�d|j	�d�}�Zt|j
j��D]�}|j
�|��}|r|dz}|�d|j��}|jr|�d|j�d|j	�d	�}n'|j	r|�d|j	�d	�}n|�d
|jj�d	�}|j
r|�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�s����,�,�4�����	��7�,�3�4�4�	
C�	
C��"�,�1�1�!�4�4���#��F�
�A�)*���H�,=�,=�>���$�C��1�1�h�/�/�/��1B�1B�1B�D�A�A�./�Q�Q��0A�0A�0A�B�A�A��7�+�2�3�3�
�
�� �)�.�.�q�1�1���#��F�
�A�'(�q�q�&�/�/�:���?�@��1�1�f�o�o�o�v����@�A�A��_�@�,-�A�A�v����?�A�A�%&�Q�Q��(9�(>�(>�(>�?�A��&�D�,-�A�A�v�/B�/B�C�A���G����r+c��dS)NrXrTr-s r)r\zFragmentBuilder._getNSattrs�s���rr+c��|tkr�|j}|j}|j�|��}|j|_|j���|_|j|_	|�|j	d��||_||_d|_	n#||_||_d|_	wxYwdSt�|||||��S)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�E�F� �1�D�M� �M�@�@�B�B�D�M��=�D�L�
$����T�\�4�0�0�0�+��� ,��
�#����� ,��� ,��
�#���#�#�#�#��2��;�;��g�t�X�x�9�9�
9s�+B�B3r&)rPrQrRrr*rtr�r�r[r\r�rTr+r)rPrPRs���������-�-�-�-����-�-�-�
���8"�"�"�H���9�9�9�9�9r+rPc�0�eZdZdZd�Zd�Zd�Zd�Zd�Zd	S)
�
Namespacesz7Mix-in class for builders; adds support for namespaces.c��g|_dSr&)�_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�p�t�||��|jjr|j|_dSdS)z.Insert the namespace-handlers onto the parser.N)rkr~rn�namespace_declarations�start_namespace_decl_handler�StartNamespaceDeclHandlerr�s  r)r~zNamespaces.install�sC�����T�6�*�*�*��=�/�	3��1�
�,�,�,�	3�	3r+c�>�|j�||f��dS)z/Push this namespace declaration on our storage.N)rqr�)r'rgres   r)rxz'Namespaces.start_namespace_decl_handler�s#���!�(�(�&�#��7�7�7�7�7r+c���d|vrt||��\}}}}nt}|}d}t}tj||||��}|j|_t|j|��||_|j	r�|j	D]y\}}|r.tj
t|d|z��t|d��}n!tj
dtdt��}||_
|j|_t||���z|j	dd�=|r�|���|j}	|j}
t%dt'|��d��D]�}||}||dz}
d|vr9t||��\}}}}tj
||||��}||	|<||
||f<n2tj
|t|t��}||	|<||
t|f<|j|_|
|_
||_��dSdS)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�,F�)�C��F�E�E�!�C��E��I�!�F���u�c�6�9�=�=��!�]����d�l�D�)�)�)�����$�	-�#�8�	
-�	
-�����<���W�T�8�f�3D�%E�%E�%4�f�g�G�G�A�A� ��W�o�%,�l�<�<�A����"&�-���#�D�!�,�,�,�,��)�!�!�!�,��	&��#�#�%�%�%��[�F��}�H��1�c�*�o�o�q�1�1�
&�
&��"�1�
��"�1�Q�3����%�<�<�4B�4��4O�4O�1�C��F�E���U�C��F�C�C�A�$%�F�5�M�12�H�c�9�-�.�.���U�O�%*�L�:�:�A�$%�F�5�M�9:�H�o�u�5�6�"&�-������!%����'	&�	&�
&�
&r+Fc��|j}d|vrt||��\}}}}|j|_|�|��dS)Nr[)r�rirr�)r'rbr�rerfrgrhs       r)r�zNamespaces.end_element_handlersP���l�G��d�{�{�0>�t�T�0J�0J�-��Y���#�-�D�L��$�$�W�-�-�-�-�-r+N)
rPrQrRrrrrxr~rxr�r�rTr+r)roro�sf������A�A�'�'�'�
���3�3�3�8�8�8�-&�-&�-&�^.�.r+roc��eZdZdZd�ZdS)�ExpatBuilderNSz*Document builder that supports namespaces.c�b�t�|��|���dSr&)rkrtrrr-s r)rtzExpatBuilderNS.reset)s.�����4� � � ��������r+N)rPrQrRrrtrTr+r)r�r�&s)������4�4�����r+r�c��eZdZdZd�Zd�ZdS)�FragmentBuilderNSz*Fragment builder that supports namespaces.c�b�t�|��|���dSr&)rPrtrrr-s r)rtzFragmentBuilderNS.reset1s.�����d�#�#�#��������r+c��d}|j}g}|rst|d��rZ|j���D]@\}}||vr�
|�|��|rd|z}nd}|r|�d|�d|�d�}�7d|�d|�d�}�A|j}|�s|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._getNSattrs5s������,�����	)��w� 0�1�1�

=�#*�#9�#?�#?�#A�#A�=�=�K�F�C���{�{� ��H�H�V�$�$�$��+�#+�f�#4���#*���=�5:�U�U�H�H�H�c�c�c� J���=�/7�h�h���� <����(�G��	)� �r+N)rPrQrRrrtr\rTr+r)r�r�.s8������4�4��������r+r�c��eZdZdZdS)r�zEException raised to short-circuit parsing in InternalSubsetExtractor.N)rPrQrRrrTr+r)r�r�Ss������O�O��Dr+r�c�@�eZdZdZdZd�Zd�Zd�Zd�Zd�Z	d�Z
d	�ZdS)
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.getSubset\s
���{�r+c�`�	t�||��dS#t$rYdSwxYwr&)rkr�r�rVs  r)r�z!InternalSubsetExtractor.parseFile`sE��	��"�"�4��.�.�.�.�.���	�	�	��D�D�	������
-�-c�`�	t�||��dS#t$rYdSwxYwr&)rkr�r�)r'r�s  r)r�z#InternalSubsetExtractor.parseStringfsE��	��$�$�T�6�2�2�2�2�2���	�	�	��D�D�	���r�c�6�|j|_|j|_dSr&)r�r�r�r�r�s  r)r~zInternalSubsetExtractor.installls��)-�)H��&�%)�%?��"�"�"r+c��|r:|���}g|_|jj|_|j|_dSt
���r&)rr�r��DefaultHandlerr�r�r�)r'rbr�r�r�r�s      r)r�z2InternalSubsetExtractor.start_doctype_decl_handlerpsH���	 ��^�^�%�%�F��D�K�$(�K�$6�F�!�+/�+H�F�(�(�(��-�-�r+c��d�|j���dd���dd��}||_t���)NrXz
�
�
)�joinr��replacer�)r'rXs  r)r�z0InternalSubsetExtractor.end_doctype_decl_handlerzsF���G�G�D�K� � �(�(���6�6�>�>�t�T�J�J������m�m�r+c��t���r&)r�)r'rbr�s   r)r�z-InternalSubsetExtractor.start_element_handlers���m�m�r+)rPrQrRrr�r�r�r�r~r�r�r�rTr+r)r�r�Ws�������L�L�
�F����������@�@�@� � � ����
����r+r�Tc��|rt��}nt��}t|t��r>t	|d��5}|�|��}ddd��n#1swxYwYn|�|��}|S)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��s���
�!� �"�"����.�.���$����)�
�$��
�
�	+���&�&�r�*�*�F�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+���"�"�4�(�(���Ms�A'�'A+�.A+c�j�|rt��}nt��}|�|��S)zOParse a document from a string, returning the resulting
    Document node.
    )r�rkr�)r�r�rWs   r)r�r��s6���!� �"�"����.�.�����v�&�&�&r+c��|rt|��}nt|��}t|t��r>t	|d��5}|�|��}ddd��n#1swxYwYn|�|��}|S)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��s����+�#�G�,�,���!�'�*�*���$����)�
�$��
�
�	+���&�&�r�*�*�F�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+���"�"�4�(�(���Ms�A)�)A-�0A-c�n�|rt|��}nt|��}|�|��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�L�|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�sZ����:.�-�-�-�-�-�-�-�-�-�B�B�B�B�B�B�B�B�B�B�������>�>�>�>�>�>�>�>�)�)�)�)�)�)��N�	��,���"�
��+�9�
��+�9�
��)�5���.�?��3�w�3�5�5��!�� ��w�/�/� �� ��}�5�5� �� ��x�0�0� �� ��z�2�2� �� ��t�,�,� �� ��w�/�/� �� ��x�0�0� �� ��y�1�1� �� ��z�2�2�
�
�
�1(�1(�1(�1(�1(�&�1(�1(�1(�f,�,�,�6�6�6�&|1�|1�|1�|1�|1�|1�|1�|1�B
)�-��E��7
�7
�7
�7
�7
��7
�7
�7
�t
<�
<�
<�
<�
<�6�
<�
<�
<�*�*�*�*�*�|�*�*�*�8!�!�!�!�!�l�!�!�!�2?�%�*�+�	+��r9�r9�r9�r9�r9�l�r9�r9�r9�j\.�\.�\.�\.�\.�\.�\.�\.�~�����Z�����"�"�"�"�"�
�O�"�"�"�J	�	�	�	�	�)�	�	�	�)�)�)�)�)�l�)�)�)�X����$'�'�'�'�����(	'�	'�	'�	'�%�%�%�%�%r+

Zerion Mini Shell 1.0