AlkantarClanX12

Your IP : 3.144.96.108


Current Path : /lib64/python3.8/xml/sax/__pycache__/
Upload File :
Current File : //lib64/python3.8/xml/sax/__pycache__/expatreader.cpython-38.opt-2.pyc

U

e5dX=�@s�dZddlTddlmZmZddlmZddlmZmZddlmZddlm	Z	m
Z
ddlZejdd	�d
krxe
dd��[zddlmZWnek
r�e
d
d��YnXeed�s�e
d
d��ddlmZmZmZejZejZzddlZWnek
�rdd�ZYnXddlZejZ[[Gdd�d�ZGdd�dej�ZGdd�dejej�Z dd�Z!e"dk�r�ddl#Z$e!�Z%e%�&e$j'j�(��e%�)e$j'�*��e%�+d�dS)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�+/usr/lib64/python3.8/xml/sax/expatreader.py�_mkproxy'src@seZdZdS)�
_ClosedParserN)�__name__�
__module__�__qualname__rrrrr.src@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ExpatLocatorcCst|�|_dSr)r�_ref��self�parserrrr�__init__9szExpatLocator.__init__cCs|j}|jdkrdS|jjSr)r�_parser�ErrorColumnNumberrrrr�getColumnNumber<s
zExpatLocator.getColumnNumbercCs|j}|jdkrdS|jjS�N�)rr!�ErrorLineNumberrrrr�
getLineNumberBs
zExpatLocator.getLineNumbercCs|j}|dkrdS|j��Sr)r�_source�getPublicIdrrrrr)HszExpatLocator.getPublicIdcCs|j}|dkrdS|j��Sr)rr(�getSystemIdrrrrr*NszExpatLocator.getSystemIdN)rrrr r#r'r)r*rrrrr3s
rc@seZdZdBdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dCdd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Z d?d@�Z!dAS)D�ExpatParserr��cCsFtj�||�t��|_d|_||_d|_d|_g|_	d|_
d|_dS)Nr)r�IncrementalParserr ZInputSourcer(r!�_namespaces�_lex_handler_prop�_parsing�
_entity_stack�
_external_ges�
_interning)rZnamespaceHandling�bufsizerrrr Zs
zExpatParser.__init__cCsVt�|�}||_z*|��|j�t|��tj�	||�Wn|�
��YnXdSr)r�prepare_input_sourcer(�reset�
_cont_handlerZsetDocumentLocatorrrr-�parse�
_close_source�r�sourcerrrr8gs
zExpatParser.parsecCs |��dk	r|j�|���dSr)r*r!ZSetBaser:rrr�
prepareParserwszExpatParser.prepareParsercCs tj�||�|jr|��dSr)rr-�setContentHandlerr0�_reset_cont_handler)rrrrrr=}szExpatParser.setContentHandlercCsP|tkr|jS|tkr |jdk	S|tttfkr2dS|tkr@|jSt	d|��dS)Nr�Feature '%s' not recognized)
rr.rr3rrrrr2�SAXNotRecognizedException�r�namerrr�
getFeature�s
�zExpatParser.getFeaturecCs�|jrtd��|tkr||_n�|tkr.||_nt|tkrT|rL|jdkrRi|_q�d|_nN|tkrj|r�td��n8|t	kr�|r�td��n"|t
kr�|r�td��ntd|��dS)Nz!Cannot set features while parsingz!expat does not support validationz/expat does not read external parameter entitiesz(expat does not report namespace prefixesr?)r0�SAXNotSupportedExceptionrr.rr2rr3rrrr@)rrB�staterrr�
setFeature�s:
����zExpatParser.setFeaturecCsd|tjkr|jS|tkr|jS|tkrT|jrLt|jd�rB|j��St	d��nt
d��t	d|��dS)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/r
r3r	r!�hasattrrGr@rDrArrr�getProperty�s

��zExpatParser.getPropertycCsV|tjkr ||_|jrR|��n2|tkr0||_n"|tkrFtd|��nt	d|��dS)NzProperty '%s' cannot be setrH)
rrIr/r0�_reset_lex_handler_propr
r3r	rDr@)rrB�valuerrr�setProperty�s

��zExpatParser.setPropertyc
Csz|js|��d|_|j��z|j�||�WnDtjk
rt}z$tt�	|j
�||�}|j�|�W5d}~XYnXdSr$)
r0r6r7Z
startDocumentr!ZParser
�errorZSAXParseExceptionZErrorString�codeZ_err_handlerZ
fatalError)r�data�isFinal�e�excrrr�feed�s
zExpatParser.feedcCsB|j}z|��}|dk	r |��W5|��}|dk	r<|��XdSr)r(Z
getByteStream�closeZgetCharacterStream)rr;�filerrrr9�szExpatParser._close_sourcecCs�|js|jdkst|jt�r dSz(|jddd�|j	�
�d|_d|_W5d|_|jdk	rzt�}|jj|_|jj|_||_|��XdS)Nr�r%)rR)r1r!�
isinstancerr0r"r&r9rUr7ZendDocumentrrrrrV�s 
�




zExpatParser.closecCs|jj|j_|jj|j_dSr)r7�processingInstructionr!ZProcessingInstructionHandler�
charactersZCharacterDataHandler�rrrrr>�s�zExpatParser._reset_cont_handlercCs`|j}|j}|dkr4d|_d|_d|_d|_d|_n(|j|_|j|_|j	|_|j
|_|j|_dSr)r/r!ZCommentHandlerZStartCdataSectionHandlerZEndCdataSectionHandlerZStartDoctypeDeclHandlerZEndDoctypeDeclHandlerZcommentZ
startCDATAZendCDATA�start_doctype_declZendDTD)rZlexrrrrrLsz#ExpatParser._reset_lex_handler_propcCs�|jr>tj|j��d|jd�|_d|j_|j|j_	|j
|j_n,tj|j��|jd�|_|j|j_	|j
|j_|��|j|j_|j|j_|j|j_|j|j_d|_|jr�|��|j|j_z|j|j_Wntk
r�YnX|j�tj �d|_!g|_"dS)N� )�internr%r)#r.r
rr(ZgetEncodingr3r!Znamespace_prefixes�start_element_nsZStartElementHandler�end_element_nsZEndElementHandler�
start_element�end_elementr>�unparsed_entity_declZUnparsedEntityDeclHandler�
notation_declZNotationDeclHandler�start_namespace_declZStartNamespaceDeclHandler�end_namespace_declZEndNamespaceDeclHandlerZ_decl_handler_propr/rL�external_entity_refZExternalEntityRefHandler�skipped_entity_handlerZSkippedEntityHandler�AttributeErrorZSetParamEntityParsingZ*XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONEr0r1r\rrrr6s<�
�






�zExpatParser.resetcCs|jdkrdS|jjSr)r!r"r\rrrr#;s
zExpatParser.getColumnNumbercCs|jdkrdS|jjSr$)r!r&r\rrrr'@s
zExpatParser.getLineNumbercCs
|j��Sr)r(r)r\rrrr)EszExpatParser.getPublicIdcCs
|j��Sr)r(r*r\rrrr*HszExpatParser.getSystemIdcCs|j�|t|��dSr)r7ZstartElement�AttributesImpl)rrB�attrsrrrrbLszExpatParser.start_elementcCs|j�|�dSr)r7Z
endElementrArrrrcOszExpatParser.end_elementcCs�|��}t|�dkrd|f}n&t|�dkr<|d|df}nt|�}i}i}|��D]|\}}|��}t|�}	|	dkr�|}
d|f}n>|	dkr�d|d|df}
|d|df}n|d}
t|�}|||<|
||<qT|j�|dt||��dS)Nr%�rz%s:%s�)�split�len�tuple�itemsr7ZstartElementNS�AttributesNSImpl)rrBrl�pairZnewattrsZqnamesZanamerM�partsZlengthZqnameZapairrrrr`Rs0



�zExpatParser.start_element_nscCsV|��}t|�dkrd|f}n&t|�dkr<|d|df}nt|�}|j�|d�dS)Nr%rmr)rorprqr7ZendElementNS)rrBrtrrrrats
zExpatParser.end_element_nscCs|j�||�dSr)r7rZ)r�targetrQrrr�processing_instruction�sz"ExpatParser.processing_instructioncCs|j�|�dSr)r7r[)rrQrrr�character_data�szExpatParser.character_datacCs|j�||�dSr)r7ZstartPrefixMapping)r�prefixZurirrrrf�sz ExpatParser.start_namespace_declcCs|j�|�dSr)r7ZendPrefixMapping)rryrrrrg�szExpatParser.end_namespace_declcCs|j�|||�dSr)r/ZstartDTD)rrB�sysid�pubidZhas_internal_subsetrrrr]�szExpatParser.start_doctype_declcCs|j�||||�dSr)�_dtd_handlerZunparsedEntityDecl)rrB�baserzr{Z
notation_namerrrrd�sz ExpatParser.unparsed_entity_declcCs|j�|||�dSr)r|ZnotationDecl)rrBr}rzr{rrrre�szExpatParser.notation_declcCs�|js
dS|j�||�}t�||j��p*d�}|j�|j	|jf�|j	�
|�|_	||_ztj�
||�WnYdSX|jd\|_	|_|jd=dS)Nr%rXr���)r2Z_ent_handlerZ
resolveEntityrr5r(r*r1�appendr!ZExternalEntityParserCreaterr-r8)r�contextr}rzr{r;rrrrh�s"
�zExpatParser.external_entity_refcCs|rd|}|j�|�dS)N�%)r7Z
skippedEntity)rrBZis_perrrri�sz"ExpatParser.skipped_entity_handlerN)rr,)r)"rrrr r8r<r=rCrFrKrNrUr9rVr>rLr6r#r'r)r*rbrcr`rarwrxrfrgr]rdrerhrirrrrr+Ws>


'"r+cOs
t||�Sr)r+)�args�kwargsrrr�
create_parser�sr��__main__z:http://www.ibiblio.org/xml/examples/shakespeare/hamlet.xml),�versionZxml.sax._exceptionsZxml.sax.handlerrrrrrrr	r
�sys�platformZSAXReaderNotAvailableZxml.parsersr
�ImportErrorrJZxml.saxrrrrkrs�_weakrefr�weakref�proxyrZLocatorrr-r+r�rZxml.sax.saxutilsZxml�pr=ZsaxZXMLGeneratorZsetErrorHandlerZErrorHandlerr8rrrr�<module>sL


$_