Your IP : 3.133.153.224


Current Path : /opt/alt/python312/lib64/python3.12/xml/sax/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/xml/sax/__pycache__/expatreader.cpython-312.opt-2.pyc

�

�Q�f�>���	dZddl�ddlmZmZddlmZddlmZmZddlmZddlm	Z	m
Z
	ddlmZe
ed	�s	ed
d��ddlmZmZmZej(Zej*Z	ddlZddlZej0Z[[Gd�d�ZGd�dej6�ZGd�dej:ej6�Zd�Ze dk(ryddl!Z"e�Z#e#jIe"jJj$jM��e#jOe"jJjQ��e#jSd�yy#e$r
ed
d��wxYw#e$rd
�ZY��wxYw)z0.20�)�*)�feature_validation�feature_namespaces)�feature_namespace_prefixes)�feature_external_ges�feature_external_pes)�feature_string_interning)�property_xml_string�property_interning_dict)�expat�ParserCreatezexpat not supportedN)�	xmlreader�saxutils�handlerc��|S�N�)�os �:/opt/alt/python312/lib64/python3.12/xml/sax/expatreader.py�_mkproxyr!s����c��eZdZy)�
_ClosedParserN)�__name__�
__module__�__qualname__rrrrr(s��rrc�,�eZdZ	d�Zd�Zd�Zd�Zd�Zy)�ExpatLocatorc�$�t|�|_yr)r�_ref��self�parsers  r�__init__zExpatLocator.__init__3s���V�$��	rc�`�|j}|j�y|jjSr)r �_parser�ErrorColumnNumberr!s  r�getColumnNumberzExpatLocator.getColumnNumber6s(�������>�>�!���~�~�/�/�/rc�`�|j}|j�y|jjS�N�)r r&�ErrorLineNumberr!s  r�
getLineNumberzExpatLocator.getLineNumber<s(�������>�>�!���~�~�-�-�-rc�T�|j}|�y|jj�Sr)r �_source�getPublicIdr!s  rr0zExpatLocator.getPublicIdB�&�������>���~�~�)�)�+�+rc�T�|j}|�y|jj�Sr)r r/�getSystemIdr!s  rr3zExpatLocator.getSystemIdHr1rN)rrrr$r(r-r0r3rrrrr-s ���
%�0�.�,�,rrc���eZdZ	d"d�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d#d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"y!)$�ExpatParserc���tjj||�tj�|_d|_||_d|_d|_g|_	d|_
d|_y)NFr)r�IncrementalParserr$�InputSourcer/r&�_namespaces�_lex_handler_prop�_parsing�
_entity_stack�
_external_ges�
_interning)r"�namespaceHandling�bufsizes   rr$zExpatParser.__init__Ts]���#�#�,�,�T�7�;� �,�,�.������,���!%�����
���������rc��	tj|�}||_	|j�|jjt
|��tjj||�y#|j��xYwr)r�prepare_input_sourcer/�reset�
_cont_handler�setDocumentLocatorrrr7�parse�
_close_source�r"�sources  rrFzExpatParser.parseasq��=��.�.�v�6�����		��J�J�L����1�1�,�t�2D�E��'�'�-�-�d�F�;��	�
��� ��s�AA4�4Bc�x�|j��*|jj|j��yyr)r3r&�SetBaserHs  r�
prepareParserzExpatParser.prepareParserqs1������+��L�L� � ��!3�!3�!5�6�,rc�~�tjj||�|jr|j	�yyr)rr7�setContentHandlerr;�_reset_cont_handler)r"rs  rrNzExpatParser.setContentHandlerws0���#�#�5�5�d�G�D��=�=��$�$�&�rc���|tk(r|jS|tk(r|jduS|tt
tfvry|tk(r|jStd|z��)Nr�Feature '%s' not recognized)
rr9r	r>rrrrr=�SAXNotRecognizedException�r"�names  r�
getFeaturezExpatParser.getFeature|sn���%�%��#�#�#�
�-�
-��?�?�$�.�.�
�(�*>�0�2�2��
�)�
)��%�%�%�'�(E��(L�M�Mrc�j�|jrtd��|tk(r||_y|tk(r||_y|tk(r|r|j�i|_yd|_yy|tk(r|rtd��y|tk(r|rtd��y|tk(r|rtd��ytd|z��)Nz!Cannot set features while parsingz!expat does not support validationz/expat does not read external parameter entitiesz(expat does not report namespace prefixesrQ)r;�SAXNotSupportedExceptionrr9rr=r	r>rrrrR)r"rT�states   r�
setFeaturezExpatParser.setFeature�s����=�=�*�+N�O�O��%�%�$�D��
�)�
)�!&�D��
�-�
-���?�?�*�&(�D�O�"&���+��'�
'��.�7�9�9���)�
)��.�E�G�G���/�
/��.�>�@�@��,�-��4�6�
6rc�<�|tjk(r|jS|tk(r|jS|t
k(rR|jr;t|jd�r|jj�Std��td��td|z��)N�GetInputContextz=This version of expat does not support getting the XML stringz.XML string cannot be returned when not parsing�Property '%s' not recognized)r�property_lexical_handlerr:rr>r
r&�hasattrr[rRrWrSs  r�getPropertyzExpatParser.getProperty�s����7�3�3�3��)�)�)�
�,�
,��?�?�"�
�(�
(��|�|��4�<�<�):�;��<�<�7�7�9�9�3�*�+�+�/�D�F�F�'�(F��(M�N�Nrc���|tjk(r%||_|jr|j	�yy|t
k(r||_y|tk(rtd|z��td|z��)NzProperty '%s' cannot be setr\)
rr]r:r;�_reset_lex_handler_proprr>r
rWrR)r"rT�values   r�setPropertyzExpatParser.setProperty�s{���7�3�3�3�%*�D�"��}�}��,�,�.��
�,�
,�#�D�O�
�(�
(�*�+H�+/�,0�1�
1�,�,J�,0�-1�2�
2rc��|js1|j�d|_|jj�	|jj||�y#tj$rO}tt
j|j�||�}|jj|�Yd}~yd}~wwxYw)NT)
r;rCrD�
startDocumentr&�Parser�error�SAXParseException�ErrorString�code�_err_handler�
fatalError)r"�data�isFinal�e�excs     r�feedzExpatParser.feed�s����}�}��J�J�L� �D�M����,�,�.�		.�

�L�L���t�W�-���{�{�	.�#�E�$5�$5�a�f�f�$=�q�$�G�C����(�(��-�-��	.�s�A�B>�/AB9�9B>c��|j�y|jj�}	|jjd�|jjdd�|jj|�y#tj
$rO}t
t	j|j�||�}|jj|�Yd}~�yd}~wwxYw#|jj|�wxYw)NFr)r&�GetReparseDeferralEnabled�SetReparseDeferralEnabledrfrrgrhrirjrkrl)r"�was_enabledrorps    r�flushzExpatParser.flush�s����<�<����l�l�<�<�>��	@��L�L�2�2�5�9��L�L���s�E�*�

�L�L�2�2�;�?��	�{�{�	.�#�E�$5�$5�a�f�f�$=�q�$�G�C����(�(��-�-��	.��
�L�L�2�2�;�?�s*�7A<�<C�AC�C!�C�C!�!C>c��|j}	|j�}|�|j�|j�}|�|j�yy#|j�}|�|j�wwxYwr)r/�getCharacterStream�close�
getByteStream)r"rI�files   rrGzExpatParser._close_source�su������	��,�,�.�D����
�
���'�'�)�D����
�
�� ���'�'�)�D����
�
�� �s�"A�%A9c��|js&|j�t|jt�ry	|j	dd��|j
j
�d|_d|_d|_|j�Gt�}|jj|_|jj|_	||_|j�y#d|_|j�Gt�}|jj|_|jj|_	||_|j�wxYw)NrT)rnF)r<r&�
isinstancerrqrD�endDocumentr;r'r,rGr!s  rryzExpatParser.close�s������$�,�,�"6��t�|�|�]�3��	!��I�I�c�4�I�(����*�*�,�!�D�M��D�L�!�D�M��|�|�'�&���+/�<�<�+I�+I��(�)-���)E�)E��&�%������ ��"�D�M��|�|�'�&���+/�<�<�+I�+I��(�)-���)E�)E��&�%������ �s�;C�A,Ec��|jj|j_|jj|j_yr)rD�processingInstructionr&�ProcessingInstructionHandler�
characters�CharacterDataHandler�r"s rrOzExpatParser._reset_cont_handlers5��$(�$6�$6�$L�$L�	
���1�,0�,>�,>�,I�,I����)rc�*�|j}|j}|�$d|_d|_d|_d|_d|_y|j|_|j|_|j|_|j|_|j|_yr)r:r&�CommentHandler�StartCdataSectionHandler�EndCdataSectionHandler�StartDoctypeDeclHandler�EndDoctypeDeclHandler�comment�
startCDATA�endCDATA�start_doctype_decl�endDTD)r"�lexr#s   rraz#ExpatParser._reset_lex_handler_props����$�$�������;�$(�F�!�.2�F�+�,0�F�)�-1�F�*�+/�F�(�$'�K�K�F�!�.1�n�n�F�+�,/�L�L�F�)�-1�-D�-D�F�*�+.�:�:�F�(rc�J�|jr�tj|jj	�d|j
��|_d|j_|j|j_	|j|j_nttj|jj	�|j
��|_|j|j_	|j|j_|j�|j|j_|j"|j_|j&|j_|j*|j_d|_|j0r|j3�|j4|j_	|j8|j_|jj?tj@�d|_!g|_"y#t<$rY�CwxYw)N� )�internr+F)#r9rr
r/�getEncodingr>r&�namespace_prefixes�start_element_ns�StartElementHandler�end_element_ns�EndElementHandler�
start_element�end_elementrO�unparsed_entity_decl�UnparsedEntityDeclHandler�
notation_decl�NotationDeclHandler�start_namespace_decl�StartNamespaceDeclHandler�end_namespace_decl�EndNamespaceDeclHandler�_decl_handler_propr:ra�external_entity_ref�ExternalEntityRefHandler�skipped_entity_handler�SkippedEntityHandler�AttributeError�SetParamEntityParsing�*XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONEr;r<r�s rrCzExpatParser.resets������ �-�-�d�l�l�.F�.F�.H�#�59�_�_�F�D�L�./�D�L�L�+�/3�/D�/D�D�L�L�,�-1�-@�-@�D�L�L�*� �-�-�d�l�l�.F�.F�.H�7;���H�D�L�/3�/A�/A�D�L�L�,�-1�-=�-=�D�L�L�*�� � �"�15�1J�1J����.�+/�+=�+=����(�15�1J�1J����.�/3�/F�/F����,�"&����!�!��(�(�*�15�0H�0H����-�	�04�0K�0K�D�L�L�-�	
���*�*��<�<�	>���
������	��	�s�H�	H"�!H"c�H�|j�y|jjSr)r&r'r�s rr(zExpatParser.getColumnNumberCs���<�<����|�|�-�-�-rc�H�|j�y|jjSr*)r&r,r�s rr-zExpatParser.getLineNumberHs���<�<����|�|�+�+�+rc�6�|jj�Sr)r/r0r�s rr0zExpatParser.getPublicIdM����|�|�'�'�)�)rc�6�|jj�Sr)r/r3r�s rr3zExpatParser.getSystemIdPr�rc�N�|jj|t|��yr)rD�startElement�AttributesImpl)r"rT�attrss   rr�zExpatParser.start_elementTs�����'�'��n�U�.C�Drc�:�|jj|�yr)rD�
endElementrSs  rr�zExpatParser.end_elementW������%�%�d�+rc���|j�}t|�dk(rd|f}n$t|�dk(r|d|df}nt|�}i}i}|j�D]c\}}|j�}t|�}	|	dk(r|}
d|f}n-|	dk(r|d�d|d��}
|d|df}n|d}
t|�}|||<|
||<�e|jj|dt
||��y)Nr+�r��:)�split�len�tuple�itemsrD�startElementNS�AttributesNSImpl)r"rTr��pair�newattrs�qnames�anamerb�parts�length�qname�apairs            rr�zExpatParser.start_element_nsZs���z�z�|���t�9��>��$�<�D�
��Y�!�^���7�D��G�#�D���;�D�����#�k�k�m�N�U�E��K�K�M�E���Z�F���{����u�
���1��#(��8�U�1�X�6���a��%��(�*���a����e���#�H�U�O�!�F�5�M�!,�$	
���)�)�$��*:�8�V�*L�	Nrc���|j�}t|�dk(rd|f}n$t|�dk(r|d|df}nt|�}|jj	|d�y)Nr+r�r)r�r�r�rD�endElementNS)r"rTr�s   rr�zExpatParser.end_element_ns|s]���z�z�|���t�9��>��$�<�D�
��Y�!�^���7�D��G�#�D���;�D����'�'��d�3rc�<�|jj||�yr)rDr�)r"�targetrms   r�processing_instructionz"ExpatParser.processing_instruction�s�����0�0���>rc�:�|jj|�yr)rDr�)r"rms  r�character_datazExpatParser.character_data�r�rc�<�|jj||�yr)rD�startPrefixMapping)r"�prefix�uris   rr�z ExpatParser.start_namespace_decl�s�����-�-�f�c�:rc�:�|jj|�yr)rD�endPrefixMapping)r"r�s  rr�zExpatParser.end_namespace_decl�s�����+�+�F�3rc�>�|jj|||�yr)r:�startDTD)r"rT�sysid�pubid�has_internal_subsets     rr�zExpatParser.start_doctype_decl�s�����'�'��e�U�;rc�@�|jj||||�yr)�_dtd_handler�unparsedEntityDecl)r"rT�baser�r��
notation_names      rr�z ExpatParser.unparsed_entity_decl�s�����,�,�T�5�%��Orc�>�|jj|||�yr)r��notationDecl)r"rTr�r�r�s     rr�zExpatParser.notation_decl�s�����&�&�t�U�E�:rc��|jsy|jj||�}tj||j
j
�xsd�}|jj|j|j
f�|jj|�|_	||_	tjj||�|jd\|_	|_|jd=y#YyxYw)Nr+�r���)r=�_ent_handler�
resolveEntityrrBr/r3r<�appendr&�ExternalEntityParserCreaterr7rF)r"�contextr�r�r�rIs      rr�zExpatParser.external_entity_ref�s����!�!���"�"�0�0���>���.�.�v�/3�|�|�/G�/G�/I�02�/1�3��	
���!�!�4�<�<����">�?��|�|�>�>�w�G������	��'�'�-�-�d�F�;�(,�'9�'9�"�'=�$���t�|����r�"���	��s�5 C?�?Dc�H�|rd|z}|jj|�y)N�%)rD�
skippedEntity)r"rT�is_pes   rr�z"ExpatParser.skipped_entity_handler�s"����t�8�D����(�(��.rN)ri�)F)#rrrr$rFrLrNrUrYr_rcrqrvrGryrOrarCr(r-r0r3r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr5r5Qs���.�	�� 7�'�

N�6�<O�$2� .�"@�	�!�*J�
6� # �N.�
,�
*�*�E�,� N�D	4�?�,�;�4�<�P�;��,/rr5c��t|i|��Sr)r5)�args�kwargss  r�
create_parserr��s����'��'�'r�__main__z:http://www.ibiblio.org/xml/examples/shakespeare/hamlet.xml)*�version�xml.sax._exceptions�xml.sax.handlerrrrrrr	r
r�xml.parsersrr^�SAXReaderNotAvailable�ImportError�xml.saxrrrr�r��_weakref�weakref�proxyrr�Locatorrr7r5r�r�xml.sax.saxutils�xml�prN�sax�XMLGenerator�setErrorHandler�ErrorHandlerrFrrr�<module>rsT���
��!�B�6�F�4�H�A�!��5�.�)�#�$9�4�@�@�0�0��)�)���-�-��
��
��}�}�H���	�	�
,�9�$�$�,�Hg/�)�-�-�y�/@�/@�g/�V(�
�z�����A�������(�(�5�5�7�8����c�g�g�*�*�,�-��G�G�H�I���a
�=�
� 5�t�
<�<�=������s�E�)E�E�E�E

?>