Your IP : 3.138.114.198


Current Path : /opt/alt/python310/lib64/python3.10/xml/sax/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/xml/sax/__pycache__/expatreader.cpython-310.opt-2.pyc

o

6��fS?�@s�	dZddlTddlmZmZddlmZddlmZmZddlmZddlm	Z	m
Z
ddlZejdd	�d
kr=e
dd��[zddlmZWneyRe
d
d��weed�s]e
d
d��ddlmZmZmZejZejZzddlZWn
ey�dd�ZYn
wddlZejZ[[Gdd�d�ZGdd�dej�ZGdd�dejej�Z dd�Z!e"dkr�ddl#Z$e!�Z%e%�&e$j'j�(��e%�)e$j'�*��e%�+d�dSdS)z0.20�)�*)�feature_validation�feature_namespaces)�feature_namespace_prefixes)�feature_external_ges�feature_external_pes)�feature_string_interning)�property_xml_string�property_interning_dictN��javazexpat not available in Java)�expatzexpat not supported�ParserCreate)�	xmlreader�saxutils�handlercCs|S�N�)�orr�:/opt/alt/python310/lib64/python3.10/xml/sax/expatreader.py�_mkproxy'src@seZdZdS)�
_ClosedParserN)�__name__�
__module__�__qualname__rrrrr.src@s6eZdZ	dd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ExpatLocatorcCst|�|_dSr)r�_ref��self�parserrrr�__init__9�zExpatLocator.__init__cCs|j}|jdur
dS|jjSr)r�_parser�ErrorColumnNumberrrrr�getColumnNumber<�
zExpatLocator.getColumnNumbercCs|j}|jdur
dS|jjS�N�)rr"�ErrorLineNumberrrrr�
getLineNumberBr%zExpatLocator.getLineNumbercC�|j}|dur	dS|j��Sr)r�_source�getPublicIdrrrrr,H�
zExpatLocator.getPublicIdcCr*r)rr+�getSystemIdrrrrr.Nr-zExpatLocator.getSystemIdN)rrrr r$r)r,r.rrrrr3src@seZdZ	dEdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dFdd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Z d@dA�Z!dBdC�Z"dDS)G�ExpatParserr��cCsFtj�||�t��|_d|_||_d|_d|_g|_	d|_
d|_dS)NFr)r�IncrementalParserr ZInputSourcer+r"�_namespaces�_lex_handler_prop�_parsing�
_entity_stack�
_external_ges�
_interning)rZnamespaceHandling�bufsizerrrr Zs

zExpatParser.__init__cCsP	t�|�}||_z|��|j�t|��tj�	||�WdS|�
��r)r�prepare_input_sourcer+�reset�
_cont_handlerZsetDocumentLocatorrrr1�parse�
_close_source�r�sourcerrrr<gs
zExpatParser.parsecCs$|��dur|j�|���dSdSr)r.r"ZSetBaser>rrr�
prepareParserws�zExpatParser.prepareParsercCs$tj�||�|jr|��dSdSr)rr1�setContentHandlerr4�_reset_cont_handler)rrrrrrA}s�zExpatParser.setContentHandlercCsL|tkr|jS|tkr|jduS|tttfvrdS|tkr |jSt	d|��)Nr�Feature '%s' not recognized)
rr2rr7rrrrr6�SAXNotRecognizedException�r�namerrr�
getFeature�s
�zExpatParser.getFeaturecCs�|jrtd��|tkr||_dS|tkr||_dS|tkr0|r+|jdur)i|_dSdSd|_dS|tkr<|r:td��dS|t	krH|rFtd��dS|t
krT|rRtd��dStd|��)Nz!Cannot set features while parsingz!expat does not support validationz/expat does not read external parameter entitiesz(expat does not report namespace prefixesrC)r4�SAXNotSupportedExceptionrr2rr6rr7rrrrD)rrF�staterrr�
setFeature�sB



�
�������zExpatParser.setFeaturecCs^|tjkr|jS|tkr|jS|tkr)|jr%t|jd�r!|j��St	d��t
d��t	d|��)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_handlerr3r
r7r	r"�hasattrrKrDrHrErrr�getProperty�s

��zExpatParser.getPropertycCsX|tjkr||_|jr|��dSdS|tkr||_dS|tkr&td|��t	d|��)NzProperty '%s' cannot be setrL)
rrMr3r4�_reset_lex_handler_propr
r7r	rHrD)rrF�valuerrr�setProperty�s
�
��zExpatParser.setPropertyFc
Cs||js|��d|_|j��z
|j�||�WdStjy=}ztt�	|j
�||�}|j�|�WYd}~dSd}~ww)NT)
r4r:r;Z
startDocumentr"�Parser
�error�SAXParseException�ErrorString�code�_err_handler�
fatalError)r�data�isFinal�e�excrrr�feed�s
��zExpatParser.feedc
Cs�|jdurdS|j��}zEz|j�d�|j�dd�Wn#tjy?}ztt�|j�||�}|j	�
|�WYd}~nd}~wwW|j�|�dSW|j�|�dS|j�|�w)NF�)r"ZGetReparseDeferralEnabledZSetReparseDeferralEnabledrSr
rTrUrVrWrXrY)rZwas_enabledr\r]rrr�flush�s

����zExpatParser.flushcCs^|j}z|��}|dur|��W|��}|dur|��dSdS|��}|dur.|��wwr)r+ZgetCharacterStream�closeZ
getByteStream)rr?�filerrrr=�s���
�zExpatParser._close_sourcecCs�|js|jdust|jt�rdSz1|jddd�|j��d|_d|_Wd|_|jdur<t�}|jj|_|jj	|_	||_|�
�dSd|_|jdurZt�}|jj|_|jj	|_	||_|�
�w)Nr_T)r[F)r5r"�
isinstancerr^r;ZendDocumentr4r#r(r=rrrrra�s.
�



�



zExpatParser.closecCs|jj|j_|jj|j_dSr)r;�processingInstructionr"ZProcessingInstructionHandler�
charactersZCharacterDataHandler�rrrrrB
s�zExpatParser._reset_cont_handlercCsb|j}|j}|durd|_d|_d|_d|_d|_dS|j|_|j|_|j	|_|j
|_|j|_dSr)r3r"ZCommentHandlerZStartCdataSectionHandlerZEndCdataSectionHandlerZStartDoctypeDeclHandlerZEndDoctypeDeclHandlerZcommentZ
startCDATAZendCDATA�start_doctype_declZendDTD)rZlexrrrrrPs
z#ExpatParser._reset_lex_handler_propcCs�|jrtj|j��d|jd�|_d|j_|j|j_	|j
|j_ntj|j��|jd�|_|j|j_	|j
|j_|��|j|j_|j|j_|j|j_|j|j_d|_|jrW|��|j|j_z|j|j_Wn	tylYnw|j�tj �d|_!g|_"dS)N� )�internr'F)#r2r
rr+ZgetEncodingr7r"Znamespace_prefixes�start_element_nsZStartElementHandler�end_element_nsZEndElementHandler�
start_element�end_elementrB�unparsed_entity_declZUnparsedEntityDeclHandler�
notation_declZNotationDeclHandler�start_namespace_declZStartNamespaceDeclHandler�end_namespace_declZEndNamespaceDeclHandlerZ_decl_handler_propr3rP�external_entity_refZExternalEntityRefHandler�skipped_entity_handlerZSkippedEntityHandler�AttributeErrorZSetParamEntityParsingZ*XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONEr4r5rfrrrr:"s>�
�






��
zExpatParser.resetcCs|jdurdS|jjSr)r"r#rfrrrr$I�
zExpatParser.getColumnNumbercCs|jdurdS|jjSr&)r"r(rfrrrr)NruzExpatParser.getLineNumbercC�
|j��Sr)r+r,rfrrrr,S�
zExpatParser.getPublicIdcCrvr)r+r.rfrrrr.VrwzExpatParser.getSystemIdcCs|j�|t|��dSr)r;ZstartElement�AttributesImpl)rrF�attrsrrrrlZ�zExpatParser.start_elementcC�|j�|�dSr)r;Z
endElementrErrrrm]�zExpatParser.end_elementcCs�|��}t|�dkrd|f}nt|�dkr|d|df}nt|�}i}i}|��D]>\}}|��}t|�}	|	dkrA|}
d|f}n|	dkrXd|d|df}
|d|df}n|d}
t|�}|||<|
||<q*|j�|dt||��dS)Nr'�rz%s:%s�)�split�len�tuple�itemsr;ZstartElementNS�AttributesNSImpl)rrFry�pairZnewattrsZqnamesZanamerQ�partsZlengthZqnameZapairrrrrj`s0



�zExpatParser.start_element_nscCsV|��}t|�dkrd|f}nt|�dkr|d|df}nt|�}|j�|d�dS)Nr'r}r)rr�r�r;ZendElementNS)rrFr�rrrrk�s
zExpatParser.end_element_nscC�|j�||�dSr)r;rd)r�targetrZrrr�processing_instruction��z"ExpatParser.processing_instructioncCr{r)r;re)rrZrrr�character_data�r|zExpatParser.character_datacCr�r)r;ZstartPrefixMapping)r�prefixZurirrrrp�r�z ExpatParser.start_namespace_declcCr{r)r;ZendPrefixMapping)rr�rrrrq�r|zExpatParser.end_namespace_declcCs|j�|||�dSr)r3ZstartDTD)rrF�sysid�pubidZhas_internal_subsetrrrrg��zExpatParser.start_doctype_declcCs|j�||||�dSr)�_dtd_handlerZunparsedEntityDecl)rrF�baser�r�Z
notation_namerrrrn�rzz ExpatParser.unparsed_entity_declcCs|j�|||�dSr)r�ZnotationDecl)rrFr�r�r�rrrro�r�zExpatParser.notation_declcCs�|jsdS|j�||�}t�||j��pd�}|j�|j	|jf�|j	�
|�|_	||_z	tj�
||�WnYdS|jd\|_	|_|jd=dS)Nr'�r���)r6Z_ent_handlerZ
resolveEntityrr9r+r.r5�appendr"ZExternalEntityParserCreaterr1r<)r�contextr�r�r�r?rrrrr�s"
�zExpatParser.external_entity_refcCs|rd|}|j�|�dS)N�%)r;Z
skippedEntity)rrFZis_perrrrs�sz"ExpatParser.skipped_entity_handlerN)rr0)F)#rrrr r<r@rArGrJrOrRr^r`r=rarBrPr:r$r)r,r.rlrmrjrkr�r�rprqrgrnrorrrsrrrrr/WsD


'"r/cOst|i|��Sr)r/)�args�kwargsrrr�
create_parser�r!r��__main__z:http://www.ibiblio.org/xml/examples/shakespeare/hamlet.xml),�versionZxml.sax._exceptionsZxml.sax.handlerrrrrrrr	r
�sys�platformZSAXReaderNotAvailableZxml.parsersr
�ImportErrorrNZxml.saxrrrrxr��_weakrefr�weakref�proxyrZLocatorrr1r/r�rZxml.sax.saxutilsZxml�prAZsaxZXMLGeneratorZsetErrorHandlerZErrorHandlerr<rrrr�<module>sV

�

�$m�

?>