Pc@s*dZddlZddlZddlZddlZddlZddlZyejejgZ Wne k rejgZ nXyddl m Z dZ [ Wnek rdZ nXdZidZidZid Zd ejfd YZd ejfd YZddZdS(snA library of useful helper classes to the SAX classes, for the convenience of application and driver writers. iN(txmlcharrefreplace_errorstxmlcharrefreplacetstrictcCs3x,|jD]\}}|j||}q W|S(s2Replace substrings of a string using a dictionary.(titemstreplace(tstdtkeytvalue((s!..\python\lib\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'(tcopytupdateRR(R R((s!..\python\lib\xml\sax\saxutils.pyt quoteattr<s "    t XMLGeneratorcBseZdddZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZRS(s iso-8859-1cCso|dkr$ddl}|j}ntjj|||_ig|_|jd|_g|_ ||_ dS(Ni( tNonetsyststdoutthandlertContentHandlert__init__t_outt _ns_contextst_current_contextt_undeclared_ns_mapst _encoding(tselftouttencodingR((s!..\python\lib\xml\sax\saxutils.pyRVs      cCsEt|tr"|jj|n|jj|j|jtdS(N(t isinstancetstrRtwritetencodeR!t_error_handling(R"ttext((s!..\python\lib\xml\sax\saxutils.pyt_writeascCsX|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:(R(R"tnametprefix((s!..\python\lib\xml\sax\saxutils.pyt_qnamegs  cCs|jd|jdS(Ns$ (R+R!(R"((s!..\python\lib\xml\sax\saxutils.pyt startDocumentzs cCs@|jj|jj||j|<|jj||fdS(N(RtappendRRR (R"R.turi((s!..\python\lib\xml\sax\saxutils.pytstartPrefixMapping~s cCs|jd|_|jd=dS(Ni(RR(R"R.((s!..\python\lib\xml\sax\saxutils.pytendPrefixMappingscCs\|jd|x7|jD])\}}|jd|t|fqW|jddS(NR s %s=%sR (R+RR(R"R-tattrsR((s!..\python\lib\xml\sax\saxutils.pyt startElements!cCs|jd|dS(Ns(R+(R"R-((s!..\python\lib\xml\sax\saxutils.pyt endElementscCs|jd|j|xN|jD]C\}}|rS|jjd||fq$|jjd|q$Wg|_x@|jD]2\}}|jd|j|t|fqW|jddS(NR s xmlns:%s="%s"s xmlns="%s"s %s=%sR (R+R/R RR'RR(R"R-tqnameR5R.R2R((s!..\python\lib\xml\sax\saxutils.pytstartElementNSs *cCs|jd|j|dS(Ns(R+R/(R"R-R8((s!..\python\lib\xml\sax\saxutils.pyt endElementNSscCs|jt|dS(N(R+R(R"tcontent((s!..\python\lib\xml\sax\saxutils.pyt charactersscCs|j|dS(N(R+(R"R;((s!..\python\lib\xml\sax\saxutils.pytignorableWhitespacescCs|jd||fdS(Ns (R+(R"ttargetR ((s!..\python\lib\xml\sax\saxutils.pytprocessingInstructionsN(t__name__t __module__RRR+R/R0R3R4R6R7R9R:R<R=R?(((s!..\python\lib\xml\sax\saxutils.pyRTs           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 XMLReaderRt_parent(R"tparent((s!..\python\lib\xml\sax\saxutils.pyRscCs|jj|dS(N(t _err_handlerterror(R"t exception((s!..\python\lib\xml\sax\saxutils.pyRHscCs|jj|dS(N(RGt fatalError(R"RI((s!..\python\lib\xml\sax\saxutils.pyRJscCs|jj|dS(N(RGtwarning(R"RI((s!..\python\lib\xml\sax\saxutils.pyRKscCs|jj|dS(N(t _cont_handlertsetDocumentLocator(R"tlocator((s!..\python\lib\xml\sax\saxutils.pyRMscCs|jjdS(N(RLR0(R"((s!..\python\lib\xml\sax\saxutils.pyR0scCs|jjdS(N(RLt endDocument(R"((s!..\python\lib\xml\sax\saxutils.pyROscCs|jj||dS(N(RLR3(R"R.R2((s!..\python\lib\xml\sax\saxutils.pyR3scCs|jj|dS(N(RLR4(R"R.((s!..\python\lib\xml\sax\saxutils.pyR4scCs|jj||dS(N(RLR6(R"R-R5((s!..\python\lib\xml\sax\saxutils.pyR6scCs|jj|dS(N(RLR7(R"R-((s!..\python\lib\xml\sax\saxutils.pyR7scCs|jj|||dS(N(RLR9(R"R-R8R5((s!..\python\lib\xml\sax\saxutils.pyR9scCs|jj||dS(N(RLR:(R"R-R8((s!..\python\lib\xml\sax\saxutils.pyR:scCs|jj|dS(N(RLR<(R"R;((s!..\python\lib\xml\sax\saxutils.pyR<scCs|jj|dS(N(RLR=(R"tchars((s!..\python\lib\xml\sax\saxutils.pyR=scCs|jj||dS(N(RLR?(R"R>R ((s!..\python\lib\xml\sax\saxutils.pyR?scCs|jj|dS(N(RLt skippedEntity(R"R-((s!..\python\lib\xml\sax\saxutils.pyRQscCs|jj|||dS(N(t _dtd_handlert notationDecl(R"R-tpublicIdtsystemId((s!..\python\lib\xml\sax\saxutils.pyRSscCs|jj||||dS(N(RRtunparsedEntityDecl(R"R-RTRUtndata((s!..\python\lib\xml\sax\saxutils.pyRVscCs|jj||S(N(t _ent_handlert resolveEntity(R"RTRU((s!..\python\lib\xml\sax\saxutils.pyRYscCsT|jj||jj||jj||jj||jj|dS(N(REtsetContentHandlertsetErrorHandlertsetEntityResolvert setDTDHandlertparse(R"tsource((s!..\python\lib\xml\sax\saxutils.pyR^s cCs|jj|dS(N(REt setLocale(R"tlocale((s!..\python\lib\xml\sax\saxutils.pyR`scCs|jj|S(N(REt getFeature(R"R-((s!..\python\lib\xml\sax\saxutils.pyRbscCs|jj||dS(N(REt setFeature(R"R-tstate((s!..\python\lib\xml\sax\saxutils.pyRcscCs|jj|S(N(REt getProperty(R"R-((s!..\python\lib\xml\sax\saxutils.pyRe scCs|jj||dS(N(REt setProperty(R"R-R((s!..\python\lib\xml\sax\saxutils.pyRf scCs|jS(N(RE(R"((s!..\python\lib\xml\sax\saxutils.pyt getParentscCs ||_dS(N(RE(R"RF((s!..\python\lib\xml\sax\saxutils.pyt setParentsN( R@RAt__doc__RRRHRJRKRMR0ROR3R4R6R7R9R:R<R=R?RQRSRVRYR^R`RbRcReRfRgRh(((s!..\python\lib\xml\sax\saxutils.pyRBs:                           tcCs;t|tkr$tj|}nSt|drw|}tj}|j|t|drw|j|jqwn|jdkr7|j }t j j t j j|}t j j||}t j j|r|j|t|d}n.|jtj||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 _StringTypesRCt InputSourcethasattrt setByteStreamt setSystemIdR-t getByteStreamRt getSystemIdtostpathtdirnametnormpathtjointisfiletopenturlparseturljointurllibturlopen(R_tbasetftsysidtbaseheadt sysidfilename((s!..\python\lib\xml\sax\saxutils.pytprepare_input_sources&    (RiRuR|R~ttypesRRCt StringTypet UnicodeTypeRntAttributeErrortcodecsRR)t ImportErrorR RRRRRRDRBR(((s!..\python\lib\xml\sax\saxutils.pyts(0         Wo