Vco=cs dZdZddlTddlmZmZddlmZddlmZmZddlm Z ddlm Z m Z dd l Z e j d d d kr ed d [ dd lmZeeds edd n#e$r edd wxYwddlmZmZmZejZejZ dd lZdd lZejZ[[n#e$rdZYnwxYwGddZGddejZGddej ejZ!dZ"e#dkrdd l$Z%e"Z&e&'e%j(j)e&*e%j(+e&,dd Sd S)z] SAX driver for the pyexpat C module. This driver works with pyexpat.__version__ == '2.22'. z0.20)Z*)feature_validationfeature_namespaces)feature_namespace_prefixes)feature_external_gesfeature_external_pes)feature_string_interning)property_xml_stringproperty_interning_dictNiZjavazexpat not available in Java)expat ParserCreatezexpat not supported) xmlreadersaxutilshandlercs|SN)Zo ,/usr/lib64/python3.11/xml/sax/expatreader.py_mkproxyr'scseZdZdS) _ClosedParserN)__name__ __module__ __qualname__rrrrr.sDrrcs0eZdZdZdZdZdZdZdZdS) ExpatLocatorzLocator 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. cs.t||_dSr)r_refselfparser r__init__zExpatLocator.__init__9sV$$ rcs:|j}|jdS|jjSr)r_parserErrorColumnNumberrrrgetColumnNumberzExpatLocator.getColumnNumber<s# > 4~//rcs:|j}|jdS|jjSN)rrErrorLineNumberrrr getLineNumberzExpatLocator.getLineNumberBs# > 1~--rcJ|j}|dS|jSr)r_source getPublicIdrrrr(zExpatLocator.getPublicIdH*  4~))+++rcr&r)rr' getSystemIdrrrr*zExpatLocator.getSystemIdNr)rN) rrr__doc__rr!r%r(r*rrrrr3si %%%000 ... ,,, ,,,,,rrcseZdZdZd%dZdZdZdZdZd Z d Z d Z d&d Z dZ dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZd Zd!Z d"Z!d#Z"d$S)' ExpatParserz$SAX driver for the pyexpat C module.rcstj||tj|_d|_||_d|_d|_g|_ d|_ d|_ dS)NFr) r IncrementalParserrZ InputSourcer'r _namespaces_lex_handler_prop_parsing _entity_stack _external_ges _interning)rZnamespaceHandlingZbufsize rrzExpatParser.__init__Zsd#,,T7;;; ,..  ,!% rcs(tj|}||_ ||jt |tj ||dS#| xYw)z3Parse an XML document from a URL or an InputSource.N) r prepare_input_sourcer'reset _cont_handlerZsetDocumentLocatorrr r.parse _close_sourcersourcerrr9zExpatParser.parsegs.v66   JJLLL   1 1,t2D2D E E E  ' - -dF ; ; ; ; ;     s AA::Bcs|.|j|dSdSr)r*rZSetBaser;rr prepareParserzExpatParser.prepareParserwsH      7 L !3!3!5!5 6 6 6 6 6 7 7rcstj|||jr|dSdSr)r r.setContentHandlerr1_reset_cont_handler)rr rrr>zExpatParser.setContentHandler}sG#55dGDDD = '  $ $ & & & & & ' 'rcs|tkr|jS|tkr |jduS|tt t fvrdS|tkr|jStd|z)NrFeature '%s' not recognized) rr/rr4rrrrr3SAXNotRecognizedExceptionrnamerr getFeaturezExpatParser.getFeatures % % &# # - - &?$. . (*>022 &1 ) ) &% %'(E(LMMMrcs|jrtd|tkr ||_dS|tkr ||_dS|t kr|r|j i|_dSdSd|_dS|tkr|rtddS|tkr|rtddS|tkr|rtddStd|z)Nz!Cannot set features while parsingz!expat does not support validationz/expat does not read external parameter entitiesz(expat does not report namespace prefixesr@) r1SAXNotSupportedExceptionrr/rr3rr4rrrrA)rrCZstater5r setFeaturezExpatParser.setFeaturesa = P*+NOO O % % 6$D    ) ) 6!&D    - - 6 '?)&(DOOO))#' ' ' 6 9.7999 9 9) ) 6 G.EGGG G G/ / 6 @.>@@@ @ @,-466 6rcs4|tjkr|jS|tkr|jS|t krS|jr=t|jdr|jStdtdtd|z)NGetInputContextz=This version of expat does not support getting the XML stringz.XML string cannot be returned when not parsingProperty '%s' not recognized) r property_lexical_handlerr0rr4rrhasattrrGrArErBrr getPropertyzExpatParser.getPropertys 73 3 F) ) , , F? " ( ( F| F4<):;;+<779993*+++/DFFF'(F(MNNNrcs|tjkr&||_|jr|dSdS|t kr ||_dS|tkrtd|ztd|z)NzProperty '%s' cannot be setrH) r rIr0r1_reset_lex_handler_proprr4rrErA)rrCvaluer5r setPropertyzExpatParser.setPropertys 73 3 2%*D "} /,,..... / / , , 2#DOOO ( ( 2*+H+/,011 1,,J,0-122 2rFcsr|js4|d|_|j |j||dS#t j$rM}tt j |j ||}|j |Yd}~dSd}~wwxYw)NT) r1r7r8Z startDocumentrZParser ZerrorZSAXParseExceptionZ ErrorStringZcodeZ _err_handlerZ fatalError)rdataisFinalZeZexc rfeedzExpatParser.feeds} / JJLLL DM   , , . . . . L  tW - - - - -{ . . .#E$5af$=$=q$GGC   ( ( - - - - - - - - - .sAB6)AB11B6cs"|j} |}|||}||dSdS#|}||wwxYwr)r'ZgetCharacterStreamcloseZ getByteStream)rr<Zfiler5rr:zExpatParser._close_sources ,,..D  ''))D    ''))D   s *A!!-BcsF|js!|jt|jtrdS |dd|jd|_d|_d|_|j7t}|jj|_|jj |_ ||_| dS#d|_|j7t}|jj|_|jj |_ ||_| wxYw)NrT)rPF) r2rZ isinstancerrRr8Z endDocumentr1r r$r:rrrrSzExpatParser.closes   $,  t|] 3 3  F ! IIc4I ( ( (   * * , , ,!DMDL!DM| &&+/<+I()-)E&%    "DM| &&+/<+I()-)E&%    s >CAD cs^|jj|j_|jj|j_dSr)r8processingInstructionrZProcessingInstructionHandler charactersZCharacterDataHandlerrrrr?zExpatParser._reset_cont_handlers+$($6$L 1,0,>,I )))rcs|j}|j}|%d|_d|_d|_d|_d|_dS|j|_|j|_|j |_|j |_|j |_dSr) r0rZCommentHandlerZStartCdataSectionHandlerZEndCdataSectionHandlerZStartDoctypeDeclHandlerZEndDoctypeDeclHandlerZcommentZ startCDATAZendCDATAstart_doctype_declZendDTD)rZlexrr5rrLz#ExpatParser._reset_lex_handler_props$  6$(F !.2F +,0F )-1F *+/F ( ( ($'KF !.1nF +,/LF )-1-DF *+.:F ( ( (rcsT|jrgtj|jd|j|_d|j_|j|j_ |j |j_ nYtj|j|j|_|j |j_ |j |j_ ||j|j_|j|j_|j|j_|j|j_d|_|jr||j|j_ |j|j_n#t<$rYnwxYw|jtj d|_!g|_"dS)Nz )Zinternr#F)#r/r r r'Z getEncodingr4rZnamespace_prefixesstart_element_nsZStartElementHandlerend_element_nsZEndElementHandler start_element end_elementr?unparsed_entity_declZUnparsedEntityDeclHandler notation_declZNotationDeclHandlerstart_namespace_declZStartNamespaceDeclHandlerend_namespace_declZEndNamespaceDeclHandlerZ_decl_handler_propr0rLexternal_entity_refZExternalEntityRefHandlerskipped_entity_handlerZSkippedEntityHandlerZAttributeErrorZSetParamEntityParsingZ*XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONEr1r2rVrrr7zExpatParser.resets   > -dl.F.F.H.H#59_FFFDL./DL +/3/DDL ,-1-@DL * * -dl.F.F.H.H7;HHHDL/3/ADL ,-1-=DL *   """151J .+/+= (151J ./3/F ,"&  ! +  ( ( * * *150H - 040KDL - -    D  **  < > > > sE&& E32E3cs,|jdS|jjSr)rr rVrrr!zExpatParser.getColumnNumber;s < 4|--rcs,|jdS|jjSr")rr$rVrrr%zExpatParser.getLineNumber@s < 1|++rc4|jSr)r'r(rVrrr(zExpatParser.getPublicIdE|'')))rcrbr)r'r*rVrrr*zExpatParser.getSystemIdHrcrcsV|j|t|dSr)r8Z startElementAttributesImpl)rrCattrsr5rrZzExpatParser.start_elementLs) ''nU.C.CDDDDDrc:|j|dSr)r8Z endElementrBrrr[zExpatParser.end_elementO %%d+++++rcsJ|}t|dkrd|f}n3t|dkr|d|df}nt|}i}i}|D]\}}|}t|} | dkr|} d|f} nA| dkr$|dd|d} |d|df} n|d} t|} ||| <| || <|j|dt ||dS)Nr#riz:)splitlentupleZitemsr8ZstartElementNSAttributesNSImpl) rrCrepairZnewattrsZqnamesZanamerMZpartsZlengthZqnameZapairs rrXzExpatParser.start_element_nsRsUzz|| t99> $
 $
>>>>rcrfr)r8rU)rrOrrcharacter_datazExpatParser.character_datargrcrnr)r8ZstartPrefixMapping)rprefixZurir5rr^z ExpatParser.start_namespace_decls! --fc:::::rcrfr)r8ZendPrefixMapping)rrqrrr_zExpatParser.end_namespace_decls ++F33333rcs>|j|||dSr)r0ZstartDTD)rrCsysidpubidZhas_internal_subsetrQrrWzExpatParser.start_doctype_decls# ''eU;;;;;rcs@|j||||dSr) _dtd_handlerZunparsedEntityDecl)rrCbaserrrsZ notation_name rr\z ExpatParser.unparsed_entity_decls% ,,T5%OOOOOrcs>|j|||dSr)rtZ notationDecl)rrCrurrrsrQrr]zExpatParser.notation_decls# &&tUE:::::rcs|jsdS|j||}tj||jpd}|j|j |jf|j ||_ ||_ tj ||n#YdSxYw|jd\|_ |_|jd=dS)Nr#Zri)r3Z _ent_handlerZ resolveEntityr r6r'r*r2ZappendrZExternalEntityParserCreater r.r9)rZcontextrurrrsr<rvrr`zExpatParser.external_entity_refs! 1"00>>.v/3|/G/G/I/I02/133 !!4<">???|>>wGG     ' - -dF ; ; ; ; 11'+'9"'=$t|  r "qs CCcsH|rd|z}|j|dS)Nz%)r8Z skippedEntity)rrCZis_per5rraz"ExpatParser.skipped_entity_handlers0  t8D ((.....rN)rr-)F)#rrrr+rr9r=r>rDrFrKrNrRr:rSr?rLr7r!r%r(r*rZr[rXrYrorpr^r_rWr\r]r`rarrrr,r,Ws ..     777 ''' N N N666<OOO$ 2 2 2 ...."   !!!*JJJ 666 # # # N... ,,, ******EEE,,, N N ND 4 4 4???,,,;;;444<<<PPP;;;,/////rr,cst|i|Sr)r,)ZargsZkwargsrr create_parserrws  ' ' ''rZ__main__z:http://www.ibiblio.org/xml/examples/shakespeare/hamlet.xml)-r+ZversionZxml.sax._exceptionsZxml.sax.handlerrrrrrrrrZsysZplatformZSAXReaderNotAvailableZ xml.parsersr rJZ ImportErrorZxml.saxr r r rdrlZ_weakrefZweakrefZproxyrrZLocatorrr.r,rwrZxml.sax.saxutilsZxmlZpr>ZsaxZ XMLGeneratorZsetErrorHandlerZ ErrorHandlerr9rrrrxs !!!!BBBBBBBB666666FFFFFFFF444444HHHHHHHH <vE   =t D DDA!!!!!! 75. ) )A##$94@@@A===   5t < <<= 1000000000)- OOO NNN}H         ,,,,,9$,,,HY/Y/Y/Y/Y/)-y/@Y/Y/Y/z (((  zJ A(5577888cg**,,---GG HIIIII JJsA11BB11B<;B<