Files
PowerToys/PythonHome/Lib/xml/sax/saxutils.pyc

72 lines
14 KiB
Plaintext
Raw Normal View History

2014-07-09 18:15:23 +08:00
<03>
<EFBFBD>W`Sc@sdZddlZddlZddlZddlZddlZddlZddlZddlZyej ej
gZ Wne k
r<>ej gZ nXd<00>Z id<00>Zid<00>Zid<00>Zd<00>Zdejfd <00><00>YZd
ejfd <00><00>YZd d <00>ZdS(snA library of useful helper classes to the SAX classes, for the
convenience of application and driver writers.
i<EFBFBD><EFBFBD><EFBFBD><EFBFBD>NcCs3x,|j<00>D]\}}|j||<00>}q W|S(s2Replace substrings of a string using a dictionary.(titemstreplace(tstdtkeytvalue((s#C:\Python27\lib\xml\sax\saxutils.pyt__dict_replacescCsR|jdd<00>}|jdd<00>}|jdd<00>}|rNt||<00>}n|S(s<>Escape &, <, 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&amp;t>s&gt;t<s&lt;(RR(tdatatentities((s#C:\Python27\lib\xml\sax\saxutils.pytescapes cCsL|jdd<00>}|jdd<00>}|r<t||<00>}n|jdd<00>S(s
Unescape &amp;, &lt;, and &gt; in a string of data.
You can unescape 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&lt;R s&gt;Rs&amp;R(RR(R
R ((s#C:\Python27\lib\xml\sax\saxutils.pytunescape's
cCs<>|j<00>}|jidd6dd6dd6<>t||<00>}d|kr{d|krnd |jdd
<00>}q<>d |}n
d |}|S( s<>Escape and quote an attribute value.
Escape &, <, and > 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&#10;s
s&#13;s s&#9;s t"t's"%s"s&quot;s'%s'(tcopytupdateR R(R
R ((s#C:\Python27\lib\xml\sax\saxutils.pyt quoteattr5s "   
cs<>|dkr$ddl}|j}nt|tj<00>rTtj|<00>}d<00>|_nTtj<00>}d<00>|_|j |_ y|j
|_
|j |_ Wnt k
r<>nXdtj f<00>fd<00><00>Y<><00>|d|ddd d
<00>S( Ni<4E><69><EFBFBD><EFBFBD>cSsdS(N(tNone(((s#C:\Python27\lib\xml\sax\saxutils.pyt<lambda>VscSstS(N(tTrue(((s#C:\Python27\lib\xml\sax\saxutils.pyR[stUnbufferedTextIOWrappercseZ<00>fd<00>ZRS(cs$t<00>|<00>j|<00>|j<00>dS(N(tsupertwritetflush(tselfR(R(s#C:\Python27\lib\xml\sax\saxutils.pyRfs(t__name__t
__module__R((R(s#C:\Python27\lib\xml\sax\saxutils.pyRestencodingterrorstxmlcharrefreplacetnewlines
(Rtsyststdoutt
isinstancetiot RawIOBasetBufferedIOBasetclosetwritableRtseekablettelltAttributeErrort TextIOWrapper(toutRR!tbuffer((Rs#C:\Python27\lib\xml\sax\saxutils.pyt_gettextwriterMs$        t XMLGeneratorcBs<>eZddd<00>Zd<00>Zd<00>Zd<00>Zd<00>Zd<00>Zd<00>Z d<00>Z
d <00>Z d
<00>Z d <00>Z d <00>Zd <00>ZRS(s
iso-8859-1cCsitjj|<00>t||<00>}|j|_|j|_ig|_|jd|_ g|_
||_ dS(Ni<4E><69><EFBFBD><EFBFBD>( thandlertContentHandlert__init__R/Rt_writeRt_flusht _ns_contextst_current_contextt_undeclared_ns_mapst _encoding(RR-R((s#C:\Python27\lib\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#C:\Python27\lib\xml\sax\saxutils.pyt_qnameys
 cCs|jd|j<16>dS(Nu$<?xml version="1.0" encoding="%s"?>
(R4R9(R((s#C:\Python27\lib\xml\sax\saxutils.pyt startDocument<6E>s cCs|j<00>dS(N(R5(R((s#C:\Python27\lib\xml\sax\saxutils.pyt endDocument<6E>scCs@|jj|jj<00><00>||j|<|jj||f<00>dS(N(R6tappendR7RR8(RR<turi((s#C:\Python27\lib\xml\sax\saxutils.pytstartPrefixMapping<6E>s cCs|jd|_|jd=dS(Ni<4E><69><EFBFBD><EFBFBD>(R6R7(RR<((s#C:\Python27\lib\xml\sax\saxutils.pytendPrefixMapping<6E>scCs\|jd|<17>x7|j<00>D])\}}|jd|t|<00>f<16>qW|jd<00>dS(Nu<u %s=%su>(R4RR(RR;tattrsR((s#C:\Python27\lib\xml\sax\saxutils.pyt startElement<6E>s!cCs|jd|<16>dS(Nu</%s>(R4(RR;((s#C:\Python27\lib\xml\sax\saxutils.pyt
endElement<6E>scCs<>|jd|j|<00><17>xH|jD]=\}}|rP|jd||f<16>q$|jd|<16>q$Wg|_x@|j<00>D]2\}}|jd|j|<00>t|<00>f<16>q{W|jd<00>dS(Nu<u xmlns:%s="%s"u xmlns="%s"u %s=%su>(R4R=R8RR(RR;tqnameRDR<RAR((s#C:\Python27\lib\xml\sax\saxutils.pytstartElementNS<4E>s *cCs|jd|j|<00><16>dS(Nu</%s>(R4R=(RR;RG((s#C:\Python27\lib\xml\sax\saxutils.pyt endElementNS<4E>scCs;t|t<00>s$t||j<00>}n|jt|<00><00>dS(N(R#tunicodeR9R4R (Rtcontent((s#C:\Python27\lib\xml\sax\saxutils.pyt
characters<72>scCs5t|t<00>s$t||j<00>}n|j|<00>dS(N(R#RJR9R4(RRK((s#C:\Python27\lib\xml\sax\saxutils.pytignorableWhitespace<63>scCs|jd||f<16>dS(Nu <?%s %s?>(R4(RttargetR
((s#C:\Python27\lib\xml\sax\saxutils.pytprocessingInstruction<6F>sN(RRRR3R=R>R?RBRCRERFRHRIRLRMRO(((s#C:\Python27\lib\xml\sax\saxutils.pyR0ms
          t XMLFilterBasecBs eZdZdd<00>Zd<00>Zd<00>Zd<00>Zd<00>Zd<00>Z d<00>Z
d<00>Z d <00>Z d
<00>Z d <00>Zd <00>Zd <00>Zd<00>Zd<00>Zd<00>Zd<00>Zd<00>Zd<00>Zd<00>Zd<00>Zd<00>Zd<00>Zd<00>Zd<00>Zd<00>Zd<00>Zd<00>ZRS(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|<00>||_dS(N(t xmlreadert XMLReaderR3t_parent(Rtparent((s#C:\Python27\lib\xml\sax\saxutils.pyR3<00>scCs|jj|<00>dS(N(t _err_handlerterror(Rt exception((s#C:\Python27\lib\xml\sax\saxutils.pyRV<00>scCs|jj|<00>dS(N(RUt
fatalError(RRW((s#C:\Python27\lib\xml\sax\saxutils.pyRX<00>scCs|jj|<00>dS(N(RUtwarning(RRW((s#C:\Python27\lib\xml\sax\saxutils.pyRY<00>scCs|jj|<00>dS(N(t _cont_handlertsetDocumentLocator(Rtlocator((s#C:\Python27\lib\xml\sax\saxutils.pyR[<00>scCs|jj<00>dS(N(RZR>(R((s#C:\Python27\lib\xml\sax\saxutils.pyR><00>scCs|jj<00>dS(N(RZR?(R((s#C:\Python27\lib\xml\sax\saxutils.pyR?<00>scCs|jj||<00>dS(N(RZRB(RR<RA((s#C:\Python27\lib\xml\sax\saxutils.pyRB<00>scCs|jj|<00>dS(N(RZRC(RR<((s#C:\Python27\lib\xml\sax\saxutils.pyRC<00>scCs|jj||<00>dS(N(RZRE(RR;RD((s#C:\Python27\lib\xml\sax\saxutils.pyRE<00>scCs|jj|<00>dS(N(RZRF(RR;((s#C:\Python27\lib\xml\sax\saxutils.pyRF<00>scCs|jj|||<00>dS(N(RZRH(RR;RGRD((s#C:\Python27\lib\xml\sax\saxutils.pyRH<00>scCs|jj||<00>dS(N(RZRI(RR;RG((s#C:\Python27\lib\xml\sax\saxutils.pyRI<00>scCs|jj|<00>dS(N(RZRL(RRK((s#C:\Python27\lib\xml\sax\saxutils.pyRL<00>scCs|jj|<00>dS(N(RZRM(Rtchars((s#C:\Python27\lib\xml\sax\saxutils.pyRM<00>scCs|jj||<00>dS(N(RZRO(RRNR
((s#C:\Python27\lib\xml\sax\saxutils.pyRO<00>scCs|jj|<00>dS(N(RZt skippedEntity(RR;((s#C:\Python27\lib\xml\sax\saxutils.pyR^scCs|jj|||<00>dS(N(t _dtd_handlert notationDecl(RR;tpublicIdtsystemId((s#C:\Python27\lib\xml\sax\saxutils.pyR`scCs|jj||||<00>dS(N(R_tunparsedEntityDecl(RR;RaRbtndata((s#C:\Python27\lib\xml\sax\saxutils.pyRc scCs|jj||<00>S(N(t _ent_handlert resolveEntity(RRaRb((s#C:\Python27\lib\xml\sax\saxutils.pyRfscCsT|jj|<00>|jj|<00>|jj|<00>|jj|<00>|jj|<00>dS(N(RStsetContentHandlertsetErrorHandlertsetEntityResolvert setDTDHandlertparse(Rtsource((s#C:\Python27\lib\xml\sax\saxutils.pyRks
cCs|jj|<00>dS(N(RSt setLocale(Rtlocale((s#C:\Python27\lib\xml\sax\saxutils.pyRmscCs|jj|<00>S(N(RSt
getFeature(RR;((s#C:\Python27\lib\xml\sax\saxutils.pyRoscCs|jj||<00>dS(N(RSt
setFeature(RR;tstate((s#C:\Python27\lib\xml\sax\saxutils.pyRp scCs|jj|<00>S(N(RSt getProperty(RR;((s#C:\Python27\lib\xml\sax\saxutils.pyRr#scCs|jj||<00>dS(N(RSt setProperty(RR;R((s#C:\Python27\lib\xml\sax\saxutils.pyRs&scCs|jS(N(RS(R((s#C:\Python27\lib\xml\sax\saxutils.pyt getParent+scCs ||_dS(N(RS(RRT((s#C:\Python27\lib\xml\sax\saxutils.pyt setParent.sN( RRt__doc__RR3RVRXRYR[R>R?RBRCRERFRHRIRLRMROR^R`RcRfRkRmRoRpRrRsRtRu(((s#C:\Python27\lib\xml\sax\saxutils.pyRP<00>s:                           tcCst|<00>tkr$tj|<00>}nSt|d<00>rw|}tj<00>}|j|<00>t|d<00>rw|j|j<00>qwn|j<00>dkry|j
<00>}t j j t j j|<00><00>}tj<00>}t|t<00>rt|t<00>sdy|j|<00>}Wqtk
r|j|<00>}qXqdnHt|t<00>rdy|j|<00>}Wqdtk
r`|j|<00>}qdXnt j j||<00>}t j j|<00>}Wntk
r<>t}nX|r<>|j|<00>t|d<00>}n4|jtj||j
<00><00><00>tj|j
<00><00>}|j|<00>n|S(s<>This 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<65>((s#C:\Python27\lib\xml\sax\saxutils.pytprepare_input_source3sF       
 (RvR<>R<>R<>ttypesR$R!R1RQt
StringTypet UnicodeTypeR{R+RR R RR/R2R0RRRPR<>(((s#C:\Python27\lib\xml\sax\saxutils.pyt<module>s"0          Wo