Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/xml/sax/expatreader.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c@s dZdZddlTddlmZmZddlmZddlmZmZddlm	Z	ddlm
Z
mZdd	lZej
d
 dkr�ede��n[ydd
lmZWn ek
r�ede��n#Xeed�rede��nddlmZmZmZejZejZydd	lZWnek
r_d�ZnXdd	lZejZ[[dejfd��YZdej ejfd��YZ!d�Z"e#dkrdd	l$Z%e"�Z&e&j'e%j(jj)��e&j*e%j(j+��e&j,d�nd	S(s]
SAX driver for the pyexpat C module.  This driver works with
pyexpat.__version__ == '2.22'.
s0.20i�(t*(tfeature_validationtfeature_namespaces(tfeature_namespace_prefixes(tfeature_external_gestfeature_external_pes(tfeature_string_interning(tproperty_xml_stringtproperty_interning_dictNitjavasexpat not available in Java(texpatsexpat not supportedtParserCreate(t	xmlreadertsaxutilsthandlercCs|S(N((to((s)/sys/lib/python2.7/xml/sax/expatreader.pyt_mkproxy'stExpatLocatorcBs;eZdZd�Zd�Zd�Zd�Zd�ZRS(s�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(Rt_ref(tselftparser((s)/sys/lib/python2.7/xml/sax/expatreader.pyt__init__6scCs&|j}|jdkrdS|jjS(N(Rt_parsertNonetErrorColumnNumber(RR((s)/sys/lib/python2.7/xml/sax/expatreader.pytgetColumnNumber9s	cCs&|j}|jdkrdS|jjS(Ni(RRRtErrorLineNumber(RR((s)/sys/lib/python2.7/xml/sax/expatreader.pyt
getLineNumber?s	cCs&|j}|dkrdS|jj�S(N(RRt_sourcetgetPublicId(RR((s)/sys/lib/python2.7/xml/sax/expatreader.pyREs	cCs&|j}|dkrdS|jj�S(N(RRRtgetSystemId(RR((s)/sys/lib/python2.7/xml/sax/expatreader.pyRKs	(t__name__t
__module__t__doc__RRRRR(((s)/sys/lib/python2.7/xml/sax/expatreader.pyR0s				tExpatParsercBs%eZdZdd$d�Zd�Zd�Zd�Zd	�Zd
�Zd�Z	d�Z
dd
�Zd�Zd�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd �Zd!�Zd"�Z RS(%s$SAX driver for the pyexpat C module.iiiicCsetjj||�tj�|_d|_||_d|_d|_	g|_
d|_d|_dS(Nii(
RtIncrementalParserRtInputSourceRRRt_namespacest_lex_handler_propt_parsingt
_entity_stackt
_external_gest
_interning(RtnamespaceHandlingtbufsize((s)/sys/lib/python2.7/xml/sax/expatreader.pyRWs						cCsOtj|�}||_|j�|jjt|��tjj	||�dS(s3Parse an XML document from a URL or an InputSource.N(
R
tprepare_input_sourceRtresett
_cont_handlertsetDocumentLocatorRRR#tparse(Rtsource((s)/sys/lib/python2.7/xml/sax/expatreader.pyR1ds
	
cCsV|j�dk	rR|j�}t|t�r?|jd�}n|jj|�ndS(Nsutf-8(RRt
isinstancetunicodetencodeRtSetBase(RR2tbase((s)/sys/lib/python2.7/xml/sax/expatreader.pyt
prepareParserms
cCs-tjj||�|jr)|j�ndS(N(RR#tsetContentHandlerR't_reset_cont_handler(RR((s)/sys/lib/python2.7/xml/sax/expatreader.pyR9vs	cCsl|tkr|jS|tkr,|jdk	S|tttfkrEdS|tkrX|j	St
d|��dS(NisFeature '%s' not recognized(RR%RR*RRRRRR)tSAXNotRecognizedException(Rtname((s)/sys/lib/python2.7/xml/sax/expatreader.pyt
getFeature{s
	cCs|jrtd��n|tkr0||_n�|tkrH||_n�|tkr�|rx|jdkr�i|_q�qd|_n||t	kr�|rtd��qnX|t
kr�|rtd��qn4|tkr�rtd��qntd|��dS(Ns!Cannot set features while parsings!expat does not support validations/expat does not read external parameter entitiess(expat does not report namespace prefixessFeature '%s' not recognized(
R'tSAXNotSupportedExceptionRR%RR)RR*RRRRR;(RR<tstate((s)/sys/lib/python2.7/xml/sax/expatreader.pyt
setFeature�s2	cCs�|tjkr|jS|tkr)|jS|tkr{|jrlt|jd�r]|jj�St	d��q{t
d��nt	d|��dS(NtGetInputContexts=This version of expat does not support getting the XML strings.XML string cannot be returned when not parsingsProperty '%s' not recognized(Rtproperty_lexical_handlerR&RR*RRthasattrRAR;R>(RR<((s)/sys/lib/python2.7/xml/sax/expatreader.pytgetProperty�s	
cCs||tjkr1||_|jrx|j�qxnG|tkrI||_n/|tkrhtd|��nt	d|��dS(NsProperty '%s' cannot be setsProperty '%s' not recognized(
RRBR&R't_reset_lex_handler_propRR*RR>R;(RR<tvalue((s)/sys/lib/python2.7/xml/sax/expatreader.pytsetProperty�s		
cCs�|js,|j�d|_|jj�ny|jj||�WnDtjk
r�}ttj	|j
�||�}|jj|�nXdS(Ni(
R'R.R/t
startDocumentRtParseR
terrortSAXParseExceptiontErrorStringtcodet_err_handlert
fatalError(RtdatatisFinaltetexc((s)/sys/lib/python2.7/xml/sax/expatreader.pytfeed�s	
	cCsC|jr
dS|jddd�|jj�d|_d|_dS(NtRQii(R(RTR/tendDocumentR'RR(R((s)/sys/lib/python2.7/xml/sax/expatreader.pytclose�s	
	cCs(|jj|j_|jj|j_dS(N(R/tprocessingInstructionRtProcessingInstructionHandlert
characterstCharacterDataHandler(R((s)/sys/lib/python2.7/xml/sax/expatreader.pyR:�scCs�|j}|j}|dkrNd|_d|_d|_d|_d|_n<|j|_|j	|_|j
|_|j|_|j|_dS(N(
R&RRtCommentHandlertStartCdataSectionHandlertEndCdataSectionHandlertStartDoctypeDeclHandlertEndDoctypeDeclHandlertcommentt
startCDATAtendCDATAtstart_doctype_decltendDTD(RtlexR((s)/sys/lib/python2.7/xml/sax/expatreader.pyRE�s						cCsc|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�n|j|j_y|j|j_Wntk
r9nX|jj tj!�d|_"g|_#dS(Nt tinternii($R%R
RRtgetEncodingR*Rtnamespace_prefixeststart_element_nstStartElementHandlertend_element_nstEndElementHandlert
start_elementtend_elementR:tunparsed_entity_decltUnparsedEntityDeclHandlert
notation_decltNotationDeclHandlertstart_namespace_decltStartNamespaceDeclHandlertend_namespace_decltEndNamespaceDeclHandlerRt_decl_handler_propR&REtexternal_entity_reftExternalEntityRefHandlertskipped_entity_handlertSkippedEntityHandlertAttributeErrortSetParamEntityParsingt*XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONER'R((R((s)/sys/lib/python2.7/xml/sax/expatreader.pyR.�s6	
		

	
	cCs|jdkrdS|jjS(N(RRR(R((s)/sys/lib/python2.7/xml/sax/expatreader.pyRscCs|jdkrdS|jjS(Ni(RRR(R((s)/sys/lib/python2.7/xml/sax/expatreader.pyR#scCs
|jj�S(N(RR(R((s)/sys/lib/python2.7/xml/sax/expatreader.pyR(scCs
|jj�S(N(RR(R((s)/sys/lib/python2.7/xml/sax/expatreader.pyR+scCs|jj|t|��dS(N(R/tstartElementtAttributesImpl(RR<tattrs((s)/sys/lib/python2.7/xml/sax/expatreader.pyRo/scCs|jj|�dS(N(R/t
endElement(RR<((s)/sys/lib/python2.7/xml/sax/expatreader.pyRp2sc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|df}
|d|df}n|d}
t|�}|||<|
||<q{W|jj|dt||��dS(Niiis%s:%si(tsplittlenRttupletitemsR/tstartElementNStAttributesNSImpl(RR<R�tpairtnewattrstqnamestanameRFtpartstlengthtqnametapair((s)/sys/lib/python2.7/xml/sax/expatreader.pyRk5s.

cCsy|j�}t|�dkr-d|f}n5t|�dkrV|d|df}nt|�}|jj|d�dS(Niii(R�R�RR�R/tendElementNS(RR<R�((s)/sys/lib/python2.7/xml/sax/expatreader.pyRmWscCs|jj||�dS(N(R/RX(RttargetRP((s)/sys/lib/python2.7/xml/sax/expatreader.pytprocessing_instructioncscCs|jj|�dS(N(R/RZ(RRP((s)/sys/lib/python2.7/xml/sax/expatreader.pytcharacter_datagscCs|jj||�dS(N(R/tstartPrefixMapping(Rtprefixturi((s)/sys/lib/python2.7/xml/sax/expatreader.pyRujscCs|jj|�dS(N(R/tendPrefixMapping(RR�((s)/sys/lib/python2.7/xml/sax/expatreader.pyRwmscCs|jj|||�dS(N(R&tstartDTD(RR<tsysidtpubidthas_internal_subset((s)/sys/lib/python2.7/xml/sax/expatreader.pyRdpscCs|jj||||�dS(N(t_dtd_handlertunparsedEntityDecl(RR<R7R�R�t
notation_name((s)/sys/lib/python2.7/xml/sax/expatreader.pyRqsscCs|jj|||�dS(N(R�tnotationDecl(RR<R7R�R�((s)/sys/lib/python2.7/xml/sax/expatreader.pyRsvscCs�|js
dS|jj||�}tj||jj�p=d�}|jj|j	|jf�|j	j
|�|_	||_ytjj
||�WndSX|jd\|_	|_|jd=dS(NiRUii�(R)t_ent_handlert
resolveEntityR
R-RRR(tappendRtExternalEntityParserCreateRR#R1(RtcontextR7R�R�R2((s)/sys/lib/python2.7/xml/sax/expatreader.pyRzys 				
cCs'|rd|}n|jj|�dS(Nt%(R/t
skippedEntity(RR<tis_pe((s)/sys/lib/python2.7/xml/sax/expatreader.pyR|�s
ii�(!RR R!RR1R8R9R=R@RDRGRTRWR:RER.RRRRRoRpRkRmR�R�RuRwRdRqRsRzR|(((s)/sys/lib/python2.7/xml/sax/expatreader.pyR"Ts>
										
			'							"									cOs
t||�S(N(R"(targstkwargs((s)/sys/lib/python2.7/xml/sax/expatreader.pyt
create_parser�st__main__s:http://www.ibiblio.org/xml/examples/shakespeare/hamlet.xml(-R!tversiontxml.sax._exceptionstxml.sax.handlerRRRRRRRRtsystplatformtSAXReaderNotAvailableRtxml.parsersR
tImportErrorRCtxml.saxRR
RR�R�t_weakrefRtweakreftproxytLocatorRR#R"R�Rtxml.sax.saxutilstxmltpR9tsaxtXMLGeneratortsetErrorHandlertErrorHandlerR1(((s)/sys/lib/python2.7/xml/sax/expatreader.pyt<module>sJ

		

	$�	

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].