ok

Mini Shell

Direktori : /opt/alt/python27/lib64/python2.7/site-packages/
Upload File :
Current File : //opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pyo

�
�BCVc@sddZdZdZddlZddlZejddkr_eje�dZeefZ	neZ	ddl
TddlmZm
Z
dd	lmZmZmZmZmZmZmZmZmZmZejd
�dZd�ZyddlZWn+ek
r$ed
ej�d��nXdej fd��YZ dej!fd��YZ"d�Z#dS(s� A SAX2 driver for libxml2, on top of it's XmlReader API

USAGE
    # put this file (drv_libxml2.py) in PYTHONPATH
    import xml.sax
    reader = xml.sax.make_parser(["drv_libxml2"])
    # ...and the rest is standard python sax.

CAVEATS
    - Lexical handlers are supported, except for start/endEntity
      (waiting for XmlReader.ResolveEntity) and start/endDTD
    - Error callbacks are not exactly synchronous, they tend
      to be invoked before the corresponding content callback,
      because the underlying reader interface parses
      data by chunks of 512 bytes
    
TODO
    - search for TODO
    - some ErrorHandler events (warning)
    - some ContentHandler events (setDocumentLocator, skippedEntity)
    - EntityResolver (using libxml2.?)
    - DTDHandler (if/when libxml2 exposes such node types)
    - DeclHandler (if/when libxml2 exposes such node types)
    - property_xml_string?
    - feature_string_interning?
    - Incremental parser
    - additional performance tuning:
      - one might cache callbacks to avoid some name lookups
      - one might implement a smarter way to pass attributes to startElement
        (some kind of lazy evaluation?)
      - there might be room for improvement in start/endPrefixMapping
      - other?

sSt�phane Bidoul <sbi@skynet.be>s0.3i����Nii(t*(t	xmlreadertsaxutils(
tfeature_namespacestfeature_namespace_prefixestfeature_string_interningtfeature_validationtfeature_external_gestfeature_external_pestproperty_lexical_handlertproperty_declaration_handlertproperty_dom_nodetproperty_xml_stringtutf8icCs"|dkr|St|�dSdS(Ni(tNonet_decoder(ts((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pyt_dBss+libxml2 not available: import error was: %stLocatorcBs;eZdZd�Zd�Zd�Zd�Zd�ZRS(s4SAX Locator adapter for libxml2.xmlTextReaderLocatorcCs
||_dS(N(t_Locator__locator(tselftlocator((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pyt__init__QscCsdS(s6Return the column number where the current event ends.i����((R((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pytgetColumnNumberTscCs
|jj�S(s4Return the line number where the current event ends.(Rt
LineNumber(R((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pyt
getLineNumberXscCsdS(s3Return the public identifier for the current event.N(R(R((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pytgetPublicId\scCs
|jj�S(s3Return the system identifier for the current event.(RtBaseURI(R((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pytgetSystemId`s(t__name__t
__module__t__doc__RRRRR(((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pyRNs				t
LibXml2ReadercBsbeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�ZRS(
cCs\tjj|�d|_d|_d|_d|_d|_d|_	d|_
d|_dS(Nii(Rt	XMLReaderRt_LibXml2Reader__nst_LibXml2Reader__nspfxt_LibXml2Reader__validatet_LibXml2Reader__extparamst_LibXml2Reader__parsingRt_LibXml2Reader__lex_handlert_LibXml2Reader__decl_handlert_LibXml2Reader__errors(R((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pyRfs							cCsG|jdkrg|_n|jj|t|dt|��f�dS(N(R)RtappendtSAXParseExceptionR(RtargtmsgtseverityR((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pyt
_errorHandlerus
	cCs�x�|jD]w\}}|tjtjfkrA|jj|�q
|rq||jddkrq|jj|�q
|jj|�q
Wd|_dS(Ni����i(	R)tlibxml2t PARSER_SEVERITY_VALIDITY_WARNINGtPARSER_SEVERITY_WARNINGt_err_handlertwarningt
fatalErrorterrorR(RtfatalR.t	exception((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pyt
_reportErrors|s	cCs"d|_zt|t�r-tj|�}n9tj|�}tj|j��}|j	|j
��}|j|jd�|jr�|jtjd�|jtjd�|jtjd�|jtj|j�n|jtjd�|jrtjii�}ntji�}g}|jj�x�|j�}|dkrd|jdk	r�|jd�q�ne|dkr�|jdk	r�|jd�nPn6|jdk	r�|jd�n|jjt d��P|j!�}|dkr!|jr�t"|j#��t"|j$��f}	t"|j%��}
i|_&}i|_'}g}
x�|j(�rt"|j%��}t"|j)��}|j*d�r�t+|�dkr�|d}nd}|
j,|�|jj-||�|j.s�qCq�nt"|j#��t"|j$��f}|||<|||<qCW|j/�|jj0|	|
|�|j1�rx|jj2|	|
�x.|
D]}|jj3|�q[Wq|j,|
�q�t"|j%��}	i|_&}x8|j(�r�t"|j%��}t"|j)��||<q�W|j/�|jj4|	|�|j1�r�|jj5|	�q�q*|dkr�|jr�|jj2t"|j#��t"|j$��ft"|j%���xC|j6�D]}|jj3|�q�Wq�|jj5t"|j%���q*|dkr�|jj7t"|j)���q*|d	kr|jj8t"|j)���q*|d
kr=|jj7t"|j)���q*|dkr�|j9dk	rh|j9j:�n|jj7t"|j)���|j9dk	r�|j9j;�q�q*|dkr�|j9dk	r�|j<t"|j%���n|j=�q*|dkr$|j9dk	r�|j>t"|j%���q�q*|d
kr^|jj?t"|j%��t"|j)���q*|dkr�|j9dk	r�|j9j@t"|j)���q�q*|dkr�q*|dkr�q*|dkr�q*|dkr�q*t d|��q*|dkr|jjA�n|jB�Wdd|_XdS(Niis"Read failed (no details available)txmlnsiiiii
iiiiii
iisUnexpected node type %d(CR&t
isinstancetStringTypesR0tnewTextReaderFilenameRtprepare_input_sourcetinputBuffert
getByteStreamt
newTextReaderRtSetErrorHandlerR/RR%t
SetParserProptPARSER_LOADDTDtPARSER_DEFAULTATTRStPARSER_SUBST_ENTITIEStPARSER_VALIDATER$R"RtAttributesNSImpltAttributesImplt
_cont_handlert
startDocumenttReadR)R9R3R5tSAXExceptiontNodeTypeRtNamespaceUrit	LocalNametNamet_attrst_qnamestMoveToNextAttributetValuet
startswithtlenR*tstartPrefixMappingR#t
MoveToElementtstartElementNStIsEmptyElementtendElementNStendPrefixMappingtstartElementt
endElementtpopt
characterstignorableWhitespaceR't
startCDATAtendCDATAtstartEntityt
ResolveEntityt	endEntitytprocessingInstructiontcommenttendDocumenttClose(RtsourcetreadertinputtattributesNSImpltattributesImpltprefixestrtnodeTypeteltNameteltQNametattrstqnamestnewPrefixestqnametvaluet	newPrefixtattNametprefix((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pytparse�s�			
	
	



	
		

	



	
		!
	%"cCstd��dS(NsDTDHandler not supported(tSAXNotSupportedException(Rthandler((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pyt
setDTDHandler6scCstd��dS(NsEntityResolver not supported(R(Rtresolver((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pytsetEntityResolver:scCsp|tkr|jS|tkr&|jS|tkr9|jS|tkrIdS|tkr\|jSt	d|��dS(NisFeature '%s' not recognized(
RR"RR#RR$RRR%tSAXNotRecognizedException(Rtname((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pyt
getFeature>scCs�|jrtd|��n|tkr4||_n�|tkrL||_nn|tkrd||_nV|tkr�|dkr�td|��q�n(|t	kr�||_
ntd|��dS(Ns#Cannot set feature %s while parsingisFeature '%s' not supportedsFeature '%s' not recognized(R&RRR"RR#RR$RRR%R�(RR�tstate((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pyt
setFeatureMs"	
cCs:|tkr|jS|tkr&|jStd|��dS(NsProperty '%s' not recognized(R	R'R
R(R�(RR�((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pytgetPropertybscCsT|tkr||_n8|tkr@td|��||_ntd|��dS(NsProperty '%s' not supportedsProperty '%s' not recognized(R	R'R
RR(R�(RR�Rz((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pytsetPropertyks
(RRRR/R9R~R�R�R�R�R�R�(((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pyR ds				�						cCst�S(N(R (((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pyt
create_parserws($Rt
__author__t__version__tsystcodecstversion_infotunicode_escape_decodetstrtunicodeR<txml.sax._exceptionstxml.saxRRtxml.sax.handlerRRRRRRR	R
RRtlookupRRR0tImportErrortSAXReaderNotAvailabletexc_infoRR!R R�(((s>/opt/alt/python27/lib64/python2.7/site-packages/drv_libxml2.pyt<module>#s,
F
	
�

Zerion Mini Shell 1.0