AlkantarClanX12

Your IP : 3.138.118.194


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

U

e5dX=�@s�dZdZddlTddlmZmZddlmZddlmZmZddlm	Z	ddlm
Z
mZdd	lZej
d	d
�dkr|edd	��[zdd
lmZWnek
r�edd	��YnXeed�s�edd	��ddlmZmZmZejZejZzdd	lZWnek
�rdd�ZYnXdd	lZejZ[[Gdd�d�ZGdd�dej�ZGdd�dej ej�Z!dd�Z"e#dk�r�dd	l$Z%e"�Z&e&�'e%j(j�)��e&�*e%j(�+��e&�,d�d	S)z]
SAX driver for the pyexpat C module.  This driver works with
pyexpat.__version__ == '2.22'.
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@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�ExpatLocatorz�Locator for use with the ExpatParser class.

    This uses a weak reference to the parser object to avoid creating
    a circular reference between the parser and the content handler.
    cCst|�|_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)	rrr�__doc__r r#r'r)r*rrrrr3src@seZdZdZdCdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�ZdDdd�Zdd�Z
dd�Zdd�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=�Z d>d?�Z!d@dA�Z"dBS)E�ExpatParserz$SAX driver for the pyexpat C module.r��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|�
��YnXdS)z3Parse an XML document from a URL or an InputSource.N)r�prepare_input_sourcer(�reset�
_cont_handlerZsetDocumentLocatorrrr.�parse�
_close_source�r�sourcerrrr9gs
zExpatParser.parsecCs |��dk	r|j�|���dSr)r*r!ZSetBaser;rrr�
prepareParserwszExpatParser.prepareParsercCs tj�||�|jr|��dSr)rr.�setContentHandlerr1�_reset_cont_handler)rrrrrr>}szExpatParser.setContentHandlercCsP|tkr|jS|tkr |jdk	S|tttfkr2dS|tkr@|jSt	d|��dS)Nr�Feature '%s' not recognized)
rr/rr4rrrrr3�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@)r1�SAXNotSupportedExceptionrr/rr3rr4rrrrA)rrC�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_handlerr0r
r4r	r!�hasattrrHrArErBrrr�getProperty�s

��zExpatParser.getPropertycCsV|tjkr ||_|jrR|��n2|tkr0||_n"|tkrFtd|��nt	d|��dS)NzProperty '%s' cannot be setrI)
rrJr0r1�_reset_lex_handler_propr
r4r	rErA)rrC�valuerrr�setProperty�s

��zExpatParser.setPropertyc
Csz|js|��d|_|j��z|j�||�WnDtjk
rt}z$tt�	|j
�||�}|j�|�W5d}~XYnXdSr$)
r1r7r8Z
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<�filerrrr:�szExpatParser._close_sourcecCs�|js|jdkst|jt�r dSz(|jddd�|j	�
�d|_d|_W5d|_|jdk	rzt�}|jj|_|jj|_||_|��XdS)Nr�r%)rS)r2r!�
isinstancerr1r"r&r:rVr8ZendDocumentrrrrrW�s 
�




zExpatParser.closecCs|jj|j_|jj|j_dSr)r8�processingInstructionr!ZProcessingInstructionHandler�
charactersZCharacterDataHandler�rrrrr?�s�zExpatParser._reset_cont_handlercCs`|j}|j}|dkr4d|_d|_d|_d|_d|_n(|j|_|j|_|j	|_|j
|_|j|_dSr)r0r!ZCommentHandlerZStartCdataSectionHandlerZEndCdataSectionHandlerZStartDoctypeDeclHandlerZEndDoctypeDeclHandlerZcommentZ
startCDATAZendCDATA�start_doctype_declZendDTD)rZlexrrrrrMsz#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(ZgetEncodingr4r!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_propr0rM�external_entity_refZExternalEntityRefHandler�skipped_entity_handlerZSkippedEntityHandler�AttributeErrorZSetParamEntityParsingZ*XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONEr1r2r]rrrr7s<�
�






�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)r8ZstartElement�AttributesImpl)rrC�attrsrrrrcLszExpatParser.start_elementcCs|j�|�dSr)r8Z
endElementrBrrrrdOszExpatParser.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�itemsr8ZstartElementNS�AttributesNSImpl)rrCrm�pairZnewattrsZqnamesZanamerN�partsZlengthZqnameZapairrrrraRs0



�zExpatParser.start_element_nscCsV|��}t|�dkrd|f}n&t|�dkr<|d|df}nt|�}|j�|d�dS)Nr%rnr)rprqrrr8ZendElementNS)rrCrurrrrbts
zExpatParser.end_element_nscCs|j�||�dSr)r8r[)r�targetrRrrr�processing_instruction�sz"ExpatParser.processing_instructioncCs|j�|�dSr)r8r\)rrRrrr�character_data�szExpatParser.character_datacCs|j�||�dSr)r8ZstartPrefixMapping)r�prefixZurirrrrg�sz ExpatParser.start_namespace_declcCs|j�|�dSr)r8ZendPrefixMapping)rrzrrrrh�szExpatParser.end_namespace_declcCs|j�|||�dSr)r0ZstartDTD)rrC�sysid�pubidZhas_internal_subsetrrrr^�szExpatParser.start_doctype_declcCs|j�||||�dSr)�_dtd_handlerZunparsedEntityDecl)rrC�baser{r|Z
notation_namerrrre�sz ExpatParser.unparsed_entity_declcCs|j�|||�dSr)r}ZnotationDecl)rrCr~r{r|rrrrf�szExpatParser.notation_declcCs�|js
dS|j�||�}t�||j��p*d�}|j�|j	|jf�|j	�
|�|_	||_ztj�
||�WnYdSX|jd\|_	|_|jd=dS)Nr%rYr���)r3Z_ent_handlerZ
resolveEntityrr6r(r*r2�appendr!ZExternalEntityParserCreaterr.r9)r�contextr~r{r|r<rrrri�s"
�zExpatParser.external_entity_refcCs|rd|}|j�|�dS)N�%)r8Z
skippedEntity)rrCZis_perrrrj�sz"ExpatParser.skipped_entity_handlerN)rr-)r)#rrrr+r r9r=r>rDrGrLrOrVr:rWr?rMr7r#r'r)r*rcrdrarbrxryrgrhr^rerfrirjrrrrr,Ws@

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


$_