{fc@s-dZddlZddlZddlZddlZddlZddlZddlZddlZyej ej gZ Wne k rej gZ nXdZ idZidZidZdZdejfd YZd ejfd YZd ejfd YZddZdS(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 "    cCs|dkr$ddl}|j}nt|tjrTtj|}d|_nTtj}d|_|j |_ y|j |_ |j |_ Wnt k rnXt |d|ddddS( NicSsdS(N(tNone(((s(/usr/lib64/python2.7/xml/sax/saxutils.pytVtcSstS(N(tTrue(((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR[Rtencodingterrorstxmlcharrefreplacetnewlines (Rtsyststdoutt isinstancetiot RawIOBasetBufferedIOBasetclosetwritabletwritetseekablettelltAttributeErrort_UnbufferedTextIOWrapper(toutRRtbuffer((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt_gettextwriterMs"        R'cBseZdZRS(cCs$tt|j||jdS(N(tsuperR'R#tflush(tselfR((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR#ks(t__name__t __module__R#(((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR'jst 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*R#t_writeR,t_flusht _ns_contextst_current_contextt_undeclared_ns_mapst _encoding(R-R(R((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR3rs    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(R-tnametprefix((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt_qname|s  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(R-R<turi((s(/usr/lib64/python2.7/xml/sax/saxutils.pytstartPrefixMappings cCs|jd|_|jd=dS(Ni(R6R7(R-R<((s(/usr/lib64/python2.7/xml/sax/saxutils.pytendPrefixMappingscCs\|jd|x7|jD])\}}|jd|t|fqW|jddS(Nu(R4RR(R-R;tattrsR((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt startElements!cCs|jd|dS(Nu(R4(R-R;((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(R-R;tqnameRDR<RAR((s(/usr/lib64/python2.7/xml/sax/saxutils.pytstartElementNSs *cCs|jd|j|dS(Nu(R4R=(R-R;RG((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt endElementNSscCs;t|ts$t||j}n|jt|dS(N(RtunicodeR9R4R (R-tcontent((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt charactersscCs5t|ts$t||j}n|j|dS(N(RRJR9R4(R-RK((s(/usr/lib64/python2.7/xml/sax/saxutils.pytignorableWhitespacescCs|jd||fdS(Nu (R4(R-ttargetR ((s(/usr/lib64/python2.7/xml/sax/saxutils.pytprocessingInstructionsN(R.R/RR3R=R>R?RBRCRERFRHRIRLRMRO(((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR0ps           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(R-tparent((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR3scCs|jj|dS(N(t _err_handlerterror(R-t exception((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRVscCs|jj|dS(N(RUt fatalError(R-RW((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRXscCs|jj|dS(N(RUtwarning(R-RW((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRYscCs|jj|dS(N(t _cont_handlertsetDocumentLocator(R-tlocator((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(R-R<RA((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRBscCs|jj|dS(N(RZRC(R-R<((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRCscCs|jj||dS(N(RZRE(R-R;RD((s(/usr/lib64/python2.7/xml/sax/saxutils.pyREscCs|jj|dS(N(RZRF(R-R;((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRFscCs|jj|||dS(N(RZRH(R-R;RGRD((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRHscCs|jj||dS(N(RZRI(R-R;RG((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRIscCs|jj|dS(N(RZRL(R-RK((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRLscCs|jj|dS(N(RZRM(R-tchars((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRMscCs|jj||dS(N(RZRO(R-RNR ((s(/usr/lib64/python2.7/xml/sax/saxutils.pyROscCs|jj|dS(N(RZt skippedEntity(R-R;((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR^scCs|jj|||dS(N(t _dtd_handlert notationDecl(R-R;tpublicIdtsystemId((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR` scCs|jj||||dS(N(R_tunparsedEntityDecl(R-R;RaRbtndata((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRc scCs|jj||S(N(t _ent_handlert resolveEntity(R-RaRb((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRfscCsT|jj||jj||jj||jj||jj|dS(N(RStsetContentHandlertsetErrorHandlertsetEntityResolvert setDTDHandlertparse(R-tsource((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRks cCs|jj|dS(N(RSt setLocale(R-tlocale((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRmscCs|jj|S(N(RSt getFeature(R-R;((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRo scCs|jj||dS(N(RSt setFeature(R-R;tstate((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRp#scCs|jj|S(N(RSt getProperty(R-R;((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRr&scCs|jj||dS(N(RSt setProperty(R-R;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(R-RT((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt setParent1sN( R.R/t__doc__RR3RVRXRYR[R>R?RBRCRERFRHRIRLRMROR^R`RcRfRkRmRoRpRrRsRtRu(((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRPs:                           RcCst|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 getSystemIdtostpathtdirnametnormpathRtgetfilesystemencodingRRJtdecodetUnicodeDecodeErrortencodetjointisfilet UnicodeErrortFalsetopenturlparseturljointurllibturlopen(RltbasetftsysidtbaseheadRt sysidfilenameR((s(/usr/lib64/python2.7/xml/sax/saxutils.pytprepare_input_source6sF         (RvRRRttypesRRR1RQt StringTypet UnicodeTypeRzR&RR R RR*t TextIOWrapperR'R2R0RRRPR(((s(/usr/lib64/python2.7/xml/sax/saxutils.pyts$0          Wo