ó {fc@s3dZdZddlTddlmZmZddlmZddlmZmZddlm Z ddlm Z m Z dd l Z e j d d kr©ed eƒ‚n[ ydd lmZWn ek râedeƒ‚n#Xeedƒ redeƒ‚nddlmZmZmZejZejZydd lZWnek r_d„ZnXdd lZejZ[[dfd„ƒYZdejfd„ƒYZ dej!ejfd„ƒYZ"d„Z#e$dkr/dd 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+/usr/lib64/python2.7/xml/sax/expatreader.pyt_mkproxy'st _ClosedParsercBseZRS((t__name__t __module__(((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR.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+/usr/lib64/python2.7/xml/sax/expatreader.pyt__init__9scCs&|j}|jdkrdS|jjS(N(Rt_parsertNonetErrorColumnNumber(RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pytgetColumnNumber<s cCs&|j}|jdkrdS|jjS(Ni(RRRtErrorLineNumber(RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt getLineNumberBs cCs&|j}|dkrdS|jjƒS(N(RRt_sourcet getPublicId(RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR Hs  cCs&|j}|dkrdS|jjƒS(N(RRRt getSystemId(RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR!Ns  (RRt__doc__RRRR R!(((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR3s     t ExpatParsercBs.eZdZdd%d„Zd„Zd„Zd„Zd „Zd „Zd „Z d „Z dd „Z d„Z d„Z d„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd „Zd!„Zd"„Z d#„Z!RS(&s$SAX driver for the pyexpat C module.iiiicCsetjj||ƒtjƒ|_d|_||_d|_d|_ g|_ d|_ d|_ dS(Nii( R tIncrementalParserRt InputSourceRRRt _namespacest_lex_handler_propt_parsingt _entity_stackt _external_gest _interning(RtnamespaceHandlingtbufsize((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRZs      cCsjtj|ƒ}||_y7|jƒ|jjt|ƒƒtjj ||ƒWn|j ƒ‚nXdS(s3Parse an XML document from a URL or an InputSource.N( R tprepare_input_sourceRtresett _cont_handlertsetDocumentLocatorRR R$tparset _close_source(Rtsource((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR2gs   cCsV|jƒdk rR|jƒ}t|tƒr?|jdƒ}n|jj|ƒndS(Nsutf-8(R!Rt isinstancetunicodetencodeRtSetBase(RR4tbase((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt prepareParserws  cCs-tjj||ƒ|jr)|jƒndS(N(R R$tsetContentHandlerR(t_reset_cont_handler(RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR;€s cCsl|tkr|jS|tkr,|jdk S|tttfkrEdS|tkrX|j St d|ƒ‚dS(NisFeature '%s' not recognized( RR&RR+RRRRRR*tSAXNotRecognizedException(Rtname((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt getFeature…s      cCs|jrtdƒ‚n|tkr0||_nÐ|tkrH||_n¸|tkr„|rx|jdkri|_qqd|_n||t kr¨|rtdƒ‚qnX|t krÌ|rtdƒ‚qn4|t krð|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+/usr/lib64/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+RRthasattrRCR=R@(RR>((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt getProperty¯s      cCs||tjkr1||_|jrx|jƒqxnG|tkrI||_n/|tkrhtd|ƒ‚nt d|ƒ‚dS(NsProperty '%s' cannot be setsProperty '%s' not recognized( RRDR'R(t_reset_lex_handler_propRR+RR@R=(RR>tvalue((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt setPropertyÁs      cCsŽ|js,|jƒd|_|jjƒny|jj||ƒWnDtjk r‰}ttj |j ƒ||ƒ}|j j |ƒnXdS(Ni( R(R/R0t startDocumentRtParseR terrortSAXParseExceptiont ErrorStringtcodet _err_handlert fatalError(RtdatatisFinaltetexc((s+/usr/lib64/python2.7/xml/sax/expatreader.pytfeedÑs   cCs_|j}z)|jƒ}|dk r1|jƒnWd|jƒ}|dk rZ|jƒnXdS(N(RtgetCharacterStreamRtcloset getByteStream(RR4tfile((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR3âs     cCsÁ|js*|jdks*t|jtƒr.dSz6|jdddƒ|jjƒd|_d|_Wdd|_|jdk r²tƒ}|jj |_ |jj |_ ||_n|j ƒXdS(NtRSii( R)RRR5RRVR0t endDocumentR(RRR3(RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRXís      cCs(|jj|j_|jj|j_dS(N(R0tprocessingInstructionRtProcessingInstructionHandlert characterstCharacterDataHandler(R((s+/usr/lib64/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+/usr/lib64/python2.7/xml/sax/expatreader.pyRGs            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 R Rt getEncodingR+Rtnamespace_prefixeststart_element_nstStartElementHandlertend_element_nstEndElementHandlert start_elementt end_elementR<tunparsed_entity_decltUnparsedEntityDeclHandlert notation_decltNotationDeclHandlertstart_namespace_decltStartNamespaceDeclHandlertend_namespace_decltEndNamespaceDeclHandlerRt_decl_handler_propR'RGtexternal_entity_reftExternalEntityRefHandlertskipped_entity_handlertSkippedEntityHandlertAttributeErrortSetParamEntityParsingt*XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONER(R)(R((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR/s6          cCs|jdkrdS|jjS(N(RRR(R((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR>scCs|jdkrdS|jjS(Ni(RRR(R((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRCscCs |jjƒS(N(RR (R((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR HscCs |jjƒS(N(RR!(R((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR!KscCs|jj|t|ƒƒdS(N(R0t startElementtAttributesImpl(RR>tattrs((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRtOscCs|jj|ƒdS(N(R0t endElement(RR>((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRuRsc 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|ƒ} ||| <| || RˆtpairtnewattrstqnamestanameRHtpartstlengthtqnametapair((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRpUs.         cCsy|jƒ}t|ƒdkr-d|f}n5t|ƒdkrV|d|df}n t|ƒ}|jj|dƒdS(Niii(RŠR‹RRŒR0t endElementNS(RR>R((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRrws  cCs|jj||ƒdS(N(R0R](RttargetRR((s+/usr/lib64/python2.7/xml/sax/expatreader.pytprocessing_instructionƒscCs|jj|ƒdS(N(R0R_(RRR((s+/usr/lib64/python2.7/xml/sax/expatreader.pytcharacter_data‡scCs|jj||ƒdS(N(R0tstartPrefixMapping(Rtprefixturi((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRzŠscCs|jj|ƒdS(N(R0tendPrefixMapping(RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR|scCs|jj|||ƒdS(N(R'tstartDTD(RR>tsysidtpubidthas_internal_subset((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRiscCs|jj||||ƒdS(N(t _dtd_handlertunparsedEntityDecl(RR>R9R¡R¢t notation_name((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRv“scCs|jj|||ƒdS(N(R¤t notationDecl(RR>R9R¡R¢((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRx–scCsÆ|js dS|jj||ƒ}tj||jjƒp=dƒ}|jj|j |jfƒ|j j |ƒ|_ ||_yt j j ||ƒWndSX|jd\|_ |_|jd=dS(NiR[iiÿÿÿÿ(R*t _ent_handlert resolveEntityR R.RR!R)tappendRtExternalEntityParserCreateR R$R2(RtcontextR9R¡R¢R4((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR™s      cCs'|rd|}n|jj|ƒdS(Nt%(R0t skippedEntity(RR>tis_pe((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR¯s iiìÿ("RRR"RR2R:R;R?RBRFRIRVR3RXR<RGR/RRR R!RtRuRpRrRšR›RzR|RiRvRxRR(((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR#Ws@          '       "        cOs t||ŽS(N(R#(targstkwargs((s+/usr/lib64/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.handlerRRRRRRRRtsystplatformtSAXReaderNotAvailableRt xml.parsersR t ImportErrorREtxml.saxR R RR‡Rt_weakrefRtweakreftproxyRtLocatorRR$R#R²Rtxml.sax.saxutilstxmltpR;tsaxt XMLGeneratortsetErrorHandlert ErrorHandlerR2(((s+/usr/lib64/python2.7/xml/sax/expatreader.pytsL         $ÿa