%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/duplicity/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/duplicity/__pycache__/librsync.cpython-312.pyc

�

�2e6!��<�dZddlZddlZddlmZej
j
d�dk(r ddlmZddl	Z	ej�e	_ejZGd�de
�ZGd	�d
e�ZGd�de�ZGd
�de�ZGd�de�ZGd�de�Zy)z�Provides a high-level interface to some librsync functions

This is a python wrapper around the lower-level _librsync module,
which is written in C.  The goal was to use C as little as possible...

�N�)�	_librsync�READTHEDOCS�Truec��eZdZdZy)�
librsyncErrora/Signifies error in internal librsync processing (bad signature, etc.)

    underlying _librsync.librsyncError's are regenerated using this
    class because the C-created exceptions are by default
    unPickleable.  There is probably a way to fix this in _librsync,
    but this scheme was easier.

    N)�__name__�
__module__�__qualname__�__doc__���4/usr/lib/python3/dist-packages/duplicity/librsync.pyrr+s���	rrc�B�eZdZdZdZdZd
d�Zd
d�Zdd�Zd�Z	d�Z
d	�Zy)�LikeFilez:File-like object used by SigFile, DeltaFile, and PatchFile�rbNc��|j||�||_dx|_|_d|_tj
d�|_dx|_|_y)z1LikeFile initializer - zero buffers, set eofs offNr�b)	�
check_file�infile�closed�
infile_closed�inbuf�array�outbuf�eof�
infile_eof)�selfr�	need_seeks   r�__init__zLikeFile.__init__AsK������	�*����+/�/���d�(���
��k�k�#�&���%)�)���4�?rc��t|d�std��t|d�std��|rt|d�std��yy)z:Raise type error if file doesn't have necessary attributes�readz$Basis file must have a read() method�closez%Basis file must have a close() method�seekz$Basis file must have a seek() methodN)�hasattr�	TypeError)r�filers   rrzLikeFile.check_fileJsM���t�V�$��B�C�C��t�W�%��C�D�D��W�T�6�2��B�C�C�3�9rc���|dk(r?|js|j�|js�t|j�}nx|jsMt|j�|kr5|j�|jst|j�|kr�5t	|t|j��}|jd|j�}|jd|�=|S)z/Build up self.outbuf, return first length bytes���N)r�_add_to_outbuf_once�lenr�min�tobytes)r�length�real_len�
return_vals    rr"z
LikeFile.readSs����R�<��h�h��(�(�*��h�h��4�;�;�'�H��h�h�3�t�{�{�#3�f�#<��(�(�*��h�h�3�t�{�{�#3�f�#<��6�3�t�{�{�#3�4�H��[�[��(�+�3�3�5�
��K�K�	��	�"��rc�V�|js|j�	|jj|j�\|_}}|j|d|_|jj|�y#tj$r}tt|���d}~wwxYw)z.Add one cycle's worth of output to self.outbufN)r�
_add_to_inbuf�maker�cyclerrrr�strr�	frombytes)r�len_inbuf_read�	cycle_out�es    rr*zLikeFile._add_to_outbuf_oncebs��������� �	(�26�*�*�2B�2B�4�:�:�2N�/�D�H�n�i��Z�Z���0��
������i�(���&�&�	(���A��'�'��	(�s�.A<�<B(�B#�#B(c�V�|jrJ�t|j�tkr|jjt�}|s+d|_|jj
�rJ�d|_y|xj|z
c_t|j�tkr�~yy)z&Make sure len(self.inbuf) >= blocksizerN)rr+r�	blocksizerr"r#r)r�new_ins  rr2zLikeFile._add_to_inbufms~���?�?�"�"��$�*�*�o�	�)��[�[�%�%�i�0�F��"#����;�;�,�,�.�.�.�%&��"���J�J�&� �J��$�*�*�o�	�)rc�b�|js|jj�rJ�d|_y)zClose infilerN)rrr#r�rs rr#zLikeFile.closeys(���!�!��{�{�(�(�*�*�*���r)N)r))r	r
rr�moder3r rr"r*r2r#r
rrrr8s0��D��D�
�E�*�D�
�	)�
!�rrc�.�eZdZdZej
fd�Zy)�SigFilezCFile-like object which incrementally generates a librsync signaturec���tj||�	tj|�|_y#tj
$r}tt
|���d}~wwxYw)z�SigFile initializer - takes basis file

        basis file only needs to have read() and close() methods.  It
        will be closed when we come to the end of the signature.

        N)rr r�new_sigmakerr3rr5)rrr;r9s    rr zSigFile.__init__�sP��	���$��'�	(�"�/�/�	�:�D�J���&�&�	(���A��'�'��	(�s�3�A�A�AN)r	r
rrr�RS_DEFAULT_BLOCK_LENr r
rrrArA�s��M�)2�)G�)G�(rrAc��eZdZdZd�Zy)�	DeltaFilez?File-like object which incrementally generates a librsync deltac�P�tj||�t|t�r|}n3|j	|�|j�}|j
�rJ�	tj|�|_	y#tj$r}tt|���d}~wwxYw)a
DeltaFile initializer - call with signature and new file

        Signature can either be a string or a file with read() and
        close() methods.  New_file also only needs to have read() and
        close() methods.  It will be closed when self is closed.

        N)rr �
isinstance�bytesrr"r#r�new_deltamakerr3rr5)r�	signature�new_file�
sig_stringr9s     rr zDeltaFile.__init__�s���	���$��)��i��'�"�J��O�O�I�&�"���)�J� ���(�(�(�	(�"�1�1�*�=�D�J���&�&�	(���A��'�'��	(�s�A9�9B%�B � B%N�r	r
rrr r
rrrFrF�s
��I�(rrFc��eZdZdZd�Zy)�PatchedFilez=File-like object which applies a librsync delta incrementallyc��tj||�	|j�	tj|�|_
y#t$rN}	t	|d�r#t	|j
d�r
|j
}nt
td���Yd}~�nd}~wwxYw#tj$r}tt|���d}~wwxYw)z�PatchedFile initializer - call with basis delta

        Here basis_file must be a true Python file, because we may
        need to seek() around in it a lot, and this is done in C.
        delta_file only needs read() and close() methods.

        r'�filenozebasis_file must be a (true) file or an object whose file attribute is the underlying true file objectN)
rr rR�	Exceptionr%r'r&�_r�new_patchmakerr3rr5)r�
basis_file�
delta_filer9s    rr zPatchedFile.__init__�s���	���$�
�+�	����� 	(�"�1�1�*�=�D�J��!�	�
�
�z�6�*�w�z����/Q�'�_�_�
���L������	��"�&�&�	(���A��'�'��	(�s/�A�B�	B�
AB�B�C
�1C�C
NrNr
rrrPrP�s
��G�(rrPc�@�eZdZdZej
fd�Zd�Zd�Zd�Z	y)�SigGeneratorz�Calculate signature.

    Input and output is same as SigFile, but the interface is like md5
    module, not filelike object

    c���	tj|�|_d|_d|_g|_y#tj$r}tt	|���d}~wwxYw)zReturn new signature instanceNr)rrC�	sig_makerrr5�gotsig�buffer�sigstring_list)rr;r9s   rr zSigGenerator.__init__�sX��	(�&�3�3�I�>�D�N������� ����	�&�&�	(���A��'�'��	(�s�2�A�A�Ac��|jrtd��|xj|z
c_t|j�tk\r9|j�rtd��t|j�tk\r�8yy)z6Add buf to data that signature will be calculated overz'SigGenerator already provided signaturez%Premature EOF received from sig_makerN)r\rr]r+r;�process_buffer)r�bufs  r�updatezSigGenerator.update�s_���;�;�� I�J�J����s����$�+�+��)�+��"�"�$�#�$K�L�L��$�+�+��)�+rc��	|jj|j�\}}}|j|d|_|jj|�|S#tj$r}t	t|���d}~wwxYw)z9Run self.buffer through sig_maker, add to self.sig_stringN)r[r4r]rrr5r^�append)rr�len_buf_readr8r9s     rr`zSigGenerator.process_buffer�sz��	(�+/�>�>�+?�+?����+L�(�C��y��k�k�,�-�0������"�"�9�-��
��	�&�&�	(���A��'�'��	(�s�)A�B�/B�Bc�|�|j�s	|j�s�dj|j�S)z Return signature over given datar)r`�joinr^r>s r�getsigzSigGenerator.getsig�s4���%�%�'���%�%�'��x�x��+�+�,�,rN)
r	r
rrrrDr rbr`rhr
rrrYrY�s'���"+�!?�!?�!�M��-rrY)rr�os�r�environ�get�
unittest.mock�mock�	duplicity�	MagicMock�RS_JOB_BLOCKSIZEr;rSr�objectrrArFrPrYr
rr�<module>rss���,�
�	���:�:�>�>�-� �F�*� ��(�$�.�.�*�I���&�&�	�
	�I�
	�E�v�E�P(�h�(�"(��(�0 (�(� (�F)-�6�)-r

Zerion Mini Shell 1.0