add-determinism 0.7.3

RPM buildroot helper to strip nondeterministic bits in files
Documentation
3

�
�^�/c@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)ZsZdZkey�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.
    �&�&amp;�>�&gt;�<�&lt;�rr	��dataZentitiesrrr�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.
    rrr
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
z	z"z'z"%s"z&quot;z'%s')�copyZupdaterrrrrr�	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)Zgetattr��self�name��outrr�__getattr__[�z,_gettextwriter.<locals>._wrapper.__getattr__N)�__name__�
__module__�__qualname__Z	__class__rrrrr�_wrapperYsr#cSsdSrrrrrr�<lambda>^�z _gettextwriter.<locals>.<lambda>cSsdS)NTrrrrrr$cr%ZxmlcharrefreplacerT)�encodingZerrorsZnewlineZ
write_through)�sysZstdout�
isinstance�ioZ
TextIOBase�codecsZStreamWriterZStreamReaderWriterZ	RawIOBaseZcloseZBufferedIOBaseZwritable�writeZseekableZtellZAttributeErrorZ
TextIOWrapper)rr&r'r#Zbufferrrr�_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,r+�_writeZflush�_flush�_ns_contexts�_current_context�_undeclared_ns_maps�	_encoding�_short_empty_elements�_pending_start_element)rrr&Zshort_empty_elementsrrrr1ss
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:rz:)r5)rr�prefixrrr�_qnameszXMLGenerator._qnamecCs|jr|jd�d|_dS)NrF�r9r2)r�
endElementrrr�_finish_pending_start_element�s
z*XMLGenerator._finish_pending_start_elementcCs|jd|j�dS)Nz$<?xml version="1.0" encoding="%s"?>
)r2r7�rrrr�
startDocument�szXMLGenerator.startDocumentcCs|j�dSr)r3r?rrr�endDocument�rzXMLGenerator.endDocumentcCs0|jj|jj��||j|<|jj||f�dSr)r4Zappendr5rr6�rr:�urirrr�startPrefixMapping�s
zXMLGenerator.startPrefixMappingcCs|jd|_|jd=dS)Nrr/r/)r4r5�rr:rrr�endPrefixMapping��zXMLGenerator.endPrefixMappingcCs^|j�|jd|�x*|j�D]\}}|jd|t|�f�q W|jrPd|_n
|jd�dS)Nr� %s=%sTr)r>r2rrr8r9)rr�attrsrrrr�startElement�szXMLGenerator.startElementcCs*|jr|jd�d|_n|jd|�dS�Nz/>Fz</%s>r<rrrrr=��
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"rHTr)r>r2r;r6rrr8r9)rr�qnamerIr:rCrrrr�startElementNS�s zXMLGenerator.startElementNScCs0|jr|jd�d|_n|jd|j|��dSrK)r9r2r;�rrrMrrr�endElementNS�rLzXMLGenerator.endElementNScCs4|r0|j�t|t�s"t||j�}|jt|��dSr)r>r(�strr7r2r�rZcontentrrr�
characters��

zXMLGenerator.characterscCs0|r,|j�t|t�s"t||j�}|j|�dSr)r>r(rQr7r2rRrrr�ignorableWhitespace�rTz XMLGenerator.ignorableWhitespacecCs|j�|jd||f�dS)Nz	<?%s %s?>)r>r2�rZtargetrrrr�processingInstruction�sz"XMLGenerator.processingInstruction)Nr.F)F)r r!r"r1r;r>r@rArDrFrJr=rNrPrSrUrWrrrrr-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|�||_dSr)r�	XMLReaderr1�_parent�rZparentrrrr1�rGzXMLFilterBase.__init__cC�|jj|�dSr)�_err_handler�error�rZ	exceptionrrrr^�rzXMLFilterBase.errorcCr\r)r]�
fatalErrorr_rrrr`�rzXMLFilterBase.fatalErrorcCr\r)r]�warningr_rrrra�rzXMLFilterBase.warningcCr\r)�
_cont_handler�setDocumentLocator)rZlocatorrrrrc�rz XMLFilterBase.setDocumentLocatorcC�|jj�dSr)rbr@r?rrrr@rzXMLFilterBase.startDocumentcCrdr)rbrAr?rrrrArzXMLFilterBase.endDocumentcC�|jj||�dSr)rbrDrBrrrrDrz XMLFilterBase.startPrefixMappingcCr\r)rbrFrErrrrF	rzXMLFilterBase.endPrefixMappingcCrer)rbrJ)rrrIrrrrJrzXMLFilterBase.startElementcCr\r)rbr=rrrrr=rzXMLFilterBase.endElementcC�|jj|||�dSr)rbrN)rrrMrIrrrrNrzXMLFilterBase.startElementNScCrer)rbrPrOrrrrPrzXMLFilterBase.endElementNScCr\r)rbrSrRrrrrSrzXMLFilterBase.characterscCr\r)rbrU)rZcharsrrrrUrz!XMLFilterBase.ignorableWhitespacecCrer)rbrWrVrrrrWrz#XMLFilterBase.processingInstructioncCr\r)rb�
skippedEntityrrrrrg!rzXMLFilterBase.skippedEntitycCrfr)�_dtd_handler�notationDecl)rr�publicId�systemIdrrrri&rzXMLFilterBase.notationDeclcCs|jj||||�dSr)rh�unparsedEntityDecl)rrrjrkZndatarrrrl)rz XMLFilterBase.unparsedEntityDeclcCs|jj||�Sr)Z_ent_handler�
resolveEntity)rrjrkrrrrm.rzXMLFilterBase.resolveEntitycCs@|jj|�|jj|�|jj|�|jj|�|jj|�dSr)rZZsetContentHandlerZsetErrorHandlerZsetEntityResolverZ
setDTDHandler�parse)r�sourcerrrrn3s
zXMLFilterBase.parsecCr\r)rZ�	setLocale)rZlocalerrrrp:rzXMLFilterBase.setLocalecC�|jj|�Sr)rZ�
getFeaturerrrrrr=rzXMLFilterBase.getFeaturecCrer)rZ�
setFeature)rrZstaterrrrs@rzXMLFilterBase.setFeaturecCrqr)rZ�getPropertyrrrrrtCrzXMLFilterBase.getPropertycCrer)rZ�setProperty)rrrrrrruFrzXMLFilterBase.setPropertycCs|jSr�rZr?rrr�	getParentKrzXMLFilterBase.getParentcCs
||_dSrrvr[rrr�	setParentNrzXMLFilterBase.setParentr) r r!r"�__doc__r1r^r`rarcr@rArDrFrJr=rNrPrSrUrWrgrirlrmrnrprrrsrtrurwrxrrrrrX�s:
rX�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.�readrrNZrb)r(rQrZInputSourceZhasattrr{ZsetCharacterStreamZ
setByteStreamrZsetSystemIdZgetCharacterStreamZ
getByteStreamZgetSystemId�osZpathZdirnameZnormpathZjoinZisfileZopen�urllibrnZurljoinZrequestZurlopen)roZbaseZfZsysidZbaseheadZ
sysidfilenamerrr�prepare_input_sourceSs*




r~)rz)ryr|Zurllib.parser}Zurllib.requestr)r*rzrrr	rrrr,r0r-rYrXr~rrrrZ<module>s)so