Hacked By AnonymousFox

Current Path : /opt/alt/python37/lib64/python3.7/xml/sax/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/xml/sax/__pycache__/expatreader.cpython-37.pyc

B

� fX=�@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&�'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�8/opt/alt/python37/lib64/python3.7/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|j��S)N)r�_source�getPublicId)rrrrrr&HszExpatLocator.getPublicIdcCs|j}|dkrdS|j��S)N)rr%�getSystemId)rrrrrr'NszExpatLocator.getSystemIdN)	rrr�__doc__rr!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�IncrementalParserrZInputSourcer%r�_namespaces�_lex_handler_prop�_parsing�
_entity_stack�
_external_ges�
_interning)rZnamespaceHandling�bufsizerrrrZs
zExpatParser.__init__cCsVt�|�}||_y*|��|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�sourcerrrr6gs
zExpatParser.parsecCs |��dk	r|j�|���dS)N)r'rZSetBase)rr8rrr�
prepareParserwszExpatParser.prepareParsercCs tj�||�|jr|��dS)N)rr+�setContentHandlerr.�_reset_cont_handler)rrrrrr:}szExpatParser.setContentHandlercCsP|tkr|jS|tkr |jdk	S|tttfkr2dS|tkr@|jSt	d|��dS)NrzFeature '%s' not recognized)
rr,rr1rrrrr0�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)r.�SAXNotSupportedExceptionrr,rr0rr1rrrr<)rr=�staterrr�
setFeature�s2
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 parsingzProperty '%s' not recognized)r�property_lexical_handlerr-r
r1r	r�hasattrrBr<r?)rr=rrr�getProperty�s

zExpatParser.getPropertycCsV|tjkr ||_|jrR|��n2|tkr0||_n"|tkrFtd|��nt	d|��dS)NzProperty '%s' cannot be setzProperty '%s' not recognized)
rrCr-r.�_reset_lex_handler_propr
r1r	r?r<)rr=�valuerrr�setProperty�s


zExpatParser.setPropertyc
Csz|js|��d|_|j��y|j�||�WnDtjk
rt}z$tt�	|j
�||�}|j�|�Wdd}~XYnXdS)Nr")
r.r4r5Z
startDocumentrZParser
�errorZSAXParseExceptionZErrorString�codeZ_err_handlerZ
fatalError)r�data�isFinal�e�excrrr�feed�s
zExpatParser.feedcCsB|j}z|��}|dk	r |��Wd|��}|dk	r<|��XdS)N)r%ZgetCharacterStream�closeZ
getByteStream)rr8�filerrrr7�szExpatParser._close_sourcecCs�|js|jdkst|jt�r dSz(|jddd�|j��d|_d|_Wdd|_|jdk	rzt�}|jj|_|jj	|_	||_|�
�XdS)N�r")rLr)r/r�
isinstancerrOr5ZendDocumentr.r r#r7)rrrrrrP�s




zExpatParser.closecCs|jj|j_|jj|j_dS)N)r5�processingInstructionrZProcessingInstructionHandler�
charactersZCharacterDataHandler)rrrrr;�szExpatParser._reset_cont_handlercCs`|j}|j}|dkr4d|_d|_d|_d|_d|_n(|j|_|j|_|j	|_|j
|_|j|_dS)N)r-rZCommentHandlerZStartCdataSectionHandlerZEndCdataSectionHandlerZStartDoctypeDeclHandlerZEndDoctypeDeclHandler�commentZ
startCDATAZendCDATA�start_doctype_declZendDTD)rZlexrrrrrFsz#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_y|j|j_Wntk
r�YnX|j�tj �d|_!g|_"dS)N� )�internr"r)#r,r
rr%ZgetEncodingr1rZnamespace_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-rF�external_entity_refZExternalEntityRefHandler�skipped_entity_handlerZSkippedEntityHandler�AttributeErrorZSetParamEntityParsingZ*XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONEr.r/)rrrrr4s6







zExpatParser.resetcCs|jdkrdS|jjS)N)rr )rrrrr!;s
zExpatParser.getColumnNumbercCs|jdkrdS|jjS)Nr")rr#)rrrrr$@s
zExpatParser.getLineNumbercCs
|j��S)N)r%r&)rrrrr&EszExpatParser.getPublicIdcCs
|j��S)N)r%r')rrrrr'HszExpatParser.getSystemIdcCs|j�|t|��dS)N)r5ZstartElement�AttributesImpl)rr=�attrsrrrr\LszExpatParser.start_elementcCs|j�|�dS)N)r5Z
endElement)rr=rrrr]OszExpatParser.end_elementcCs�|��}t|�dkrd|f}n&t|�dkr<|d|df}nt|�}i}i}x�|��D]|\}}|��}t|�}	|	dkr�|}
d|f}n>|	dkr�d|d|df}
|d|df}n|d}
t|�}|||<|
||<qVW|j�|dt||��dS)Nr"�rz%s:%s�)�split�len�tuple�itemsr5ZstartElementNS�AttributesNSImpl)rr=rf�pairZnewattrsZqnamesZanamerG�parts�lengthZqnameZapairrrrrZRs.


zExpatParser.start_element_nscCsV|��}t|�dkrd|f}n&t|�dkr<|d|df}nt|�}|j�|d�dS)Nr"rgr)rirjrkr5ZendElementNS)rr=rnrrrr[ts
zExpatParser.end_element_nscCs|j�||�dS)N)r5rT)r�targetrKrrr�processing_instruction�sz"ExpatParser.processing_instructioncCs|j�|�dS)N)r5rU)rrKrrr�character_data�szExpatParser.character_datacCs|j�||�dS)N)r5ZstartPrefixMapping)r�prefixZurirrrr`�sz ExpatParser.start_namespace_declcCs|j�|�dS)N)r5ZendPrefixMapping)rrtrrrra�szExpatParser.end_namespace_declcCs|j�|||�dS)N)r-ZstartDTD)rr=�sysid�pubidZhas_internal_subsetrrrrW�szExpatParser.start_doctype_declcCs|j�||||�dS)N)�_dtd_handlerZunparsedEntityDecl)rr=�baserurvZ
notation_namerrrr^�sz ExpatParser.unparsed_entity_declcCs|j�|||�dS)N)rwZnotationDecl)rr=rxrurvrrrr_�szExpatParser.notation_declcCs�|js
dS|j�||�}t�||j��p*d�}|j�|j	|jf�|j	�
|�|_	||_ytj�
||�Wn
dS|jd\|_	|_|jd=dS)Nr"rRr���)r0Z_ent_handlerZ
resolveEntityrr3r%r'r/�appendrZExternalEntityParserCreaterr+r6)r�contextrxrurvr8rrrrb�s 
zExpatParser.external_entity_refcCs|rd|}|j�|�dS)N�%)r5Z
skippedEntity)rr=Zis_perrrrc�sz"ExpatParser.skipped_entity_handlerN)rr*)r)#rrrr(rr6r9r:r>rArErHrOr7rPr;rFr4r!r$r&r'r\r]rZr[rrrsr`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)-r(�versionZxml.sax._exceptionsZxml.sax.handlerrrrrrrr	r
�sys�platformZSAXReaderNotAvailableZxml.parsersr
�ImportErrorrDZxml.saxrrrrerm�_weakrefr�weakref�proxyrZLocatorrr+r)rrZxml.sax.saxutilsZxml�pr:ZsaxZXMLGeneratorZsetErrorHandlerZErrorHandlerr6rrrr�<module>sN


$_


Hacked By AnonymousFox1.0, Coded By AnonymousFox