ok

Mini Shell

Direktori : /opt/alt/python35/lib64/python3.5/xml/sax/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/xml/sax/__pycache__/saxutils.cpython-35.opt-1.pyc



B�Ma�/�@s�dZddlZddlZddlZddlZddlZddlmZddlm	Z	dd�Z
idd	�Zid
d�Zidd
�Z
dd�ZGdd�dej�ZGdd�de	j�Zddd�ZdS)znA library of useful helper classes to the SAX classes, for the
convenience of application and driver writers.
�N�)�handler)�	xmlreadercCs3x,|j�D]\}}|j||�}q
W|S)z2Replace substrings of a string using a dictionary.)�items�replace)�s�d�key�value�r�5/opt/alt/python35/lib64/python3.5/xml/sax/saxutils.py�__dict_replacesr
cCsO|jdd�}|jdd�}|jdd�}|rKt||�}|S)z�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.
    �&z&amp;�>z&gt;�<z&lt;)rr
)�data�entitiesrrr�escapes	rcCsI|jdd�}|jdd�}|r9t||�}|jdd�S)a
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.
    z&lt;rz&gt;rz&amp;r)rr
)rrrrr�unescape"s
rcCs�|j�}|jddddddi�t||�}d|krxd|krkd	|jdd
�}q�d|}n
d	|}|S)a�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.
    �
z&#10;�
z&#13;�	z&#9;�"�'z"%s"z&quot;z'%s')�copy�updaterr)rrrrr�	quoteattr0s

rcs�dkrddl}|jSt�tj�r5�St�tjtjf�rT�St�tj�r�G�fdd�d�}|�}dd�|_	nXtj
�}dd�|_�j|_y�j
|_
�j|_Wntk
r�YnXtj|d|dd	d
ddd
�S)Nrcs+eZdZ�jZ�fdd�ZdS)z _gettextwriter.<locals>._wrappercs
t�|�S)N)�getattr)�self�name)�outrr�__getattr__[sz,_gettextwriter.<locals>._wrapper.__getattr__N)�__name__�
__module__�__qualname__�	__class__r!r)r rr�_wrapperYs	r&cSsdS)Nrrrrr�<lambda>^sz _gettextwriter.<locals>.<lambda>cSsdS)NTrrrrrr'cs�encoding�errors�xmlcharrefreplace�newlinerZ
write_throughT)�sys�stdout�
isinstance�io�
TextIOBase�codecs�StreamWriter�StreamReaderWriter�	RawIOBase�close�BufferedIOBase�writable�write�seekable�tell�AttributeError�
TextIOWrapper)r r(r,r&�bufferr)r r�_gettextwriterHs.	
r>c@s�eZdZddddd�Zdd�Zddd	�Zd
d�Zdd
�Zdd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS) �XMLGeneratorNz
iso-8859-1FcCs{tjj|�t||�}|j|_|j|_ig|_|jd|_	g|_
||_||_d|_
dS)NrF���)r�ContentHandler�__init__r>r8�_write�flush�_flush�_ns_contexts�_current_context�_undeclared_ns_maps�	_encoding�_short_empty_elements�_pending_start_element)rr r(Zshort_empty_elementsrrrrBss			zXMLGenerator.__init__cCsU|drMd|dkr&d|dS|j|d}|rM|d|dS|dS)z7Builds a qualified name from a (ns_url, localname) pairrz$http://www.w3.org/XML/1998/namespacezxml:r�:)rG)rr�prefixrrr�_qnames
zXMLGenerator._qnamecCs#|jr|jd�d|_dS)NrF)rKrC)r�
endElementrrr�_finish_pending_start_element�s	
z*XMLGenerator._finish_pending_start_elementcCs|jd|j�dS)Nz$<?xml version="1.0" encoding="%s"?>
)rCrI)rrrr�
startDocument�s	zXMLGenerator.startDocumentcCs|j�dS)N)rE)rrrr�endDocument�szXMLGenerator.endDocumentcCs@|jj|jj��||j|<|jj||f�dS)N)rF�appendrGrrH)rrM�urirrr�startPrefixMapping�s
zXMLGenerator.startPrefixMappingcCs|jd|_|jd=dS)Nrr@r@)rFrG)rrMrrr�endPrefixMapping�szXMLGenerator.endPrefixMappingcCs{|j�|jd|�x7|j�D])\}}|jd|t|�f�q(W|jrjd|_n
|jd�dS)Nrz %s=%sTr)rPrCrrrJrK)rr�attrsr
rrr�startElement�s
!	zXMLGenerator.startElementcCs7|jr"|jd�d|_n|jd|�dS)Nz/>Fz</%s>)rKrC)rrrrrrO�s	
zXMLGenerator.endElementcCs�|j�|jd|j|��xH|jD]=\}}|rZ|jd||f�q.|jd|�q.Wg|_x@|j�D]2\}}|jd|j|�t|�f�q�W|jr�d|_n
|jd�dS)Nrz xmlns:%s="%s"z xmlns="%s"z %s=%sTr)rPrCrNrHrrrJrK)rr�qnamerWrMrTr
rrr�startElementNS�s
	*	zXMLGenerator.startElementNScCs@|jr"|jd�d|_n|jd|j|��dS)Nz/>Fz</%s>)rKrCrN)rrrYrrr�endElementNS�s	
zXMLGenerator.endElementNScCsH|rD|j�t|t�s1t||j�}|jt|��dS)N)rPr.�strrIrCr)r�contentrrr�
characters�s

zXMLGenerator.characterscCsB|r>|j�t|t�s1t||j�}|j|�dS)N)rPr.r\rIrC)rr]rrr�ignorableWhitespace�s

z XMLGenerator.ignorableWhitespacecCs%|j�|jd||f�dS)Nz	<?%s %s?>)rPrC)r�targetrrrr�processingInstruction�s
z"XMLGenerator.processingInstruction)r"r#r$rBrNrPrQrRrUrVrXrOrZr[r^r_rarrrrr?qs
r?c@sieZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�ZdS);�
XMLFilterBaseaYThis 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.NcCstjj|�||_dS)N)r�	XMLReaderrB�_parent)r�parentrrrrB�szXMLFilterBase.__init__cCs|jj|�dS)N)�_err_handler�error)r�	exceptionrrrrg�szXMLFilterBase.errorcCs|jj|�dS)N)rf�
fatalError)rrhrrrri�szXMLFilterBase.fatalErrorcCs|jj|�dS)N)rf�warning)rrhrrrrj�szXMLFilterBase.warningcCs|jj|�dS)N)�
_cont_handler�setDocumentLocator)rZlocatorrrrrl�sz XMLFilterBase.setDocumentLocatorcCs|jj�dS)N)rkrQ)rrrrrQszXMLFilterBase.startDocumentcCs|jj�dS)N)rkrR)rrrrrRszXMLFilterBase.endDocumentcCs|jj||�dS)N)rkrU)rrMrTrrrrUsz XMLFilterBase.startPrefixMappingcCs|jj|�dS)N)rkrV)rrMrrrrV	szXMLFilterBase.endPrefixMappingcCs|jj||�dS)N)rkrX)rrrWrrrrXszXMLFilterBase.startElementcCs|jj|�dS)N)rkrO)rrrrrrOszXMLFilterBase.endElementcCs|jj|||�dS)N)rkrZ)rrrYrWrrrrZszXMLFilterBase.startElementNScCs|jj||�dS)N)rkr[)rrrYrrrr[szXMLFilterBase.endElementNScCs|jj|�dS)N)rkr^)rr]rrrr^szXMLFilterBase.characterscCs|jj|�dS)N)rkr_)r�charsrrrr_sz!XMLFilterBase.ignorableWhitespacecCs|jj||�dS)N)rkra)rr`rrrrrasz#XMLFilterBase.processingInstructioncCs|jj|�dS)N)rk�
skippedEntity)rrrrrrn!szXMLFilterBase.skippedEntitycCs|jj|||�dS)N)�_dtd_handler�notationDecl)rr�publicId�systemIdrrrrp&szXMLFilterBase.notationDeclcCs|jj||||�dS)N)ro�unparsedEntityDecl)rrrqrrZndatarrrrs)sz XMLFilterBase.unparsedEntityDeclcCs|jj||�S)N)Z_ent_handler�
resolveEntity)rrqrrrrrrt.szXMLFilterBase.resolveEntitycCsT|jj|�|jj|�|jj|�|jj|�|jj|�dS)N)rdZsetContentHandlerZsetErrorHandlerZsetEntityResolverZ
setDTDHandler�parse)r�sourcerrrru3s
zXMLFilterBase.parsecCs|jj|�dS)N)rd�	setLocale)rZlocalerrrrw:szXMLFilterBase.setLocalecCs|jj|�S)N)rd�
getFeature)rrrrrrx=szXMLFilterBase.getFeaturecCs|jj||�dS)N)rd�
setFeature)rr�staterrrry@szXMLFilterBase.setFeaturecCs|jj|�S)N)rd�getProperty)rrrrrr{CszXMLFilterBase.getPropertycCs|jj||�dS)N)rd�setProperty)rrr
rrrr|FszXMLFilterBase.setPropertycCs|jS)N)rd)rrrr�	getParentKszXMLFilterBase.getParentcCs
||_dS)N)rd)rrerrr�	setParentNszXMLFilterBase.setParent) r"r#r$�__doc__rBrgrirjrlrQrRrUrVrXrOrZr[r^r_rarnrprsrtrurwrxryr{r|r}r~rrrrrb�s:rb�cCs�t|t�r!tj|�}n�t|d�r�|}tj�}t|jd�t�rj|j|�n
|j|�t|d�r�t|jt�r�|j	|j�|j
�dkr}|j�dkr}|j�}t
jjt
jj|��}t
jj||�}t
jj|�r<|j	|�t|d�}n4|j	tjj||��tjj|j��}|j|�|S)z�This function takes an InputSource and an optional base URL and
    returns a fully resolved InputSource object ready for reading.�readrrN�rb)r.r\rZInputSource�hasattrr�ZsetCharacterStreamZ
setByteStreamrZsetSystemIdZgetCharacterStreamZ
getByteStreamZgetSystemId�os�path�dirname�normpath�join�isfile�open�urllibruZurljoinZrequestZurlopen)rv�base�fZsysidZbaseheadZ
sysidfilenamerrr�prepare_input_sourceSs*
!$

r�)rr�Zurllib.parser�Zurllib.requestr/r1r�rrr
rrrr>rAr?rcrbr�rrrr�<module>s$)so

Zerion Mini Shell 1.0