https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/duplicity/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/duplicity/__pycache__/patchdir.cpython-310.pyc
o

�0ka,X�@s�ddlmZddlmZddlmZddlmZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
lm
Z
ddlmZddlmZdd
lmZddlmZddlTddlT	Gdd�de�Zdd�Zd7dd�Zd7dd�Zdd�Zdd�Zdd�Zdd �ZGd!d"�d"e�ZGd#d$�d$e�ZGd%d&�d&e�Z d'd(�Z!Gd)d*�d*e�Z"d+d,�Z#d-d.�Z$d/d0�Z%d7d1d2�Z&d3d4�Z'Gd5d6�d6e�Z(dS)8�)�map)�next)�object)�rangeN)�errors)�diffdir)�config)�librsync)�log)�	selection)�tarfile)�tempdir)�util)�*c@seZdZdS)�PatchDirExceptionN)�__name__�
__module__�__qualname__�rr�4/usr/lib/python3/dist-packages/duplicity/patchdir.pyr.srcCs(t�dd|�}t||�|��rJ�dS)z6Patch given base_path and file object containing delta�	arbitrary�rN)r�TarFile�patch_diff_tarfile�close)�	base_path�difftar_fileobj�diff_tarfilerrr�Patch2s
rrcCst|�}t|||�dS)z8Patch given base_path and iterator of delta file objectsN)�TarFile_FromFileobjsr)r�fileobj_iter�restrict_indexrrrr�Patch_from_iter9sr"c		Cs�|��rt�|���}nt�}t|�}|rt||�}t�||�}t	t
|g�}|D]C\}}|rMt�t
d�t�|���tjjt�|����||j||�q(t�t
d�t�|���tjjt�|����||j||�q(|��|��dS)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�PathPatcherr
�Info�_r�fsdecode�get_relative_path�InfoCode�patch_file_patching�escape�index�Finish�setdata)	rrr!�	path_iter�diff_path_iter�collated�ITR�
basis_path�diff_ropathrrrr?s,
��rccs�dS�Nrrrrrr&`s�r&ccsV�t|t�r|sJ|��t|�}|D]}|jd|�|kr(|j|d�|_|VqdS)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�lenr3)r6r3�l�pathrrrr(es���r(ccs�t|�}d}zt|�g}Wn
tyYdSw	|ds dS|r*|js*|��qt|d�\}}}t|�}|�|d�||_|dkrId|_	n |�
�ri|r_t||||�}|�|�|Vq|�|�
|d��|Vzt|�|d<Wn
ty~YdSwq)z2Turn file-like difftarobj into iterator of ROPathsN�r�deleted)�iterr�
StopIteration�at_endr�get_index_from_tarinfo�ROPath�init_from_tarinfo�difftype�type�isreg�Multivol_Filelike�
setfileobj�extractfile)r�tar_iter�multivol_fileobj�tarinfo_listr3rJ�multivol�ropathrrrr'tsH��
�
��r'cCsDdD]d}t�|�}tjjdkrt|t�r|��}|�|�rf|t	|�d�}|�d�rI|dkr1d}nd}d}t
�d	d
|�\}}|dkrHtd|��n|dd�}|t	|�d�}|�
d
�rb|dd�}d}nqtd|��|dksu|dkrxd}n%tjjdkr�tt�|��d��}nt|�d��}d|vr�tdt�|���|||fS)z;Return (index, difftype, multivol) pair from tarinfo object)z	snapshot/zdiff/zdeleted/�multivol_diff/zmultivol_snapshot/�NrSrU�diff�snapshotrBz+(?s)^multivol_(diff|snapshot)/?(.*)/[0-9]+$z\2zUnrecognized diff entry %s����/r�.�r��/s..z/Tar entry %s contains '..'.  Security violation)r�get_tarinfo_name�sys�version_info�majorr=�unicode�encode�
startswithr?�re�subnr�endswithr>�fsencode�splitr.)�tarinfo�prefix�tiname�namerJrS�num_subsr3rrrrG�sP


����
���
rGc@s2eZdZdZdd�Zddd�Zdd�Zd	d
�ZdS)
rMz�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.

    cCs*|||_|_||_||_d|_d|_dS)z9Initializer.  tf is TarFile obj, tarinfo is first tarinfo�rN)�tfrPrRr3�bufferrF)�selfrqrPrRr3rrr�__init__�s

zMultivol_Filelike.__init__rYcCs~|dkr|��r
	|��st|j�}nt|j�|kr&|��snt|j�|kstt|j�|�}|jd|�}|j|d�|_|S)zRead length bytes from filerN)�addtobufferr?rr�min)rs�length�real_len�resultrrr�read�s��zMultivol_Filelike.readcCs�|jrdSt|jd�\}}}|r||jkrd|_dS|j�|jd�}|j|��7_|��zt	|j
�|jd<WdStyNd|jd<d|_YdSw)zAdd next chunk to bufferNrrB)rFrGrRr3rqrOrrrzrrrPrE)rsr3rJrS�fprrrru�s"�
�zMultivol_Filelike.addtobuffercCs$|js
	d|_|��snqd|_dS)z"If not at end, read remaining datarBrpN)rFrrru�rsrrrrs�
zMultivol_Filelike.closeN)rY)rrr�__doc__rtrzrurrrrrrM�s
rMc@�8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
r+z2Used by DirPatch, process the given basis and diffcCs||_d|_dS�z#Set base_path, Path of root of treeN)r�dir_diff_ropath�rsrrrrrt
s
zPathPatcher.__init__cCs�|r|��s|dksJt�|���|�|||�dS|s-|j�|�}|��r(J�|��n|��s9|��|��||_	||_
dS)z0Start processing when diff_ropath is a directoryrN)�isdirr�uindex�fast_processr�	new_indexr#�mkdir�delete�dir_basis_pathr��rsr3r:r;rrr�
start_processs

zPathPatcher.start_processcC�|jr|j�|j�dSdS)z,Copy directory permissions when leaving treeN)r��copy_attribsr�r|rrr�end_process#��zPathPatcher.end_processcCs|o|��S)z3No need to recurse if diff_ropath isn't a directory)r�r�rrr�can_fast_process(szPathPatcher.can_fast_processcCs�|sdS|s|jdkr
dS|�|j�|��dS|jdkr-|��r'|��dS|��dS|��r:|��rN|jdkrN|��rC|��n|��|�|�dS|jdksXJ|j��|�|�dS)z#For use when neither is a directoryNrCrXrW)	rJ�copyrr�r��deltreer�rL�patch_with_attribsr�rrrr�,s"


zPathPatcher.fast_processN�	rrrr}rtr�r�r�r�rrrrr+sr+c@r~)
rz@Like a tarfile.TarFile iterator, but read from multiple fileobjscCs||_d\|_|_d|_dS)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)r rrP�
current_fp)rsr rrrrtHs
zTarFile_FromFileobjs.__init__cCs|Sr<rr|rrr�__iter__SszTarFile_FromFileobjs.__iter__cCsV|jr
|j��r
J�	t|j�}t|tj�rq
||_	t�d|j�|_	t
|j	�|_dS)z9Set tarfile from next file object, or raise StopIterationTrN)r�rrr r=r�BadVolumeExceptionr�make_tarfilerrDrP)rs�xrrr�set_tarfileVs
z TarFile_FromFileobjs.set_tarfilecCsh|jsz|��Wn
tyYdSwzt|j�WSty3|j��r(J�|��t|j�YSwr<)rr�rErrPrr|rrr�__next__gs��zTarFile_FromFileobjs.__next__cCs|j�|�S)z)Return data associated with given tarinfo)rrO)rsrkrrrrOtsz TarFile_FromFileobjs.extractfileN)	rrrr}rtr�r�r�rOrrrrrFs
rcsjt����dkrt��d�d�Sdg�}|dd�}��fdd��dd����fd	d
�}|�||�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.

    rVrrBNc	s^t��D](}||s,||dur,z
t�|�||<Wqty+d||<d||<YqwqdS)zSet the overflow and rorps listNrB)rrrE)�overflow�elems�i)�	iter_list�iter_numrr�setrorps�s���zcollate_iters.<locals>.setrorpscSstdd�dd�|D�D��S)z;Return the first index in elems, assuming elems isn't emptycSsg|]}|j�qSr)r3)�.0�elemrrr�
<listcomp>�sz8collate_iters.<locals>.getleastindex.<locals>.<listcomp>cSsg|]}|r|�qSrr�r�r�rrrr���)rv)r�rrr�
getleastindex�sz$collate_iters.<locals>.getleastindexc3sx�	�||�d|vr
dS�|�}g}t|�D]}||r0||j|kr0|�||�d||<q|�d�qt|�Vqr<)rr3�appendr>)r�r�r�r3�yieldvalr�)r�r�rr�yield_tuples�s�


�z#collate_iters.<locals>.yield_tuples)r?rr))r�r�r�r�r)r�r�r�r�r�
collate_itersys

r�c@sheZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�IndexedTuplez?Like a tuple, but has .index (used previously by collate_iters)cCs||_t|�|_dSr<)r3r>�data)rsr3�sequencerrrrt�szIndexedTuple.__init__cCs
t|j�Sr<)r?r�r|rrr�__len__�s
zIndexedTuple.__len__cCs
|j|S)z4This only works for numerical keys (easier this way))r�)rs�keyrrr�__getitem__�s
zIndexedTuple.__getitem__cC�|�|�dkS�NrY��__cmp__�rs�otherrrr�__lt__��zIndexedTuple.__lt__cC�|�|�dkS�NrBr�r�rrr�__le__�r�zIndexedTuple.__le__cCs|�|�Sr<)�__eq__r�rrr�__ne__�szIndexedTuple.__ne__cCr�r�r�r�rrr�__gt__�r�zIndexedTuple.__gt__cCr�r�r�r�rrr�__ge__�r�zIndexedTuple.__ge__cCs2t|t�sJ�|j|jkrdS|j|jkrdSdS)NrYrrB)r=r�r3r�rrrr��szIndexedTuple.__cmp__cCs:t|t�r|j|jko|j|jkSt|t�r|j|kSdSr<)r=r�r3r�r>r�rrrr��s



zIndexedTuple.__eq__cCsdd�tt|j��|jfS)Nz(%s).%sz, )�joinr�strr�r3r|rrr�__str__�szIndexedTuple.__str__N)rrrr}rtr�r�r�r�r�r�r�r�r�r�rrrrr��s	r�cCsXg}t|�d}|dkr*||}|dur"|�d|�|jdkr"	|S|d8}|dks|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).

    rBrNrW)r?�insertrJ)�patch_sequence�result_listr��deltarrr�normalize_ps�s	
��r�cCs�|d}|jdksJd|��|��s%t|�dks!Jdt|���|��S|�d�}|dd�D]>}|jdks<J|j��zt��Wn"	tjt	�
���d�}t�
||�|��r]J�|�d�|}Yt�||�d��}q0|d	��}|�|�|S)
z4Apply the patches in patch_seq, return single ropathrrWz%First patch in sequence %s was a diffrBz0Patch sequence isn't regular, but has %d entries�rbN)�dirrY)rJrLr?�
get_ropath�open�cur_file�fileno�tempfile�
TemporaryFiler
�defaultr�r�copyfileobjr�seekr	�PatchedFilerN)�	patch_seq�first�current_file�delta_ropath�tempfpryrrr�patch_seq2ropath�s6��

�
r�ccs��t|�}|D]E}t|�}z
t|�}|��r|VWqtyL}z&|d����}t�t	d�t
�|�t
�|�ftj
jt
�|��WYd}~qd}~wwdS)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.

    rYzError '%s' patching %sN)r�r�r�r#�	Exceptionr�r/r
�Warnr-r�uexcr.�WarningCode�cannot_processr2)r�r8r��
normalized�final_ropath�e�filenamerrr�integrate_patch_iterss(��
�����r�cs,dd�|D�}�r�fdd�|D�}t|�S)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.

    cSsg|]}t|��qSr)r'r�rrrr�:r�z%tarfiles2rop_iter.<locals>.<listcomp>csg|]}t|���qSr)r(r��r!rrr�=s)r�)�tarfile_listr!�
diff_itersrr�r�tarfiles2rop_iter3sr�cCs>tt|g�}d}|D]
}d}||j|�q
|��|��|S)zxWrite out ropaths in rop_iter starting at base_path

    Returns 1 if something was actually written, 0 otherwise.

    rrB)r*�ROPath_IterWriterr3r4r5)r�rop_iterr9�
return_valrTrrr�
Write_ROPathsAsr�c@r~)
r�z�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.

    cCs||_d|_d|_dSr)rr��dir_new_pathr�rrrrtXs
zROPath_IterWriter.__init__cCs�|��s%|jdksJ|j��|j�|�}|��r%|��r |��|�|�|j�|�|_|j��r=tj	s=|dks<J|��n|j�
�||_dS)z.Write ropath.  Only handles the directory caserN)r�r3rr�r#r�r�r�r�forcer�r�)rsr3rT�new_pathrrrr�^s


zROPath_IterWriter.start_processcCr�)z1Update information of a directory when leaving itN)r�r�r�r|rrrr�qr�zROPath_IterWriter.end_processc	CsHt�td�t�|���|jftjjdt�	|���|jf�|�
�S)z;Can fast process (no recursion) if ropath isn't a directoryzWriting %s of type %sz%s %s)r
r,r-rr.r/rKr0�patch_file_writingr2r��rsr3rTrrrr�vs
��
z"ROPath_IterWriter.can_fast_processcCs"|��r|�|j�|��dSdS)z)Write non-directory ropath to destinationN)r#r�rr�r�rrrr�~s�zROPath_IterWriter.fast_processNr�rrrrr�Qsr�)r))�builtinsrrrrrfr`r��	duplicityrrrr	r
rrr
r�duplicity.lazy�duplicity.pathr�rrr"rr&r(r'rGrM�	ITRBranchr+rr�r�r�r�r�r�r�r�rrrr�<module>sL

!+,@;351&


https://t.me/RX1948 - 2025