Jfc@sdZddlZddlZddlZddlZddlZddlZddlZddlZyej ej gZ Wne k rej gZ nXdZ idZidZidZdZdejfd YZd ejfd YZd d ZdS(snA library of useful helper classes to the SAX classes, for the convenience of application and driver writers. iNcCs3x,|jD]\}}|j||}q W|S(s2Replace substrings of a string using a dictionary.(titemstreplace(tstdtkeytvalue((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt__dict_replacescCsR|jdd}|jdd}|jdd}|rNt||}n|S(sEscape &, <, and > in a string of data. You can escape other strings of data by passing a dictionary as the optional entities parameter. The keys and values must all be strings; each key will be replaced with its corresponding value. t&s&t>s>t in a string of data, then quote it for use as an attribute value. The " character will be escaped as well, if necessary. You can escape other strings of data by passing a dictionary as the optional entities parameter. The keys and values must all be strings; each key will be replaced with its corresponding value. s s s s s s t"t's"%s"s"s'%s'(tcopytupdateR R(R R ((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt quoteattr5s "    cs|dkr$ddl}|j}nt|tjrTtj|}d|_nTtj}d|_|j |_ y|j |_ |j |_ Wnt k rnXdtj ffdY|d|ddd d S( NicSsdS(N(tNone(((s(/usr/lib64/python2.7/xml/sax/saxutils.pytVscSstS(N(tTrue(((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR[stUnbufferedTextIOWrappercseZfdZRS(cs$t|j||jdS(N(tsupertwritetflush(tselfR(R(s(/usr/lib64/python2.7/xml/sax/saxutils.pyRfs(t__name__t __module__R((R(s(/usr/lib64/python2.7/xml/sax/saxutils.pyRestencodingterrorstxmlcharrefreplacetnewlines (Rtsyststdoutt isinstancetiot RawIOBasetBufferedIOBasetclosetwritableRtseekablettelltAttributeErrort TextIOWrapper(toutRR!tbuffer((Rs(/usr/lib64/python2.7/xml/sax/saxutils.pyt_gettextwriterMs$        t XMLGeneratorcBseZdddZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZRS(s iso-8859-1cCsitjj|t||}|j|_|j|_ig|_|jd|_ g|_ ||_ dS(Ni( thandlertContentHandlert__init__R/Rt_writeRt_flusht _ns_contextst_current_contextt_undeclared_ns_mapst _encoding(RR-R((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR3os    cCsX|drPd|dkr&d|dS|j|d}|rP|d|dSn|dS(s7Builds a qualified name from a (ns_url, localname) pairis$http://www.w3.org/XML/1998/namespacesxml:it:(R7(Rtnametprefix((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt_qnameys  cCs|jd|jdS(Nu$ (R4R9(R((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt startDocuments cCs|jdS(N(R5(R((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt endDocumentscCs@|jj|jj||j|<|jj||fdS(N(R6tappendR7RR8(RR<turi((s(/usr/lib64/python2.7/xml/sax/saxutils.pytstartPrefixMappings cCs|jd|_|jd=dS(Ni(R6R7(RR<((s(/usr/lib64/python2.7/xml/sax/saxutils.pytendPrefixMappingscCs\|jd|x7|jD])\}}|jd|t|fqW|jddS(Nu(R4RR(RR;tattrsR((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt startElements!cCs|jd|dS(Nu(R4(RR;((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt endElementscCs|jd|j|xH|jD]=\}}|rP|jd||fq$|jd|q$Wg|_x@|jD]2\}}|jd|j|t|fq{W|jddS(Nu(R4R=R8RR(RR;tqnameRDR<RAR((s(/usr/lib64/python2.7/xml/sax/saxutils.pytstartElementNSs *cCs|jd|j|dS(Nu(R4R=(RR;RG((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt endElementNSscCs|jtt|dS(N(R4R tunicode(Rtcontent((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt charactersscCs|jt|dS(N(R4RJ(RRK((s(/usr/lib64/python2.7/xml/sax/saxutils.pytignorableWhitespacescCs|jd||fdS(Nu (R4(RttargetR ((s(/usr/lib64/python2.7/xml/sax/saxutils.pytprocessingInstructionsN(RRRR3R=R>R?RBRCRERFRHRIRLRMRO(((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR0ms           t XMLFilterBasecBs eZdZddZdZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZRS(sYThis class is designed to sit between an XMLReader and the client application's event handlers. By default, it does nothing but pass requests up to the reader and events on to the handlers unmodified, but subclasses can override specific methods to modify the event stream or the configuration requests as they pass through.cCstjj|||_dS(N(t xmlreadert XMLReaderR3t_parent(Rtparent((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR3scCs|jj|dS(N(t _err_handlerterror(Rt exception((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRVscCs|jj|dS(N(RUt fatalError(RRW((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRXscCs|jj|dS(N(RUtwarning(RRW((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRYscCs|jj|dS(N(t _cont_handlertsetDocumentLocator(Rtlocator((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR[scCs|jjdS(N(RZR>(R((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR>scCs|jjdS(N(RZR?(R((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR?scCs|jj||dS(N(RZRB(RR<RA((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRBscCs|jj|dS(N(RZRC(RR<((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRCscCs|jj||dS(N(RZRE(RR;RD((s(/usr/lib64/python2.7/xml/sax/saxutils.pyREscCs|jj|dS(N(RZRF(RR;((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRFscCs|jj|||dS(N(RZRH(RR;RGRD((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRHscCs|jj||dS(N(RZRI(RR;RG((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRIscCs|jj|dS(N(RZRL(RRK((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRLscCs|jj|dS(N(RZRM(Rtchars((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRMscCs|jj||dS(N(RZRO(RRNR ((s(/usr/lib64/python2.7/xml/sax/saxutils.pyROscCs|jj|dS(N(RZt skippedEntity(RR;((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR^scCs|jj|||dS(N(t _dtd_handlert notationDecl(RR;tpublicIdtsystemId((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR`scCs|jj||||dS(N(R_tunparsedEntityDecl(RR;RaRbtndata((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRcscCs|jj||S(N(t _ent_handlert resolveEntity(RRaRb((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRf scCsT|jj||jj||jj||jj||jj|dS(N(RStsetContentHandlertsetErrorHandlertsetEntityResolvert setDTDHandlertparse(Rtsource((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRks cCs|jj|dS(N(RSt setLocale(Rtlocale((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRmscCs|jj|S(N(RSt getFeature(RR;((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRoscCs|jj||dS(N(RSt setFeature(RR;tstate((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRpscCs|jj|S(N(RSt getProperty(RR;((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRrscCs|jj||dS(N(RSt setProperty(RR;R((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRs"scCs|jS(N(RS(R((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt getParent'scCs ||_dS(N(RS(RRT((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt setParent*sN( RRt__doc__RR3RVRXRYR[R>R?RBRCRERFRHRIRLRMROR^R`RcRfRkRmRoRpRrRsRtRu(((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRPs:                           tcCst|tkr$tj|}nSt|drw|}tj}|j|t|drw|j|jqwn|jdkry|j }t j j t j j|}tj}t|trt|tsdy|j|}Wqtk r|j|}qXqdnHt|trdy|j|}Wqdtk r`|j|}qdXnt j j||}t j j|}Wntk rt}nX|r|j|t|d}n4|jtj||j tj|j }|j|n|S(sThis function takes an InputSource and an optional base URL and returns a fully resolved InputSource object ready for reading.treadR;trbN(ttypet _StringTypesRQt InputSourcethasattrt setByteStreamt setSystemIdR;t getByteStreamRt getSystemIdtostpathtdirnametnormpathR!tgetfilesystemencodingR#RJtdecodetUnicodeDecodeErrortencodetjointisfilet UnicodeErrortFalsetopenturlparseturljointurllibturlopen(RltbasetftsysidtbaseheadRt sysidfilenameR((s(/usr/lib64/python2.7/xml/sax/saxutils.pytprepare_input_source/sF         (RvRRRttypesR$R!R1RQt StringTypet UnicodeTypeR{R+RR R RR/R2R0RRRPR(((s(/usr/lib64/python2.7/xml/sax/saxutils.pyts"0          So