AlkantarClanX12

Your IP : 3.143.203.129


Current Path : /opt/alt/python39/lib64/python3.9/xml/sax/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/xml/sax/__pycache__/expatreader.cpython-39.opt-1.pyc

a

R�fS?�@s�dZdZddlTddlmZmZddlmZddlmZmZddlm	Z	ddlm
Z
mZdd	lZej
d	d
�dkr|edd	��[zdd
lmZWney�edd	��Yn0eed�s�edd	��ddlmZmZmZejZejZzdd	lZWne�ydd�ZYn0dd	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/python39/lib64/python3.9/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}|jdurdS|jjSr)r�_parser�ErrorColumnNumberrrrr�getColumnNumber<s
zExpatLocator.getColumnNumbercCs|j}|jdurdS|jjS�N�)rr!�ErrorLineNumberrrrr�
getLineNumberBs
zExpatLocator.getLineNumbercCs|j}|durdS|j��Sr)r�_source�getPublicIdrrrrr)HszExpatLocator.getPublicIdcCs|j}|durdS|j��Sr)rr(�getSystemIdrrrrr*NszExpatLocator.getSystemIdN)	rrr�__doc__r r#r'r)r*rrrrr3src@seZdZdZdFdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�ZdGdd�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!dAdB�Z"dCdD�Z#dES)H�ExpatParserz$SAX driver for the pyexpat C module.r��cCsFtj�||�t��|_d|_||_d|_d|_g|_	d|_
d|_dS)NFr)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|�
��Yn0dS)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 |��dur|j�|���dSr)r*r!ZSetBaser;rrr�
prepareParserwszExpatParser.prepareParsercCs tj�||�|jr|��dSr)rr.�setContentHandlerr1�_reset_cont_handler)rrrrrr>}szExpatParser.setContentHandlercCsP|tkr|jS|tkr |jduS|tttfvr2dS|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|jdurRi|_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.setPropertyFc
Cs||js|��d|_|j��z|j�||�WnFtjyv}z,tt�	|j
�||�}|j�|�WYd}~n
d}~00dS)NT)
r1r7r8Z
startDocumentr!�Parser
�error�SAXParseException�ErrorString�code�_err_handler�
fatalError)r�data�isFinal�e�excrrr�feed�s
zExpatParser.feedc
Cs�|jdurdS|j��}zvz|j�d�|j�dd�WnFtjy~}z,tt�|j�||�}|j	�
|�WYd}~n
d}~00W|j�|�n|j�|�0dS)NF�)r!ZGetReparseDeferralEnabledZSetReparseDeferralEnabledrPr
rQrRrSrTrUrV)rZwas_enabledrYrZrrr�flush�s

$zExpatParser.flushcCsZ|j}z4|��}|dur |��W|��}|durV|��n|��}|durT|��0dSr)r(ZgetCharacterStream�closeZ
getByteStream)rr<�filerrrr:�s

�zExpatParser._close_sourcecCs�|js|jdust|jt�r dSz`|jddd�|j��d|_d|_Wd|_|jdurxt�}|jj|_|jj	|_	||_|�
�n:d|_|jdur�t�}|jj|_|jj	|_	||_|�
�0dS)Nr\T)rXF)r2r!�
isinstancerr[r8ZendDocumentr1r"r&r:rrrrr^�s.
�




�


zExpatParser.closecCs|jj|j_|jj|j_dSr)r8�processingInstructionr!ZProcessingInstructionHandler�
charactersZCharacterDataHandler�rrrrr?
s�zExpatParser._reset_cont_handlercCs`|j}|j}|dur4d|_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_Wnty�Yn0|j�tj �d|_!g|_"dS)N� )�internr%F)#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_STANDALONEr1r2rcrrrr7"s<�
�






�zExpatParser.resetcCs|jdurdS|jjSr)r!r"rcrrrr#Is
zExpatParser.getColumnNumbercCs|jdurdS|jjSr$)r!r&rcrrrr'Ns
zExpatParser.getLineNumbercCs
|j��Sr)r(r)rcrrrr)SszExpatParser.getPublicIdcCs
|j��Sr)r(r*rcrrrr*VszExpatParser.getSystemIdcCs|j�|t|��dSr)r8ZstartElement�AttributesImpl)rrC�attrsrrrriZszExpatParser.start_elementcCs|j�|�dSr)r8Z
endElementrBrrrrj]szExpatParser.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)rrCrs�pairZnewattrsZqnamesZanamerN�partsZlengthZqnameZapairrrrrg`s0



�zExpatParser.start_element_nscCsV|��}t|�dkrd|f}n&t|�dkr<|d|df}nt|�}|j�|d�dS)Nr%rtr)rvrwrxr8ZendElementNS)rrCr{rrrrh�s
zExpatParser.end_element_nscCs|j�||�dSr)r8ra)r�targetrWrrr�processing_instruction�sz"ExpatParser.processing_instructioncCs|j�|�dSr)r8rb)rrWrrr�character_data�szExpatParser.character_datacCs|j�||�dSr)r8ZstartPrefixMapping)r�prefixZurirrrrm�sz ExpatParser.start_namespace_declcCs|j�|�dSr)r8ZendPrefixMapping)rr�rrrrn�szExpatParser.end_namespace_declcCs|j�|||�dSr)r0ZstartDTD)rrC�sysid�pubidZhas_internal_subsetrrrrd�szExpatParser.start_doctype_declcCs|j�||||�dSr)�_dtd_handlerZunparsedEntityDecl)rrC�baser�r�Z
notation_namerrrrk�sz ExpatParser.unparsed_entity_declcCs|j�|||�dSr)r�ZnotationDecl)rrCr�r�r�rrrrl�szExpatParser.notation_declcCs�|js
dS|j�||�}t�||j��p*d�}|j�|j	|jf�|j	�
|�|_	||_ztj�
||�WnYdS0|jd\|_	|_|jd=dS)Nr%�r���)r3Z_ent_handlerZ
resolveEntityrr6r(r*r2�appendr!ZExternalEntityParserCreaterr.r9)r�contextr�r�r�r<rrrro�s"
�zExpatParser.external_entity_refcCs|rd|}|j�|�dS)N�%)r8Z
skippedEntity)rrCZis_perrrrp�sz"ExpatParser.skipped_entity_handlerN)rr-)F)$rrrr+r r9r=r>rDrGrLrOr[r]r:r^r?rMr7r#r'r)r*rirjrgrhr~rrmrnrdrkrlrorprrrrr,WsB


'"r,cOst|i|��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.saxrrrrrrz�_weakrefr�weakref�proxyrZLocatorrr.r,r�rZxml.sax.saxutilsZxml�pr>ZsaxZXMLGeneratorZsetErrorHandlerZErrorHandlerr9rrrr�<module>sN


$m