%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__/patchdir.cpython-312.pyc

�

�2e�T�� �ddlZddlmZddlmZddlmZddlmZddl�	Gd�de�Zd	�Z	d d
�Z
d d�Zd�Zd
�Z
d�Zd�ZGd�de�ZGd�de�ZGd�de�Zd�ZGd�de�Zd�Zd�Zd�Zd d�Zd�ZGd�de�Zy)!�N)�diffdir)�errors)�	selection)�tempdir)�*c��eZdZy)�PatchDirExceptionN)�__name__�
__module__�__qualname__���4/usr/lib/python3/dist-packages/duplicity/patchdir.pyr	r	"s��rr	c�n�tjdd|�}t||�|j�rJ�y)z6Patch given base_path and file object containing delta�	arbitrary�rN)�tarfile�TarFile�patch_diff_tarfile�close)�	base_path�difftar_fileobj�diff_tarfiles   r�Patchr&s3���?�?�;��_�E�L��y�,�/��$�$�&�&�&�&rc�4�t|�}t|||�y)z8Patch given base_path and iterator of delta file objectsN)�TarFile_FromFileobjsr)r�fileobj_iter�restrict_indexrs    r�Patch_from_iterr-s��'��5�L��y�,��?rc	��|j�r$tj|�j�}n
t	�}t|�}|rt
||�}tj||�}tt|g�}|D�]+\}}|r�tjtd�tj|j!��ztj"j$t&j)|j!���||j*||���tjtd�tj|j!��ztj"j$t&j)|j!���||j*||���.|j-�|j/�y)z�Patch given Path object using delta tarfile (as in tarfile.TarFile)

    If restrict_index is set, ignore any deltas in diff_tarfile that
    don't start with restrict_index.

    zPatching %sN)�existsr�Select�set_iter�
empty_iter�difftar2path_iter�filter_path_iterr�
collate2iters�IterTreeReducer�PathPatcher�log�Info�_�os�fsdecode�get_relative_path�InfoCode�patch_file_patching�util�escape�index�Finish�setdata)	rrr�	path_iter�diff_path_iter�collated�ITR�
basis_path�diff_ropaths	         rrr3sY�������$�$�Y�/�8�8�:�	��L�	�&�|�4�N��)�.�.�I���$�$�Y��?�H�
�+�	�{�
3�C�#+�<��
�K���H�H��-� �B�K�K�
�0L�0L�0N�$O�P����0�0����J�8�8�:�;�
�

�
� � �*�k�:��H�H��-� �B�K�K��0M�0M�0O�$P�Q����0�0����K�9�9�;�<�
�

��!�!�:�{�;�<��J�J�L�
���rc#�K�y�w�Nr
r
rrr$r$Xs	�����s�c#�K�t|t�r|sJ|��t|�}|D]-}|jd||k(s�|j|d|_|���/y�w)z�Rewrite path elements of path_iter so they start with index

    Discard any that doesn't start with index, and remove the index
    prefix from the rest.

    N)�
isinstance�tuple�lenr4)r7r4�l�paths    rr&r&]s_�����e�U�#��4�u�4�-��E�
�A�����:�:�b�q�>�U�"����A�B��D�J��J��s
�<A�Ac#�*K�t|�}d}	t|�g}	|dsy|r|js|j	��&t|d�\}}}t
|�}|j|d�||_|dk(rd|_	nY|j�rI|r$t||||�}|j|�|����|j|j|d��|��	t|�|d<��#t$rYywxYw#t$rYywxYw�w)z2Turn file-like difftarobj into iterator of ROPathsNr�deleted)�iter�next�
StopIteration�at_endr�get_index_from_tarinfo�ROPath�init_from_tarinfo�difftype�type�isreg�Multivol_Filelike�
setfileobj�extractfile)r�tar_iter�multivol_fileobj�tarinfo_listr4rN�multivol�ropaths        rr%r%ls+�����L�!�H���
��X��'����A����$4�$;�$;��"�"�$��$:�<��?�$K�!��x������� � ��a��1�"����y� ��F�K�
�\�\�^��#4�\�8�\�[`�#a� ��!�!�"2�3�����!�!�,�":�":�<��?�"K�L���	�"�8�n�L��O�1�������8�	��	�sL�D�C5�CD�&D�4D�5	D�>D�D�D�	D�
D�D�Dc�L�dD]�}tj|�}|j|�s�*|t|�d}|jd�r9|dk(rd}nd}d}tjdd	|�\}}|dk7r9t
d
|����|dd}|t|�d}|jd�r|dd}d
}nt
d
����|dk(s|dk(rd}nSttj|�jd��}d|vr"t
dtj|��d���|||fS)z;Return (index, difftype, multivol) pair from tarinfo object)z	snapshot/zdiff/zdeleted/�multivol_diff/zmultivol_snapshot/NrWrZ�diff�snapshot�z+(?s)^multivol_(diff|snapshot)/?(.*)/[0-9]+$z\2zUnrecognized diff entry ����/r�.�r
�/s..z
Tar entry z# contains '..'.  Security violation)
r2�get_tarinfo_name�
startswithrB�re�subnr	�endswithrAr-�fsencode�splitr.)�tarinfo�prefix�tiname�namerNrW�num_subsr4s        rrKrK�sP���E���&�&�w�/�����V�$��#�f�+�-�(�D�� � ��,��-�-�%�H�)�H���!#���)V�X]�_e�!f���h��q�=�+�.F�v�h�,O�P�P�!�#�2�;���c�&�k�m�,���=�=��&����9�D����3E�6 �":�6�(� C�D�D��t�|�t�s�{����b�k�k�$�'�-�-�d�3�4���E�>�#�j����V�1D�0E�Eh�$i�j�j��(�H�$�$rc�*�eZdZdZd�Zdd�Zd�Zd�Zy)rQz�Emulate a file like object from multivols

    Maintains a buffer about the size of a volume.  When it is read()
    to the end, pull in more volumes as desired.

    c�Z�||c|_|_||_||_d|_d|_y)z9Initializer.  tf is TarFile obj, tarinfo is first tarinforFN)�tfrTrVr4�bufferrJ)�selfrqrTrVr4s     r�__init__zMultivol_Filelike.__init__�s/��!#�X������(�����
������rc��|dkr8|j�r	|j�r�t|j�}nat|j�|kr*|j�snt|j�|kr�*tt|j�|�}|jd|}|j|d|_|S)zRead length bytes from filerN)�addtobufferrBrr�min)rs�length�real_len�results    r�readzMultivol_Filelike.read�s����A�:��"�"�$���"�"�$��4�;�;�'�H��d�k�k�"�V�+��'�'�)���d�k�k�"�V�+��3�t�{�{�+�V�4�H����Y�h�'���k�k�(�)�,����
rc���|jryt|jd�\}}}|r||jk7rd|_y|jj|jd�}|xj|j�z
c_|j�	t|j�|jd<y#t$rd|jd<d|_YywxYw)zAdd next chunk to bufferFrTN)rJrKrVr4rqrSrrr{rrHrTrI)rsr4rNrW�fps     rrvzMultivol_Filelike.addtobuffer�s����;�;��$:�4�;L�;L�Q�;O�$P�!��x���5�D�J�J�.��D�K��
�W�W�
 �
 ��!2�!2�1�!5�
6�����r�w�w�y� ��
���
�	�#'��
�
�#6�D���a� �
��	�	�#'�D���a� ��D�K��	�s�"C�C$�#C$c�n�|js"	d|_|j�s		d|_y�!d|_y)z"If not at end, read remaining dataTrN)rJrrrv�rss rrzMultivol_Filelike.close�s7���{�{��!����'�'�)�����	���rN)r^)r
rr�__doc__rtr{rvrr
rrrQrQ�s����� �.rrQc�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)r)z2Used by DirPatch, process the given basis and diffc�.�d|_||_d|_y�z#Set base_path, Path of root of treeN)�dir_basis_pathr�dir_diff_ropath�rsrs  rrtzPathPatcher.__init__s��"���"���#��rc��|r|j�s3|dk(sJtj|���|j|||�y|s>|jj|�}|j
�rJ�|j�n0|j�s |j�|j�||_	||_
y)z0Start processing when diff_ropath is a directoryr
N)�isdirr2�uindex�fast_processr�	new_indexr!�mkdir�deleter�r��rsr4r;r<s    r�
start_processzPathPatcher.start_processs����� 1� 1� 3��B�;�2����E� 2�2�;����e�Z��=������1�1�%�8�J�!�(�(�*�*�*������!�!�#���������(���*��rc�h�|jr&|jj|j�yy)z,Copy directory permissions when leaving treeN)r��copy_attribsr�rs r�end_processzPathPatcher.end_processs*������ � �-�-�d�.A�.A�B� rc�,�|xr|j�S)z3No need to recurse if diff_ropath isn't a directory)r�r�s    r�can_fast_processzPathPatcher.can_fast_processs���7�K�$5�$5�$7�8�8rc�L�|sy|s;|jdk(ry|j|jj|��y|jdk(r2|j	�r|j�y|j
�y|j�r|j�rR|jdk(rC|j	�r|j�n|j
�|j|�y|jdk(sJ|j��|j|�y)z#For use when neither is a directoryNrFr\r[)	rN�copyrr�r��deltreer�rP�patch_with_attribsr�s    rr�zPathPatcher.fast_process!s�������#�#�y�0��� � ����!9�!9�%�!@�A�
�
!�
!�Y�
.����!��"�"�$��!�!�#��!�!�#�
�(8�(8�(:�{�?S�?S�Wa�?a����!��"�"�$��!�!�#����Z�(��'�'�6�1�G�;�3G�3G�G�1��)�)�+�6rN�	r
rrr�rtr�r�r�r�r
rrr)r)�s��<�$�+�"C�
9�7rr)c�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)rz@Like a tarfile.TarFile iterator, but read from multiple fileobjsc�>�||_d\|_|_d|_y)z�Make new tarinfo iterator

        fileobj_iter should be an iterator of file objects opened for
        reading.  They will be closed at end of reading.

        )NNN)rrrT�
current_fp)rsrs  rrtzTarFile_FromFileobjs.__init__>s!��)���&0�#���d�m���rc��|Sr>r
rs r�__iter__zTarFile_FromFileobjs.__iter__Is���rc�D�|jr|jj�rJ�	t|j�}t	|t
j�r�1||_	tjd|j�|_	t|j�|_y)z9Set tarfile from next file object, or raise StopIterationrN)r�rrHrr@r�BadVolumeExceptionr2�make_tarfilerrGrT)rs�xs  r�set_tarfilez TarFile_FromFileobjs.set_tarfileLsw���?�?����,�,�.�.�.���T�&�&�'�A��!�V�6�6�7��"#�����(�(��d�o�o�>����T�\�\�*��
rc�&�|js	|j�	t|j�S#t$rYywxYw#t$rD|jj�rJ�|j�t|j�cYSwxYwr>)rr�rIrHrTrrs r�__next__zTarFile_FromFileobjs.__next__]s����|�|�
�� � �"�	'���
�
�&�&��!�
��
���	'��|�|�)�)�+�+�+�������
�
�&�&�	'�s �4�A�	A�A�A
B�Bc�8�|jj|�S)z)Return data associated with given tarinfo)rrS)rsrjs  rrSz TarFile_FromFileobjs.extractfilejs���|�|�'�'��0�0rN)	r
rrr�rtr�r�r�rSr
rrrr;s��J�	��+�"'�1rrc������t����dk(rtj�d�d�Sdg�z}|dd}��fd��d����fd�}|�||�S)a�Collate iterators by index

    Input is a list of n iterators each of which must iterate elements
    with an index attribute.  The elements must come out in increasing
    order, and the index should be a tuple itself.

    The output is an iterator which yields tuples where all elements
    in the tuple have the same index, and the tuple has n elements in
    it.  If any iterator lacks an element with that index, the tuple
    will have None in that spot.

    �rr]Nc���t��D] }||r�	||��	t�|�||<�"y#t$r
d||<d||<Y�9wxYw)zSet the overflow and rorps listNr])�rangerHrI)�overflow�elems�i�	iter_list�iter_nums   ��r�setrorpszcollate_iters.<locals>.setrorps�s`����x��	$�A��A�;�5��8�#3�$�#�I�a�L�1�E�!�H�	$��%�$�"#�H�Q�K�#�E�!�H�$�s�1�A�Ac�~�t|D�cgc]}|s�|��	c}D�cgc]}|j��c}�Scc}wcc}w)z;Return the first index in elems, assuming elems isn't empty)rwr4)r�r��elems   r�
getleastindexz$collate_iters.<locals>.getleastindex�s/���u�+B�!��A�+B�C�4�D�J�J�C�D�D��+B��Cs�5�5�:c3��K�	�||�d|vry�|�}g}t|�D]D}||r,||j|k(r|j||�d||<�4|jd��Ft|����x�wr>)r�r4�appendrA)r�r�r�r4�yieldvalr�r�r�s      ��r�yield_tuplesz#collate_iters.<locals>.yield_tuples�s��������X�u�%��8�#��!�%�(�E��H��8�_�
*����8��a����%� 7��O�O�E�!�H�-�#�E�!�H��O�O�D�)�
*���/�!��s�A:A=)rBrr')r�r�r�r�r�r�r�s`   @@@r�
collate_itersr�osf����9�~�H��1�}��$�$�Y�q�\�9�Q�<�@�@��v�� �H��Q�K�E�$�E�"� ��(�E�2�2rc�R�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zy
)�IndexedTuplez?Like a tuple, but has .index (used previously by collate_iters)c�2�||_t|�|_yr>)r4rA�data)rsr4�sequences   rrtzIndexedTuple.__init__�s����
��(�O��	rc�,�t|j�Sr>)rBr�rs r�__len__zIndexedTuple.__len__�s���4�9�9�~�rc� �|j|S)z4This only works for numerical keys (easier this way))r�)rs�keys  r�__getitem__zIndexedTuple.__getitem__�s���y�y��~�rc�*�|j|�dk(S�Nr^��__cmp__�rs�others  r�__lt__zIndexedTuple.__lt__�����|�|�E�"�b�(�(rc�*�|j|�dk7S�Nr]r�r�s  r�__le__zIndexedTuple.__le__�����|�|�E�"�a�'�'rc�&�|j|�Sr>)�__eq__r�s  r�__ne__zIndexedTuple.__ne__�s���;�;�u�%�%�%rc�*�|j|�dk(Sr�r�r�s  r�__gt__zIndexedTuple.__gt__�r�rc�*�|j|�dk7Sr�r�r�s  r�__ge__zIndexedTuple.__ge__�r�rc��t|t�sJ�|j|jkry|j|jk(ryy)Nr^rr])r@r�r4r�s  rr�zIndexedTuple.__cmp__�s;���%��.�.�.��:�:����#��
�Z�Z�5�;�;�
&��rc���t|t�r4|j|jk(xr|j|jk(St|t�r|j|k(Sy)NF)r@r�r4r�rAr�s  rr�zIndexedTuple.__eq__�sM���e�\�*��:�:����,�H����e�j�j�1H�H�
��u�
%��9�9��%�%�rc�t�ddjtt|j���d|j��S)N�(z, z).)�join�map�strr�r4rs r�__str__zIndexedTuple.__str__�s.���4�9�9�S��d�i�i�0�1�2�"�T�Z�Z�L�A�ArN)r
rrr�rtr�r�r�r�r�r�r�r�r�r�r
rrr�r��s=��I�$���)�(�&�(�)���Brr�c��g}t|�dz
}|dk\r6||}|�$|jd|�|jdk7r	|S|dz}|dk\r�6|S)a$Given an sequence of ROPath deltas, remove blank and unnecessary

    The sequence is assumed to be in patch order (later patches apply
    to earlier ones).  A patch is unnecessary if a later one doesn't
    require it (for instance, any patches before a "delete" are
    unnecessary).

    r]rr[)rB�insertrN)�patch_sequence�result_listr��deltas    r�normalize_psr��sp���K��N��a��A�
�q�&��q�!�������q�%�(��~�~��'����	
�Q����q�&��rc�
�|d}|jdk7sJd|�d���|j�s2t|�dk(sJdt|��d���|j�S|j	d�}|dd	D]\}|jdk(sJ|j��	t
j
�t"j%||j	d��}�^|dj�}|j'|�|S#t$r|}	tjtj�j��
�}tj||�|j�rJ�|j!d�|}Yd	}~��d	}~wwxYw)z4Apply the patches in patch_seq, return single ropathrr[zFirst patch in sequence z was a diffr]z&Patch sequence isn't regular, but has z entries�rbN)�dirr^)rNrPrB�
get_ropath�open�cur_file�fileno�	Exception�tempfile�
TemporaryFiler�defaultr�r2�copyfileobjr�seek�librsync�PatchedFilerR)�	patch_seq�first�current_file�delta_ropath�e�tempfprzs       r�patch_seq2ropathr��sp���a�L�E��>�>�V�#�V�'?�	�{�+�%V�V�#��;�;�=��9�~��"�e�&L�S�QZ�^�L\�\d�$e�e�"����!�!��:�:�d�#�L�!�!�"�
�S���$�$��.�E��0E�0E�E�.�	"��O�O�� �+�+�L�,�:K�:K�D�:Q�R��%S�&�r�]�
%�
%�
'�F�
���l�#��M��#�
	"�
��+�+����0A�0E�0E�0G�H�F����\�6�2�#�)�)�+�+�+��K�K��N�!�L��
	"�s�C=�=	F�A2E=�=Fc	#��K�t|�}|D]-}t|�}	t|�}|j�r|���/y#t$r�}|dj�j
�}tjtd�tj|�tj|�fztjjtj!|��Yd}~��d}~wwxYw�w)z�Combine a list of iterators of ropath patches

    The iter_list should be sorted in patch order, and the elements in
    each iter_list need to be orderd by index.  The output will be an
    iterator of the final ROPaths in index order.

    r^zError '%s' patching %sN)r�r�r�r!r�r�r/r*�Warnr,r2�uexcr-r.�WarningCode�cannot_processr3)r�r9r��
normalized�final_ropathr��filenames       r�integrate_patch_itersrs������Y�'�H��
�	�!�)�,�
�	�+�J�7�L��"�"�$�"�"��

���	�!�"�~�0�0�2�D�D�F�H��H�H��*�+�t�y�y��|�R�[�[��=R�.S�S����.�.����H�%�
�
��	�s.�C.�A�C.�	C+�
BC&�!C.�&C+�+C.c��|D�cgc]
}t|���}}|r|D�cgc]}t||���}}t|�Scc}wcc}w)z�Integrate tarfiles of diffs into single ROPath iter

    Then filter out all the diffs in that index which don't start with
    the restrict_index.

    )r%r&r)�tarfile_listrr��
diff_iterss    r�tarfiles2rop_iterr)sQ��1=�=�1�#�A�&�=�J�=��CM�N�a�&�q�.�9�N�
�N� ��,�,��	>��Os	�?�Ac��tt|g�}d}|D]}d}||j|��|j�|j	�|S)zxWrite out ropaths in rop_iter starting at base_path

    Returns 1 if something was actually written, 0 otherwise.

    rr])r(�ROPath_IterWriterr4r5r6)r�rop_iterr:�
return_valrXs     r�
Write_ROPathsr7sW���+�i�[�
9�C��J��"���
��F�L�L�&�!�"��J�J�L�
�����rc�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)rz�Used in Write_ROPaths above

    We need to use an ITR because we have to update the
    permissions/times of directories after we write the files in them.

    c�.�||_d|_d|_yr�)rr��dir_new_pathr�s  rrtzROPath_IterWriter.__init__Os��"���#��� ��rc�
�|j�s||jdk(sJ|j��|jj|�}|j	�r1|j	�r|j�|j
|�|jj|�|_|jj	�rtjs|dk(s!J|��|jj�||_y)z.Write ropath.  Only handles the directory caser
N)r�r4rr�r!r�r�r�config�forcer�r�)rsr4rX�new_paths    rr�zROPath_IterWriter.start_processUs����|�|�~��<�<�2�%�3�v�|�|�3�%��~�~�/�/��6�H��}�}���?�?�$��$�$�&����H�%� �N�N�4�4�U�;������#�#�%�f�l�l��B�;�%��%�;����#�#�%�%��rc�h�|jr&|jj|j�yy)z1Update information of a directory when leaving itN)r�r�rrs rr�zROPath_IterWriter.end_processhs*������ � �-�-�d�.?�.?�@� rc�T�tjtd�tj	|j��|jfztjjtj|j���d|j���|j�S)z;Can fast process (no recursion) if ropath isn't a directoryzWriting %s of type %s� )r*r+r,r-r.r/rOr0�patch_file_writingr2r3r��rsr4rXs   rr�z"ROPath_IterWriter.can_fast_processms}�����
�%�&�"�+�+�f�6N�6N�6P�*Q�SY�S^�S^�)_�_��L�L�+�+��{�{�6�3�3�5�6�7�q����
�F�	
�
�<�<�>�!�!rc�z�|j�r+|j|jj|��yy)z)Write non-directory ropath to destinationN)r!r�rr�rs   rr�zROPath_IterWriter.fast_processvs+���=�=�?��K�K����0�0��7�8�rNr�r
rrrrGs!���!�&�&A�
"�9rr)r
)r��	duplicityrrrr�duplicity.pathr�r	rrrr$r&r%rK�objectrQ�	ITRBranchr)rr�r�r�r�rrrrr
rr�<module>rs���.������+�	�	�	�'�@�"�J�
�'�T$%�N>��>�B:7�)�:7�z11�6�11�h33�l/B�6�/B�d�, �F�2-�
� 29�	�29r

Zerion Mini Shell 1.0