ok

Mini Shell

Direktori : /proc/thread-self/root/lib64/python3.6/xml/sax/__pycache__/
Upload File :
Current File : //proc/thread-self/root/lib64/python3.6/xml/sax/__pycache__/saxutils.cpython-36.pyc

3


 \�/�@s�dZddlZddlZddlZddlZddlZddlmZddlm	Z	dd�Z
ifdd	�Zifd
d�Zifd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)�	xmlreadercCs&x |j�D]\}}|j||�}q
W|S)z2Replace substrings of a string using a dictionary.)�items�replace)�s�d�key�value�r�(/usr/lib64/python3.6/xml/sax/saxutils.py�__dict_replacesr
cCs6|jdd�}|jdd�}|jdd�}|r2t||�}|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	
rcCs2|jdd�}|jdd�}|r&t||�}|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�}|jdddd��t||�}d|krPd|krFd|jdd�}qXd	|}nd|}|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�r&�St�tjtjf�r<�St�tj�rlG�fdd�d�}|�}dd�|_	nDtj
�}dd�|_�j|_y�j
|_
�j|_Wntk
r�YnXtj||ddd	d
�S)NrcseZdZ�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�_wrapperYsr&cSsdS)Nrrrrr�<lambda>^sz _gettextwriter.<locals>.<lambda>cSsdS)NTrrrrrr'cs�xmlcharrefreplacerT)�encoding�errors�newline�
write_through)�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�eZdZd dd�Zdd�Zd!dd	�Zd
d�Zdd
�Zdd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)"�XMLGeneratorN�
iso-8859-1FcCsVtjj|�t||�}|j|_|j|_ig|_|jd|_	g|_
||_||_d|_
dS)NrF���)r�ContentHandler�__init__r?r9�_write�flush�_flush�_ns_contexts�_current_context�_undeclared_ns_maps�	_encoding�_short_empty_elements�_pending_start_element)rr r)Zshort_empty_elementsrrrrDss
zXMLGenerator.__init__cCsJ|drBd|dkr d|dS|j|d}|rB|d|dS|dS)z7Builds a qualified name from a (ns_url, localname) pairrz$http://www.w3.org/XML/1998/namespacezxml:r�:)rI)rr�prefixrrr�_qnameszXMLGenerator._qnamecCs|jr|jd�d|_dS)NrF)rMrE)r�
endElementrrr�_finish_pending_start_element�s
z*XMLGenerator._finish_pending_start_elementcCs|jd|j�dS)Nz$<?xml version="1.0" encoding="%s"?>
)rErK)rrrr�
startDocument�szXMLGenerator.startDocumentcCs|j�dS)N)rG)rrrr�endDocument�szXMLGenerator.endDocumentcCs0|jj|jj��||j|<|jj||f�dS)N)rH�appendrIrrJ)rrO�urirrr�startPrefixMapping�s
zXMLGenerator.startPrefixMappingcCs|jd|_|jd=dS)NrrBrB)rHrI)rrOrrr�endPrefixMapping�szXMLGenerator.endPrefixMappingcCs^|j�|jd|�x*|j�D]\}}|jd|t|�f�q W|jrPd|_n
|jd�dS)Nrz %s=%sTr)rRrErrrLrM)rr�attrsr
rrr�startElement�szXMLGenerator.startElementcCs*|jr|jd�d|_n|jd|�dS)Nz/>Fz</%s>)rMrE)rrrrrrQ�s
zXMLGenerator.endElementcCs�|j�|jd|j|��x8|jD].\}}|rD|jd||f�q$|jd|�q$Wg|_x0|j�D]$\}}|jd|j|�t|�f�qfW|jr�d|_n
|jd�dS)Nrz xmlns:%s="%s"z xmlns="%s"z %s=%sTr)rRrErPrJrrrLrM)rr�qnamerYrOrVr
rrr�startElementNS�s zXMLGenerator.startElementNScCs0|jr|jd�d|_n|jd|j|��dS)Nz/>Fz</%s>)rMrErP)rrr[rrr�endElementNS�s
zXMLGenerator.endElementNScCs4|r0|j�t|t�s"t||j�}|jt|��dS)N)rRr/�strrKrEr)r�contentrrr�
characters�s

zXMLGenerator.characterscCs0|r,|j�t|t�s"t||j�}|j|�dS)N)rRr/r^rKrE)rr_rrr�ignorableWhitespace�s

z XMLGenerator.ignorableWhitespacecCs|j�|jd||f�dS)Nz	<?%s %s?>)rRrE)r�targetrrrr�processingInstruction�sz"XMLGenerator.processingInstruction)NrAF)F)r"r#r$rDrPrRrSrTrWrXrZrQr\r]r`rarcrrrrr@qs


r@c@s�eZdZdZd;dd�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�	XMLReaderrD�_parent)r�parentrrrrD�szXMLFilterBase.__init__cCs|jj|�dS)N)�_err_handler�error)r�	exceptionrrrri�szXMLFilterBase.errorcCs|jj|�dS)N)rh�
fatalError)rrjrrrrk�szXMLFilterBase.fatalErrorcCs|jj|�dS)N)rh�warning)rrjrrrrl�szXMLFilterBase.warningcCs|jj|�dS)N)�
_cont_handler�setDocumentLocator)rZlocatorrrrrn�sz XMLFilterBase.setDocumentLocatorcCs|jj�dS)N)rmrS)rrrrrSszXMLFilterBase.startDocumentcCs|jj�dS)N)rmrT)rrrrrTszXMLFilterBase.endDocumentcCs|jj||�dS)N)rmrW)rrOrVrrrrWsz XMLFilterBase.startPrefixMappingcCs|jj|�dS)N)rmrX)rrOrrrrX	szXMLFilterBase.endPrefixMappingcCs|jj||�dS)N)rmrZ)rrrYrrrrZszXMLFilterBase.startElementcCs|jj|�dS)N)rmrQ)rrrrrrQszXMLFilterBase.endElementcCs|jj|||�dS)N)rmr\)rrr[rYrrrr\szXMLFilterBase.startElementNScCs|jj||�dS)N)rmr])rrr[rrrr]szXMLFilterBase.endElementNScCs|jj|�dS)N)rmr`)rr_rrrr`szXMLFilterBase.characterscCs|jj|�dS)N)rmra)r�charsrrrrasz!XMLFilterBase.ignorableWhitespacecCs|jj||�dS)N)rmrc)rrbrrrrrcsz#XMLFilterBase.processingInstructioncCs|jj|�dS)N)rm�
skippedEntity)rrrrrrp!szXMLFilterBase.skippedEntitycCs|jj|||�dS)N)�_dtd_handler�notationDecl)rr�publicId�systemIdrrrrr&szXMLFilterBase.notationDeclcCs|jj||||�dS)N)rq�unparsedEntityDecl)rrrsrtZndatarrrru)sz XMLFilterBase.unparsedEntityDeclcCs|jj||�S)N)Z_ent_handler�
resolveEntity)rrsrtrrrrv.szXMLFilterBase.resolveEntitycCs@|jj|�|jj|�|jj|�|jj|�|jj|�dS)N)rfZsetContentHandlerZsetErrorHandlerZsetEntityResolverZ
setDTDHandler�parse)r�sourcerrrrw3s
zXMLFilterBase.parsecCs|jj|�dS)N)rf�	setLocale)rZlocalerrrry:szXMLFilterBase.setLocalecCs|jj|�S)N)rf�
getFeature)rrrrrrz=szXMLFilterBase.getFeaturecCs|jj||�dS)N)rf�
setFeature)rr�staterrrr{@szXMLFilterBase.setFeaturecCs|jj|�S)N)rf�getProperty)rrrrrr}CszXMLFilterBase.getPropertycCs|jj||�dS)N)rf�setProperty)rrr
rrrr~FszXMLFilterBase.setPropertycCs|jS)N)rf)rrrr�	getParentKszXMLFilterBase.getParentcCs
||_dS)N)rf)rrgrrr�	setParentNszXMLFilterBase.setParent)N) r"r#r$�__doc__rDrirkrlrnrSrTrWrXrZrQr\r]r`rarcrprrrurvrwryrzr{r}r~rr�rrrrrd�s:
rd�cCst|t�rtj|�}n^t|d�rt|}tj�}t|jd�t�rH|j|�n
|j|�t|d�rtt|jt�rt|j	|j�|j
�dko�|j�dk�r|j�}t
jjt
jj|��}t
jj||�}t
jj|�r�|j	|�t|d�}n$|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�urllibrwZurljoinZrequestZurlopen)rx�base�fZsysidZbaseheadZ
sysidfilenamerrr�prepare_input_sourceSs*




r�)r�)r�r�Zurllib.parser�Zurllib.requestr0r2r�rrr
rrrr?rCr@rerdr�rrrr�<module>s)so

Zerion Mini Shell 1.0