ok

Mini Shell

Direktori : /opt/alt/python35/lib64/python3.5/xml/sax/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/xml/sax/__pycache__/expatreader.cpython-35.opt-2.pyc



���]X=�@s2dZddlTddlmZmZddlmZddlmZmZddlmZddlm	Z	m
Z
ddlZejdd	�d
kr�e
dd��[yddlmZWn!ek
r�e
d
d��Yn Xeed�re
d
d��ddlmZmZmZejZejZyddlZWnek
r^dd�ZYnXddlZejZ[[Gdd�d�ZGdd�dej�ZGdd�dejej�Z dd�Z!e"dkr.ddl#Z$e!�Z%e%j&e$j'jj(��e%j)e$j'j*��e%j+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�0/opt/alt/python35/lib64/python3.5/expatreader.py�_mkproxy'src@seZdZdS)�
_ClosedParserN)�__name__�
__module__�__qualname__rrrrr.src@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ExpatLocatorcCst|�|_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&Hs	zExpatLocator.getPublicIdcCs&|j}|dkrdS|jj�S)N)rr%�getSystemId)rrrrrr'Ns	zExpatLocator.getSystemIdN)rrrrr!r$r&r'rrrrr3s
rc@s�eZdZddEdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Zdd�Z	dd�Z
ddd�Zdd�Zdd�Z
dd�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>�Zd?d@�Z dAdB�Z!dCS)F�ExpatParserr���cCsetjj||�tj�|_d|_||_d|_d|_g|_	d|_
d|_dS)Nrr")r�IncrementalParserrZInputSourcer%r�_namespaces�_lex_handler_prop�_parsing�
_entity_stack�
_external_ges�
_interning)rZnamespaceHandling�bufsizerrrrZs						zExpatParser.__init__c	Csktj|�}||_y7|j�|jjt|��tjj	||�Wn|j
��YnXdS)N)r�prepare_input_sourcer%�reset�
_cont_handlerZsetDocumentLocatorrrr,�parse�
_close_source)r�sourcerrrr7gs	

zExpatParser.parsecCs,|j�dk	r(|jj|j��dS)N)r'rZSetBase)rr9rrr�
prepareParserwszExpatParser.prepareParsercCs*tjj||�|jr&|j�dS)N)rr,�setContentHandlerr/�_reset_cont_handler)rrrrrr;}s	zExpatParser.setContentHandlercCsl|tkr|jS|tkr,|jdk	S|tttfkrEdS|tkrX|jSt	d|��dS)NrzFeature '%s' not recognized)
rr-rr2rrrrr1�SAXNotRecognizedException)r�namerrr�
getFeature�s
	zExpatParser.getFeaturecCs�|jrtd��|tkr-||_n�|tkrE||_n�|tkr~|rr|jdkr{i|_q�d|_ns|tkr�|r�td��nR|t	kr�|r�td��n1|t
kr�|r�td��ntd|��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)r/�SAXNotSupportedExceptionrr-rr1rr2rrrr=)rr>�staterrr�
setFeature�s2	zExpatParser.setFeaturecCs�|tjkr|jS|tkr)|jS|tkrx|jrlt|jd�r]|jj�St	d��nt
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
r2r	r�hasattrrCr=r@)rr>rrr�getProperty�s	
	zExpatParser.getPropertycCsy|tjkr.||_|jru|j�nG|tkrF||_n/|tkretd|��nt	d|��dS)NzProperty '%s' cannot be setzProperty '%s' not recognized)
rrDr.r/�_reset_lex_handler_propr
r2r	r@r=)rr>�valuerrr�setProperty�s		

zExpatParser.setPropertycCs�|js)|j�d|_|jj�y|jj||�WnVtjk
r�}z3ttj	|j
�||�}|jj|�WYdd}~XnXdS)Nr")
r/r5r6Z
startDocumentrZParser
�errorZSAXParseExceptionZErrorString�codeZ_err_handlerZ
fatalError)r�data�isFinal�e�excrrr�feed�s	
	
zExpatParser.feedcCsY|j}z&|j�}|dk	r.|j�Wd|j�}|dk	rT|j�XdS)N)r%ZgetCharacterStream�closeZ
getByteStream)rr9�filerrrr8�s	zExpatParser._close_sourcecCs�|js*|jdks*t|jt�r.dSz6|jddd�|jj�d|_d|_Wdd|_|jdk	r�t�}|jj|_|jj	|_	||_|j
�XdS)N�rMr"r)r0r�
isinstancerrPr6ZendDocumentr/r r#r8)rrrrrrQ�s
	
			zExpatParser.closecCs(|jj|j_|jj|j_dS)N)r6�processingInstructionrZProcessingInstructionHandler�
charactersZCharacterDataHandler)rrrrr<�szExpatParser._reset_cont_handlercCs�|j}|j}|dkrNd|_d|_d|_d|_d|_n<|j|_|j|_|j	|_|j
|_|j|_dS)N)r.rZCommentHandlerZStartCdataSectionHandlerZEndCdataSectionHandlerZStartDoctypeDeclHandlerZEndDoctypeDeclHandlerZcommentZ
startCDATAZendCDATA�start_doctype_declZendDTD)rZlexrrrrrGs						z#ExpatParser._reset_lex_handler_propcCsa|jr]tj|jj�dd|j�|_d|j_|j|j_	|j
|j_nBtj|jj�d|j�|_|j|j_	|j
|j_|j�|j|j_|j|j_|j|j_|j|j_d|_|jr|j�|j|j_y|j|j_Wntk
r7YnX|jjtj �d|_!g|_"dS)N� �internr"r)#r-r
rr%ZgetEncodingr2rZnamespace_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.rG�external_entity_refZExternalEntityRefHandler�skipped_entity_handlerZSkippedEntityHandler�AttributeErrorZSetParamEntityParsingZ*XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONEr/r0)rrrrr5s6	
		

	
	zExpatParser.resetcCs|jdkrdS|jjS)N)rr )rrrrr!;szExpatParser.getColumnNumbercCs|jdkrdS|jjS)Nr")rr#)rrrrr$@szExpatParser.getLineNumbercCs
|jj�S)N)r%r&)rrrrr&EszExpatParser.getPublicIdcCs
|jj�S)N)r%r')rrrrr'HszExpatParser.getSystemIdcCs|jj|t|��dS)N)r6ZstartElement�AttributesImpl)rr>�attrsrrrr\LszExpatParser.start_elementcCs|jj|�dS)N)r6Z
endElement)rr>rrrr]OszExpatParser.end_elementcCsL|j�}t|�dkr-d|f}n5t|�dkrV|d|df}nt|�}i}i}x�|j�D]�\}}|j�}t|�}	|	dkr�|}
d|f}nQ|	dkr�d|d|df}
|d|df}n|d}
t|�}|||<|
||<q{W|jj|dt||��dS)Nr"�rz%s:%sr))�split�len�tuple�itemsr6ZstartElementNS�AttributesNSImpl)rr>rf�pairZnewattrsZqnamesZanamerH�parts�lengthZqnameZapairrrrrZRs.

zExpatParser.start_element_nscCsy|j�}t|�dkr-d|f}n5t|�dkrV|d|df}nt|�}|jj|d�dS)Nr"rgr)rhrirjr6ZendElementNS)rr>rmrrrr[tszExpatParser.end_element_nscCs|jj||�dS)N)r6rU)r�targetrLrrr�processing_instruction�sz"ExpatParser.processing_instructioncCs|jj|�dS)N)r6rV)rrLrrr�character_data�szExpatParser.character_datacCs|jj||�dS)N)r6ZstartPrefixMapping)r�prefixZurirrrr`�sz ExpatParser.start_namespace_declcCs|jj|�dS)N)r6ZendPrefixMapping)rrsrrrra�szExpatParser.end_namespace_declcCs|jj|||�dS)N)r.ZstartDTD)rr>�sysid�pubidZhas_internal_subsetrrrrW�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dSYnX|jd\|_	|_|jd=dS)Nr"rSr���rx)r1Z_ent_handlerZ
resolveEntityrr4r%r'r0�appendrZExternalEntityParserCreaterr,r7)r�contextrwrtrur9rrrrb�s 					
zExpatParser.external_entity_refcCs$|rd|}|jj|�dS)N�%)r6Z
skippedEntity)rr>Zis_perrrrc�s
z"ExpatParser.skipped_entity_handlerNii�)"rrrrr7r:r;r?rBrFrIrPr8rQr<rGr5r!r$r&r'r\r]rZr[rqrrr`rarWr^r_rbrcrrrrr(Ws>
'"r(cOs
t||�S)N)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
�ImportErrorrEZxml.saxrrrrerl�_weakrefr�weakref�proxyrZLocatorrr,r(r~rZxml.sax.saxutilsZxml�pr;ZsaxZXMLGeneratorZsetErrorHandlerZErrorHandlerr7rrrr�<module>sJ

		
	$�^	

Zerion Mini Shell 1.0