Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/xml/sax/saxutils.pyo

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c@sdZddlZddlZddlZddlZddlZddlZddlZddlZyej	ej
gZWnek
r�ej	gZnXd�Z
id�Zid�Zid�Zd�Zdejfd	��YZd
ejfd��YZdd
�ZdS(snA library of useful helper classes to the SAX classes, for the
convenience of application and driver writers.
i�NcCs3x,|j�D]\}}|j||�}q
W|S(s2Replace substrings of a string using a dictionary.(titemstreplace(tstdtkeytvalue((s&/sys/lib/python2.7/xml/sax/saxutils.pyt__dict_replacescCsR|jdd�}|jdd�}|jdd�}|rNt||�}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&/sys/lib/python2.7/xml/sax/saxutils.pytescapes	cCsL|jdd�}|jdd�}|r<t||�}n|jdd�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&/sys/lib/python2.7/xml/sax/saxutils.pytunescape's
cCs�|j�}|jidd6dd6dd6�t||�}d|kr{d|krnd	|jdd
�}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&/sys/lib/python2.7/xml/sax/saxutils.pyt	quoteattr5s"

cs�|dkr$ddl}|j}nt|tj�rTtj|�}d�|_nTtj�}d�|_|j	|_	y|j
|_
|j|_Wntk
r�nXdtj
f�fd��Y��|d|ddd	d
�S(Ni�cSsdS(N(tNone(((s&/sys/lib/python2.7/xml/sax/saxutils.pyt<lambda>VscSstS(N(tTrue(((s&/sys/lib/python2.7/xml/sax/saxutils.pyR[stUnbufferedTextIOWrappercseZ�fd�ZRS(cs$t�|�j|�|j�dS(N(tsupertwritetflush(tselfR(R(s&/sys/lib/python2.7/xml/sax/saxutils.pyRfs(t__name__t
__module__R((R(s&/sys/lib/python2.7/xml/sax/saxutils.pyRestencodingterrorstxmlcharrefreplacetnewlines
(Rtsyststdoutt
isinstancetiot	RawIOBasetBufferedIOBasetclosetwritableRtseekablettelltAttributeErrort
TextIOWrapper(toutRR!tbuffer((Rs&/sys/lib/python2.7/xml/sax/saxutils.pyt_gettextwriterMs$
tXMLGeneratorcBs�eZddd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�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&/sys/lib/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&/sys/lib/python2.7/xml/sax/saxutils.pyt_qnameys
cCs|jd|j�dS(Nu$<?xml version="1.0" encoding="%s"?>
(R4R9(R((s&/sys/lib/python2.7/xml/sax/saxutils.pyt
startDocument�s	cCs|j�dS(N(R5(R((s&/sys/lib/python2.7/xml/sax/saxutils.pytendDocument�scCs@|jj|jj��||j|<|jj||f�dS(N(R6tappendR7RR8(RR<turi((s&/sys/lib/python2.7/xml/sax/saxutils.pytstartPrefixMapping�s
cCs|jd|_|jd=dS(Ni�(R6R7(RR<((s&/sys/lib/python2.7/xml/sax/saxutils.pytendPrefixMapping�scCs\|jd|�x7|j�D])\}}|jd|t|�f�qW|jd�dS(Nu<u %s=%su>(R4RR(RR;tattrsR((s&/sys/lib/python2.7/xml/sax/saxutils.pytstartElement�s!cCs|jd|�dS(Nu</%s>(R4(RR;((s&/sys/lib/python2.7/xml/sax/saxutils.pyt
endElement�scCs�|jd|j|��xH|jD]=\}}|rP|jd||f�q$|jd|�q$Wg|_x@|j�D]2\}}|jd|j|�t|�f�q{W|jd�dS(Nu<u xmlns:%s="%s"u xmlns="%s"u %s=%su>(R4R=R8RR(RR;tqnameRDR<RAR((s&/sys/lib/python2.7/xml/sax/saxutils.pytstartElementNS�s	*cCs|jd|j|��dS(Nu</%s>(R4R=(RR;RG((s&/sys/lib/python2.7/xml/sax/saxutils.pytendElementNS�scCs;t|t�s$t||j�}n|jt|��dS(N(R#tunicodeR9R4R(Rtcontent((s&/sys/lib/python2.7/xml/sax/saxutils.pyt
characters�scCs5t|t�s$t||j�}n|j|�dS(N(R#RJR9R4(RRK((s&/sys/lib/python2.7/xml/sax/saxutils.pytignorableWhitespace�scCs|jd||f�dS(Nu	<?%s %s?>(R4(RttargetR
((s&/sys/lib/python2.7/xml/sax/saxutils.pytprocessingInstruction�sN(RRRR3R=R>R?RBRCRERFRHRIRLRMRO(((s&/sys/lib/python2.7/xml/sax/saxutils.pyR0ms
											t
XMLFilterBasecBs
eZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�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|�||_dS(N(t	xmlreadert	XMLReaderR3t_parent(Rtparent((s&/sys/lib/python2.7/xml/sax/saxutils.pyR3�scCs|jj|�dS(N(t_err_handlerterror(Rt	exception((s&/sys/lib/python2.7/xml/sax/saxutils.pyRV�scCs|jj|�dS(N(RUt
fatalError(RRW((s&/sys/lib/python2.7/xml/sax/saxutils.pyRX�scCs|jj|�dS(N(RUtwarning(RRW((s&/sys/lib/python2.7/xml/sax/saxutils.pyRY�scCs|jj|�dS(N(t
_cont_handlertsetDocumentLocator(Rtlocator((s&/sys/lib/python2.7/xml/sax/saxutils.pyR[�scCs|jj�dS(N(RZR>(R((s&/sys/lib/python2.7/xml/sax/saxutils.pyR>�scCs|jj�dS(N(RZR?(R((s&/sys/lib/python2.7/xml/sax/saxutils.pyR?�scCs|jj||�dS(N(RZRB(RR<RA((s&/sys/lib/python2.7/xml/sax/saxutils.pyRB�scCs|jj|�dS(N(RZRC(RR<((s&/sys/lib/python2.7/xml/sax/saxutils.pyRC�scCs|jj||�dS(N(RZRE(RR;RD((s&/sys/lib/python2.7/xml/sax/saxutils.pyRE�scCs|jj|�dS(N(RZRF(RR;((s&/sys/lib/python2.7/xml/sax/saxutils.pyRF�scCs|jj|||�dS(N(RZRH(RR;RGRD((s&/sys/lib/python2.7/xml/sax/saxutils.pyRH�scCs|jj||�dS(N(RZRI(RR;RG((s&/sys/lib/python2.7/xml/sax/saxutils.pyRI�scCs|jj|�dS(N(RZRL(RRK((s&/sys/lib/python2.7/xml/sax/saxutils.pyRL�scCs|jj|�dS(N(RZRM(Rtchars((s&/sys/lib/python2.7/xml/sax/saxutils.pyRM�scCs|jj||�dS(N(RZRO(RRNR
((s&/sys/lib/python2.7/xml/sax/saxutils.pyRO�scCs|jj|�dS(N(RZt
skippedEntity(RR;((s&/sys/lib/python2.7/xml/sax/saxutils.pyR^scCs|jj|||�dS(N(t_dtd_handlertnotationDecl(RR;tpublicIdtsystemId((s&/sys/lib/python2.7/xml/sax/saxutils.pyR`scCs|jj||||�dS(N(R_tunparsedEntityDecl(RR;RaRbtndata((s&/sys/lib/python2.7/xml/sax/saxutils.pyRc	scCs|jj||�S(N(t_ent_handlert
resolveEntity(RRaRb((s&/sys/lib/python2.7/xml/sax/saxutils.pyRfscCsT|jj|�|jj|�|jj|�|jj|�|jj|�dS(N(RStsetContentHandlertsetErrorHandlertsetEntityResolvert
setDTDHandlertparse(Rtsource((s&/sys/lib/python2.7/xml/sax/saxutils.pyRks
cCs|jj|�dS(N(RSt	setLocale(Rtlocale((s&/sys/lib/python2.7/xml/sax/saxutils.pyRmscCs|jj|�S(N(RSt
getFeature(RR;((s&/sys/lib/python2.7/xml/sax/saxutils.pyRoscCs|jj||�dS(N(RSt
setFeature(RR;tstate((s&/sys/lib/python2.7/xml/sax/saxutils.pyRp scCs|jj|�S(N(RStgetProperty(RR;((s&/sys/lib/python2.7/xml/sax/saxutils.pyRr#scCs|jj||�dS(N(RStsetProperty(RR;R((s&/sys/lib/python2.7/xml/sax/saxutils.pyRs&scCs|jS(N(RS(R((s&/sys/lib/python2.7/xml/sax/saxutils.pyt	getParent+scCs
||_dS(N(RS(RRT((s&/sys/lib/python2.7/xml/sax/saxutils.pyt	setParent.sN( RRt__doc__RR3RVRXRYR[R>R?RBRCRERFRHRIRLRMROR^R`RcRfRkRmRoRpRrRsRtRu(((s&/sys/lib/python2.7/xml/sax/saxutils.pyRP�s:																										tcCst|�tkr$tj|�}nSt|d�rw|}tj�}|j|�t|d�rw|j|j�qwn|j�dkry|j
�}tjj
tjj|��}tj�}t|t�rt|t�sdy|j|�}Wqtk
r|j|�}qXqdnHt|t�rdy|j|�}Wqdtk
r`|j|�}qdXntjj||�}tjj|�}Wntk
r�t}nX|r�|j|�t|d�}n4|jtj||j
���tj|j
��}|j|�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_StringTypesRQtInputSourcethasattrt
setByteStreamtsetSystemIdR;t
getByteStreamRtgetSystemIdtostpathtdirnametnormpathR!tgetfilesystemencodingR#RJtdecodetUnicodeDecodeErrortencodetjointisfiletUnicodeErrortFalsetopenturlparseturljointurllibturlopen(RltbasetftsysidtbaseheadRt
sysidfilenameR�((s&/sys/lib/python2.7/xml/sax/saxutils.pytprepare_input_source3sF





(RvR�R�R�ttypesR$R!R1RQt
StringTypetUnicodeTypeR{R+RRR
RR/R2R0RRRPR�(((s&/sys/lib/python2.7/xml/sax/saxutils.pyt<module>s"0
		 Wo

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.