AlkantarClanX12

Your IP : 18.223.210.249


Current Path : /lib64/python3.6/xml/sax/__pycache__/
Upload File :
Current File : //lib64/python3.6/xml/sax/__pycache__/expatreader.cpython-36.pyc

3


 \X=�@s�dZdZddlTddlmZmZddlmZddlmZmZddlm	Z	ddlm
Z
mZdd	lZej
d	d
�dkr|edd	��[ydd
lmZWnek
r�edd	��YnXeed�s�edd	��ddlmZmZmZejZejZy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&j'e%j(jj)��e&j*e%j(j+��e&j,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.6/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|�|_dS)N)r�_ref)�self�parserrrr�__init__9szExpatLocator.__init__cCs|j}|jdkrdS|jjS)N)r�_parser�ErrorColumnNumber)rrrrr�getColumnNumber<s
zExpatLocator.getColumnNumbercCs|j}|jdkrdS|jjS)N�)rr�ErrorLineNumber)rrrrr�
getLineNumberBs
zExpatLocator.getLineNumbercCs|j}|dkrdS|jj�S)N)r�_source�getPublicId)rrrrrr&HszExpatLocator.getPublicIdcCs|j}|dkrdS|jj�S)N)rr%�getSystemId)rrrrrr'NszExpatLocator.getSystemIdN)	rrr�__doc__rr!r$r&r'rrrrr3src@seZdZdZdGdd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Z	dd�Z
dd�ZdHdd�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)I�ExpatParserz$SAX driver for the pyexpat C module.r���cCsFtjj||�tj�|_d|_||_d|_d|_g|_	d|_
d|_dS)Nr)r�IncrementalParserrZInputSourcer%r�_namespaces�_lex_handler_prop�_parsing�
_entity_stack�
_external_ges�
_interning)rZnamespaceHandling�bufsizerrrrZs
zExpatParser.__init__c	CsVtj|�}||_y*|j�|jjt|��tjj	||�Wn|j
��YnXdS)z3Parse an XML document from a URL or an InputSource.N)r�prepare_input_sourcer%�reset�
_cont_handlerZsetDocumentLocatorrrr-�parse�
_close_source)r�sourcerrrr8gs
zExpatParser.parsecCs |j�dk	r|jj|j��dS)N)r'rZSetBase)rr:rrr�
prepareParserwszExpatParser.prepareParsercCs tjj||�|jr|j�dS)N)rr-�setContentHandlerr0�_reset_cont_handler)rrrrrr<}szExpatParser.setContentHandlercCsP|tkr|jS|tkr |jdk	S|tttfkr2dS|tkr@|jSt	d|��dS)NrzFeature '%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 prefixeszFeature '%s' not recognized)r0�SAXNotSupportedExceptionrr.rr2rr3rrrr>)rr?�staterrr�
setFeature�s2
zExpatParser.setFeaturecCsd|tjkr|jS|tkr|jS|tkrT|jrLt|jd�rB|jj�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 parsingzProperty '%s' not recognized)r�property_lexical_handlerr/r
r3r	r�hasattrrDr>rA)rr?rrr�getProperty�s

zExpatParser.getPropertycCsV|tjkr ||_|jrR|j�n2|tkr0||_n"|tkrFtd|��nt	d|��dS)NzProperty '%s' cannot be setzProperty '%s' not recognized)
rrEr/r0�_reset_lex_handler_propr
r3r	rAr>)rr?�valuerrr�setProperty�s


zExpatParser.setPropertycCsz|js|j�d|_|jj�y|jj||�WnDtjk
rt}z&ttj	|j
�||�}|jj|�WYdd}~XnXdS)Nr")
r0r6r7Z
startDocumentrZParser
�errorZSAXParseExceptionZErrorString�codeZ_err_handlerZ
fatalError)r�data�isFinal�e�excrrr�feed�s
zExpatParser.feedcCsB|j}z|j�}|dk	r |j�Wd|j�}|dk	r<|j�XdS)N)r%ZgetCharacterStream�closeZ
getByteStream)rr:�filerrrr9�szExpatParser._close_sourcecCs�|js|jdkst|jt�r dSz(|jddd�|jj�d|_d|_Wdd|_|jdk	rzt�}|jj|_|jj	|_	||_|j
�XdS)N�r")rNr)r1r�
isinstancerrQr7ZendDocumentr0r r#r9)rrrrrrR�s




zExpatParser.closecCs|jj|j_|jj|j_dS)N)r7�processingInstructionrZProcessingInstructionHandler�
charactersZCharacterDataHandler)rrrrr=�szExpatParser._reset_cont_handlercCs`|j}|j}|dkr4d|_d|_d|_d|_d|_n(|j|_|j|_|j	|_|j
|_|j|_dS)N)r/rZCommentHandlerZStartCdataSectionHandlerZEndCdataSectionHandlerZStartDoctypeDeclHandlerZEndDoctypeDeclHandlerZcommentZ
startCDATAZendCDATA�start_doctype_declZendDTD)rZlexrrrrrHsz#ExpatParser._reset_lex_handler_propcCs�|jr>tj|jj�d|jd�|_d|j_|j|j_	|j
|j_n,tj|jj�|jd�|_|j|j_	|j
|j_|j�|j|j_|j|j_|j|j_|j|j_d|_|jr�|j�|j|j_y|j|j_Wntk
r�YnX|jjtj �d|_!g|_"dS)N� )�internr"r)#r.r
rr%ZgetEncodingr3rZnamespace_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/rH�external_entity_refZExternalEntityRefHandler�skipped_entity_handlerZSkippedEntityHandler�AttributeErrorZSetParamEntityParsingZ*XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONEr0r1)rrrrr6s6







zExpatParser.resetcCs|jdkrdS|jjS)N)rr )rrrrr!;s
zExpatParser.getColumnNumbercCs|jdkrdS|jjS)Nr")rr#)rrrrr$@s
zExpatParser.getLineNumbercCs
|jj�S)N)r%r&)rrrrr&EszExpatParser.getPublicIdcCs
|jj�S)N)r%r')rrrrr'HszExpatParser.getSystemIdcCs|jj|t|��dS)N)r7ZstartElement�AttributesImpl)rr?�attrsrrrr]LszExpatParser.start_elementcCs|jj|�dS)N)r7Z
endElement)rr?rrrr^OszExpatParser.end_elementcCs�|j�}t|�dkrd|f}n&t|�dkr<|d|df}nt|�}i}i}x�|j�D]|\}}|j�}t|�}	|	dkr�|}
d|f}n>|	dkr�d|d|df}
|d|df}n|d}
t|�}|||<|
||<qVW|jj|dt||��dS)Nr"�rz%s:%sr*)�split�len�tuple�itemsr7ZstartElementNS�AttributesNSImpl)rr?rg�pairZnewattrsZqnamesZanamerI�partsZlengthZqnameZapairrrrr[Rs.


zExpatParser.start_element_nscCsV|j�}t|�dkrd|f}n&t|�dkr<|d|df}nt|�}|jj|d�dS)Nr"rhr)rirjrkr7ZendElementNS)rr?rnrrrr\ts
zExpatParser.end_element_nscCs|jj||�dS)N)r7rV)r�targetrMrrr�processing_instruction�sz"ExpatParser.processing_instructioncCs|jj|�dS)N)r7rW)rrMrrr�character_data�szExpatParser.character_datacCs|jj||�dS)N)r7ZstartPrefixMapping)r�prefixZurirrrra�sz ExpatParser.start_namespace_declcCs|jj|�dS)N)r7ZendPrefixMapping)rrsrrrrb�szExpatParser.end_namespace_declcCs|jj|||�dS)N)r/ZstartDTD)rr?�sysid�pubidZhas_internal_subsetrrrrX�szExpatParser.start_doctype_declcCs|jj||||�dS)N)�_dtd_handlerZunparsedEntityDecl)rr?�basertruZ
notation_namerrrr_�sz ExpatParser.unparsed_entity_declcCs|jj|||�dS)N)rvZnotationDecl)rr?rwrtrurrrr`�szExpatParser.notation_declc	Cs�|js
dS|jj||�}tj||jj�p*d�}|jj|j	|jf�|j	j
|�|_	||_ytjj
||�Wn
dS|jd\|_	|_|jd=dS)Nr"rTr���rx)r2Z_ent_handlerZ
resolveEntityrr5r%r'r1�appendrZExternalEntityParserCreaterr-r8)r�contextrwrtrur:rrrrc�s 
zExpatParser.external_entity_refcCs|rd|}|jj|�dS)N�%)r7Z
skippedEntity)rr?Zis_perrrrd�sz"ExpatParser.skipped_entity_handlerNi��)rr|)r)#rrrr(rr8r;r<r@rCrGrJrQr9rRr=rHr6r!r$r&r'r]r^r[r\rqrrrarbrXr_r`rcrdrrrrr)Ws@


'"r)cOs
t||�S)N)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
�ImportErrorrFZxml.saxrrrrfrm�_weakrefr�weakref�proxyrZLocatorrr-r)rrZxml.sax.saxutilsZxml�pr<ZsaxZXMLGeneratorZsetErrorHandlerZErrorHandlerr8rrrr�<module>sN


$_