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__/dup_collections.cpython-310.pyc
o

��/a��@s2dZddlmZddlmZddlmZddlmZddlmZddlZddlm	Z	dd	lm
Z
dd
lmZddlmZddlm
Z
dd
lmZddlmZddlmZddlmZejdkrdeefZnefZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)z6Classes and functions on collections of backup volumes�)�str)�zip)�map)�range)�objectN)�log)�file_naming)�path)�util)�dup_time)�config)�manifest)�GPGError)�c@seZdZdS)�CollectionsErrorN)�__name__�
__module__�__qualname__�rr�;/usr/lib/python3/dist-packages/duplicity/dup_collections.pyr1src@s�eZdZdZdd�Zdd�Zd(dd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zd)dd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�ZdS)*�	BackupSetzE
    Backup set - the backup information produced by one session
    cCsL||_d|_i|_d|_d|_d|_d|_d|_d|_d|_	g|_
||_dS)zN
        Initialize new backup set, only backend is required at first
        FN)�backend�info_set�volume_name_dict�remote_manifest_name�local_manifest_path�time�
start_time�end_time�partial�	encrypted�
files_changed�action)�selfrr"rrr�__init__9s
zBackupSet.__init__cC�|jS)z8
        Assume complete if found manifest file
        )r�r#rrr�is_completeJ�zBackupSet.is_completeNcCs|st�|�}|r|jdks|jdksdS|js|�|�n2|j|jkr&dS|j|jkr.dS|j|jks:|j|jkr<dSt|j	�t|j	�krP|j
rP|j	rP|j	|_	|jrZ|�|�dS|j
dusaJ�|j
|jvs{Jd|j
t�|j|j
�t�|�f��||j|j
<dS)a�
        Add a filename to given set.  Return true if it fits.

        The filename will match the given set if it has the right
        times and is of the right type.  The information will be set
        from the first filename given.

        @param filename: name of file to add
        @type filename: string

        @param pr: pre-computed result of file_naming.parse(filename)
        @type pr: Optional[ParseResults]
        �full�incFNz�Volume %d is already in the volume list as "%s".
                "%s" has the same volume number.
                Please check your command line and retry.T)r�parse�typer�set_inforrr�boolr rr
�set_manifest�
volume_numberrr
�fsdecode�r#�filename�prrrr�add_filenamePs<


����zBackupSet.add_filenamecCsP|jrJ�|j|_|j|_|j|_|j|_|j|_|j|_t|j�|_d|_dS)z�
        Set BackupSet information from ParseResults object

        @param pr: parse results
        @type pf: ParseResults
        TN)rr,rrrrr.r )r#r4rrrr-�s

zBackupSet.set_infocCs|��}|��|_dS�N)�get_manifest�get_files_changedr!)r#�mfrrr�set_files_changed�szBackupSet.set_files_changedcCs�|jrJd||jf��||_|jdkrtj��}ng}|D]2}t�|�}|rP|jrP|j|jkrP|j	|j	krP|j
|j
krP|j|jkrPtj�|�|_
|��dSqdS)zG
        Add local and remote manifest filenames to backup set
        z@Cannot set filename of remote manifest to %s; already set to %s.�	replicateN)rr"r�archive_dir_path�listdirrr+r
r,rrr�appendrr:)r#�remote_filename�local_filename_list�local_filenamer4rrrr/�s,��


���zBackupSet.set_manifestc	Cs�|��}|��z|j�|�Wnty't�td�dd�|D��Ynw|jdkr3t	j
��}ng}|D]=}t�
|�}|rt|j|jkrt|j|jkrt|j|jkrtz
t	j
�|���Wq7tyst�td�dd�|D��Yq7wq7t��dS)z@
        Remove all files in set, both local and remote
        zBackupSet.delete: missing %scS�g|]}t�|��qSr�r
r1��.0�frrr�
<listcomp>��z$BackupSet.delete.<locals>.<listcomp>r;cSrBrrCrDrrrrG�rHN)�
get_filenames�reverser�delete�	Exceptionr�Debug�_r"rr<r=rr+rrrr>r
�release_lockfile)r#�rfnr@�lfnr4rrrrK�s0�

��zBackupSet.deletecCs@g}|jr|�|j�|�t|j����dd�ttj	|��S)z0
        For now just list files in set
        z[%s]�, )
rr>�extend�listr�values�joinrr
r1)r#�filelistrrr�__str__�s
zBackupSet.__str__cCst�|jp|j�S)z@
        Return time string suitable for log statements
        )r�timetoprettyrrr&rrr�get_timestr��zBackupSet.get_timestrTcCs�|js|jst�td�tjj�|jsJd��|r|��nd}|jr&|��}|r;|jr;|r;||kr;t�td�tjj	�|sM|jrC|}n
t�td�tjj
�|��dS)zA
        Make sure remote manifest is equal to local one
        z6Fatal Error: No manifests found for most recent backupzif only one, should be remoteNz�Fatal Error: Remote manifest does not match local one.  Either the remote backup set or the local archive directory has been corrupted.z;Fatal Error: Neither remote nor local manifest is readable.)rrr�
FatalErrorrN�	ErrorCode�no_manifests�get_remote_manifest�get_local_manifest�mismatched_manifests�unreadable_manifests�
check_dirinfo)r#�check_remote�remote_manifest�local_manifestrrr�check_manifests�s(
�
�
�zBackupSet.check_manifestscCs@|jsJ�|j��}t�td�|jjt|�f�t���	|�S)zG
        Return manifest object by reading local manifest file
        z!Processing local manifest %s (%s))
r�get_datar�InforN�name�lenr
�Manifest�from_string)r#�manifest_bufferrrrr`�s


�zBackupSet.get_local_manifestc
Cs�|jsJ�z	|j�|j�}Wn%ty3}zt�td�t�|j�t�	|�f�WYd}~dSd}~wwt�
td�t�|j�t|�f�t�
��|�S)zG
        Return manifest by reading remote manifest on backend
        z)Error processing remote manifest (%s): %sNz"Processing remote manifest %s (%s))rrrhrr�ErrorrNr
r1�uexcrirkr
rlrm)r#rn�messagerrrr_s

���
�zBackupSet.get_remote_manifestcCs|jr|��S|��S)zK
        Return manifest object, showing preference for local copy
        )rr`r_r&rrrr7szBackupSet.get_manifestcs^�jsJ�t�j���}|���fdd�|D�}�jr-t��j�}|r-|js-|�	�j�|S)zJ
        Return sorted list of (remote) filenames of files in set
        csg|]}�j|�qSr)r)rE�xr&rrrG rHz+BackupSet.get_filenames.<locals>.<listcomp>)
rrTr�keys�sortrrr+rr>)r#�volume_num_list�volume_filenamesr4rr&rrIs

zBackupSet.get_filenamescCs |jr|jS|jr|jSJd��)zH
        Return time if full backup, or end_time if incremental
        rz'Neither self.time nor self.end_time set)rrr&rrr�get_time+s
zBackupSet.get_timecCr%r6)r!r&rrrr85szBackupSet.get_files_changedcCstt|j����S)z9
        Return the number of volumes in the set
        )rkrTrrsr&rrr�__len__8r[zBackupSet.__len__cCs@|j|jko|j|jko|j|jko|j|jkot|�t|�kS)zB
        Return whether this backup set is equal to other
        )r,rrrrk)r#�otherrrr�__eq__>s
�
�
��zBackupSet.__eq__r6)T)rrr�__doc__r$r'r5r-r:r/rKrXrZrgr`r_r7rIrwr8rxrzrrrrr5s(
1


	
rc@steZdZdZdd�Zdd�Zdd�Zdd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zddd�Zdd�Z
dd�Zdd�ZdS)�BackupChainz�
    BackupChain - a number of linked BackupSets

    A BackupChain always starts with a full backup set and continues
    with incremental ones.
    cCs"||_d|_g|_d\|_|_dS)zI
        Initialize new chain, only backend is required at first
        N�NN)r�fullset�incset_listrr)r#rrrrr$PszBackupChain.__init__cCs:|jst|t�s
J�||_|jsJ�|j|j|_|_dS)z%
        Add full backup set
        N)r~�
isinstancerrrr)r#r~rrr�set_fullYs
zBackupChain.set_fullcCs�|j|jkr
|j�|�n7|jr/|j|jdjkr/|j|jdjkr/t�td��||jd<nt�td�t�|j�t�|j�f�dS|j|_t�td�t�|j�t�|j�f�|js`J�dS)zL
        Add incset to self.  Return False if incset does not match
        ���z'Preferring Backupset over previous one!z;Ignoring incremental Backupset (start_time: %s; needed: %s)Fz;Added incremental Backupset (start_time: %s / end_time: %s)T)	rrrr>rrirNrrY)r#�incsetrrr�add_incbs*


��


��
zBackupChain.add_incFcCsJtt|j�ddd�D]	}|j|��q|jr!|s#|j��dSdSdS)z<
        Delete all sets in chain, in reverse order
        �r�N)rrkrrKr~)r#�	keep_full�irrrrKzs

�zBackupChain.deletecs �fdd�|jD�}|jg|S)zI
        Return a list of sets in chain earlier or equal to time
        csg|]	}|j�kr|�qSr�r�rE�s�rrrrG��z0BackupChain.get_sets_at_time.<locals>.<listcomp>�rr~)r#r�
older_incsetsrr�r�get_sets_at_time�szBackupChain.get_sets_at_timecCs|jr|jdS|jS)z0
        Return last BackupSet in chain
        r�r�r&rrr�get_last�s
zBackupChain.get_lastcCr%)zF
        Return first BackupSet in chain (ie the full backup)
        )r~r&rrr�	get_first�r(zBackupChain.get_firstcCsdt�|j�t�|j�fS)zf
        Return a short one-line description of the chain,
        suitable for log messages.
        z	[%s]-[%s])rrYrrr&rrr�
short_desc�s
�zBackupChain.short_desc�c	Csdg}|��D])}|jrd}|j}nd}|j}|jrd}nd}|�d||t�|�t|�|f�q|S)z>
        Return summary, suitable for printing to log
        r)r*�enc�noencz
%s%s %s %d %s)�get_all_setsrrr r>r�timetostringrk)r#�prefix�lr��btyperr�rrr�to_log_info�s$zBackupChain.to_log_infoc
Cs�d}dtd�t�|j�td�t�|j�td�t|j�dftd�|��f|td�td	�td
�fg}|��D]#}|j	rGtd�}|j	}ntd�}|j}|�
||t�|�t|�f�q:|�
d�d
�|�S)zD
        Return string representation, for testing purposes
        z%20s   %30s   %15s�-------------------------zChain start time: zChain end time: z#Number of contained backup sets: %dr�z%Total number of contained volumes: %d�Type of backup set:�Time:zNum volumes:�Full�Incremental�
)rNrrYrrrkr�get_num_volumesr�rr>rV)r#�
set_schemar�r�r�rrrrrX�s*���	 

zBackupChain.__str__cCs"d}|��D]}|t|�7}q|S)zA
        Return the total number of volumes in the chain
        r)r�rk)r#�nr�rrrr��szBackupChain.get_num_volumescCs|jr
|jg|jS|jS)z9
        Return list of all backup sets in chain
        )r~rr&rrrr��szBackupChain.get_all_setsN�F)r�)rrrr{r$r�r�rKr�r�r�r�r�rXr�r�rrrrr|Is		
		
	r|c@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zddd�Zdd
d�Z	ddd�Z
ddd�Zd
S)�SignatureChainz~
    A number of linked SignatureSets

    Analog to BackupChain - start with a full-sig, and continue with
    new-sigs.
    cCs>|r
|d|_|_nd||_|_d|_g|_d\|_|_dS)a�
        Return new SignatureChain.

        local should be true iff the signature chain resides in
        config.archive_dir_path and false if the chain is in
        config.backend.

        @param local: True if sig chain in config.archive_dir_path
        @type local: Boolean

        @param location: Where the sig chain is located
        @type location: config.archive_dir_path or config.backend
        Nr})r<r�fullsig�inclistrr)r#�local�locationrrrr$�szSignatureChain.__init__cCsL|jrtd�}ntd�}g}|jr|�|j�|�|j�d|d�|�fS)z>
        Local or Remote and List of files in the set
        r��remotez%s: [%s]rR)r<rNr�r>rSr�rV)r#�placerWrrrrX�s
zSignatureChain.__str__cCs*|D]}t|�tvrJd||f��qdS)z?
        Check to make sure times are in whole seconds
        rzTime %s in %s wrong typeN)r,�
integer_types)r#�	time_listrrrr�check_timess
��zSignatureChain.check_timescCs|jrdSdS)zQ
        Return true if represents a signature chain in archive_dir_path
        TF)r<r&rrr�islocalszSignatureChain.islocalNcCs�|st�|�}|sdS|jr0|jdkrdS|j|jkrdS|j�|�|�|jg�|j|_dS|jdkr7dS||_|�|j	|j	g�|j	|j	|_|_dS)zM
        Add new sig filename to current chain.  Return true if fits
        N�new-sigr��full-sig)
rr+r�r,rrr�r>r�rr2rrrr5s&


zSignatureChain.add_filenamecs>�jsJ��jr�fdd��n�jj��fdd���|�D�S)zt
        Return ordered list of signature fileobjs opened for reading,
        optionally at a certain time
        cst��jj|f�}|�d�S)z:Open filename in archive_dir_path, return filtered fileobj�rb)r	�DupPathr<rj�
filtered_open)r3�sig_dpr&rr�filename_to_fileobj>s
z8SignatureChain.get_fileobjs.<locals>.filename_to_fileobjcsg|]}�|��qSrrrD)r�rrrGD�z/SignatureChain.get_fileobjs.<locals>.<listcomp>)r�r<r�get_fileobj_readrI)r#rr)r�r#r�get_fileobjs7s

zSignatureChain.get_fileobjsFcCs�|jr+tt|j�ddd�D]
}|j�|j|���q|s)|j�|j���dSdS|js0J�|jdd�}|��|sC|�|j�|j�|�dS)z3
        Remove all files in signature set
        r�r�N)	r<rrkr�r>rKr�rrJ)r#r�r��inclist_copyrrrrKFs�
zSignatureChain.deletecs>|jr|jg}ng}|j}�r�fdd�|D�}|�|�|S)zP
        Return ordered list of filenames in set, up to a provided time
        cs g|]}t�|�j�kr|�qSr)rr+r)rEr�r�rrrGcs z0SignatureChain.get_filenames.<locals>.<listcomp>)r�r�rS)r#rr�r�rr�rrIXs

zSignatureChain.get_filenamesr6r�)rrrr{r$rXr�r�r5r�rKrIrrrrr��s
	

r�c@s�eZdZdZdd�Zdd�Zdd�Zd2d	d
�Zdd�Zd
d�Z	dd�Z
dd�Zd3dd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�ZdS)4�CollectionsStatusz:
    Hold information about available chains and sets
    cCsL||_||_||_d|_d|_d|_d|_g|_g|_d|_	d|_
d|_dS)z7
        Make new object.  Does not set values
        N)rr<r"�matched_chain_pair�all_backup_chains�other_backup_chains�all_sig_chains�local_orphaned_sig_names�remote_orphaned_sig_names�orphaned_backup_sets�incomplete_backup_sets�
values_set)r#rr<r"rrrr$ms
zCollectionsStatus.__init__cCs�d|jjjfd|jfg}tt|j��D]}|�d|f�||j|�d�7}q|j	r<|�d�||j	d�d�7}|�dt|j
�f�|�dt|j�f�|S)	zP
        Return summary of the collection, suitable for printing to log
        z
backend %szarchive-dir %szchain-no-sig %d� zchain-completer�zorphaned-sets-num %dzincomplete-sets-num %d)r�	__class__rr<rrkr�r>r�r�r�r��r#r�r�rrrr��s
�
zCollectionsStatus.to_log_infocCshtd�dtd�|jjjftd�|jr|jjndfg}|�dtddt|j	��t|j	��t
t|j	��D]!}|�td	�|d
t|j	�f�|�t|j	|��|�d�q6|jro|�dtd��|�t|jd
��n|�td
��|j
s||jr�|�tddt|j
��t|j
�f�|�tddt|j��t|j�f�|�td��n|�td��d�|�S)z9
        Return string summary of the collection
        zCollection Statusz-----------------zConnecting with backend: %szArchive dir: %s�Noner�z Found %d secondary backup chain.z!Found %d secondary backup chains.zSecondary chain %d of %d:r�r�z9Found primary backup chain with matching signature chain:z-No backup chains with active signatures foundz/Also found %d backup set not part of any chain,z0Also found %d backup sets not part of any chain,zand %d incomplete backup set.zand %d incomplete backup sets.zEThese may be deleted by running duplicity with the "cleanup" command.z,No orphaned or incomplete backup sets found.)rNrr�rr<�uc_namer>�ngettextrkr�rrr�r�r�rVr�rrrrX�sR
�����
��
��
�
zCollectionsStatus.__str__r�c
Csd|_|j��}t�tddt|��t|��|jdkr"|j�	�}ng}t�tddt|��t|��g}|D]}t
�|�}|rH|jrH|�
|�q7|�||�\}|_|_|�|�}||_t|�t|j�ksjJd��|�d�\}|_|jd	|d
�\}	|_|�||	|�|�|�|S)a
        Set values from archive_dir_path and backend.

        Returns self for convenience.  If sig_chain_warning is set to None,
        do not warn about unnecessary sig chains.  This is because there may
        naturally be some unecessary ones after a full backup.
        r�z%d file exists on backendz%d files exist on backendr;z%d file exists in cachez%d files exist in cachez7get_sorted_chains() did something more than re-orderingTF)rW)r�rrTrrMr�rkr"r<r=rr+rr>�get_backup_chainsr�r��get_sorted_chainsr��get_signature_chainsr�r��set_matched_chain_pair�warn)
r#�sig_chain_warning�backend_filename_listr@�partialsrAr4�
backup_chains�local_sig_chains�remote_sig_chainsrrr�
set_values�sP
��
��


��
���
�
zCollectionsStatus.set_valuescCs�|o|�|�}||_|dd�|_d|_|rl|rl|d}tt|�ddd�D]E}||j|jkr1n.t|���dkr^||j|��djkr^t�	t
d��|j�|j
d�|j
dd�|_
nq&|jdurk|||f|_|jrz|j�|jd�dSdS)a9
        Set self.matched_chain_pair and self.other_sig/backup_chains

        The latest matched_chain_pair will be set.  If there are both
        remote and local signature chains capable of matching the
        latest backup chain, use the local sig chain (it does not need
        to be downloaded).
        Nr�r�����zGWarning, discarding last backup set, because of missing signature file.)r�r�r�r�rrkrr�r�WarnrNr�r>r�remove)r#�
sig_chainsr��latest_backup_chainr�rrrr��s*	
�z(CollectionsStatus.set_matched_chain_paircCs|jsJ�|jr#t�tddt|j��dd�ttj	|j��tj
j�|jrAt�tddt|j��dd�ttj	|j��tj
j�|j
rS|rS|jsSt�td�tj
j�|jr`t�td�tj
j�|jrt�tdd	t|j��dd�tt|j��tj
j�d
Sd
S)zN
        Log various error messages if find incomplete/orphaned files
        z;Warning, found the following local orphaned signature file:z<Warning, found the following local orphaned signature files:r�z<Warning, found the following remote orphaned signature file:z=Warning, found the following remote orphaned signature files:z;Warning, found signatures but no corresponding backup fileszIWarning, found incomplete backup sets, probably left from aborted sessionz2Warning, found the following orphaned backup file:z3Warning, found the following orphaned backup files:N)r�r�rr�r�rkrVrr
r1�WarningCode�orphaned_sigr�r�r�rN�
unmatched_sigr��incomplete_backupr�r�orphaned_backup)r#r�rrrr�$sV
��������
�
������zCollectionsStatus.warncs�t�td�dd�|D��g���fdd�}|D]}||�q����\�}gg�����fdd�}�D]}||�q6��|fS)a"
        Split given filename_list into chains

        Return value will be tuple (list of chains, list of sets, list
        of incomplete sets), where the list of sets will comprise sets
        not fitting into any chain, and the incomplete sets are sets
        missing files.
        z/Extracting backup chains from list of files: %scSrBrrCrDrrrrGWrHz7CollectionsStatus.get_backup_chains.<locals>.<listcomp>cs�t�|�}�D]}|�||�rt�td�t�|�f�dSqt�td�t�|�f�t�j	�j
�}|�||�rA��|�dSt�td�t�|��dS)zO
            Try adding filename to existing sets, or make new one
            zFile %s is part of known setz4File %s is not part of a known set; creating new setz+Ignoring file (rejected by backup set) '%s'N)rr+r5rrMrNr
r1rrr"r>)r3r4�set�new_set)r#�setsrr�add_to_sets[s
�z8CollectionsStatus.get_backup_chains.<locals>.add_to_setscs�|jdkr!t�j�}|�|���|�t�td�|���dS|jdks(J��D]}|�	|�rCt�td�|�
�|��f�dSq*t�td�|�
�f���|�dS)zL
            Try adding set to existing chains, or make new one
            r)zFound backup chain %sr*z%Added set %s to pre-existing chain %szFound orphaned set %sN)r,r|rr�r>rrMrNr�r�rZ)r��	new_chain�chain)�chains�
orphaned_setsr#rr�
add_to_chainsrs




��z:CollectionsStatus.get_backup_chains.<locals>.add_to_chains)rrMrN�get_sorted_sets)r#�
filename_listr�rF�incomplete_setsr�r�r)r�r�r#r�rr�Ms
	�



z#CollectionsStatus.get_backup_chainscCsvgg}}|D]"}|��s|�|�q|jdkr!|�|j|f�q|�|j|f�q|jdd�d�dd�|D�|fS)zM
        Sort set list by end time, return (sorted list, incomplete)
        r)cSs|dS)Nrr�rrrrr�<lambda>�sz3CollectionsStatus.get_sorted_sets.<locals>.<lambda>��keycS�g|]}|d�qS�r�r�rE�prrrrG�r�z5CollectionsStatus.get_sorted_sets.<locals>.<listcomp>)r'r>r,rrrt)r#�set_list�time_set_pairsr�r�rrrr��s

z!CollectionsStatus.get_sorted_setsNc
s����fdd�}��fdd�}gg}}|�D])}t�|�}|r@|jdkr6|�}	|	�||�s0J�|�|	�q|jdkr@|�|�qg}
|jdd�d	�|D]}|D]	}|�|�rZnqQ|
�|�qM||
fS)
z�
        Find chains in archive_dir_path (if local is true) or backend

        Use filelist if given, otherwise regenerate.  Return value is
        pair (list of chains, list of signature paths not in any
        chains).
        cs2�dur�S�r�jdkr�j��SgS�j��S)Nr;)r"r<r=rrTr�rWr�r#rr�get_filelist�s


z<CollectionsStatus.get_signature_chains.<locals>.get_filelistcs�rtd�j�Std�j�S)z:
            Return new empty signature chain
            TF)r�r<rr)r�r#rr�get_new_sigchain�sz@CollectionsStatus.get_signature_chains.<locals>.get_new_sigchainr�r�cSstt�|�j�Sr6)�intrr+rr�rrrr��sz8CollectionsStatus.get_signature_chains.<locals>.<lambda>r�)rr+r,r5r>rt)
r#r�rWr�r�r��new_sig_filenamesr3r4r��orphaned_filenames�sig_filenamer�rr�rr��s.






�
�
�z&CollectionsStatus.get_signature_chainscCs�i}|D]}|j|vr||j�|�q|g||j<qt|���}|��g}|D]>}||}t|�dkr=|�|d�q)t|�dksEJ�|djrY|�|d�|�|d�q)|�|d�|�|d�q)|S)zL
        Return chains sorted by end_time.  If tie, local goes last
        r�rr�)rr>rTrsrtrkr)r#�
chain_list�endtime_chain_dictr��sorted_end_times�sorted_chain_listrrrrr��s&

z#CollectionsStatus.get_sorted_chainscst|jstd���fdd�|jD�}t|�dkrtd��t|�dkr%|dS�fdd�|jD�}|r5|dS|jdS)	z�
        Return backup chain covering specified time

        Tries to find the backup chain covering the given time.  If
        there is none, return the earliest chain before, and failing
        that, the earliest chain.
        zNo backup chains foundc�,g|]}|j�kr|jkrnn|�qSr�rr�rE�cr�rrrG���z>CollectionsStatus.get_backup_chain_at_time.<locals>.<listcomp>r�zTwo chains cover the given timerc�g|]	}|j�kr|�qSrr�rr�rrrG�r�r�)r�rrk)r#r�covering_chains�
old_chainsrr�r�get_backup_chain_at_time�s
z*CollectionsStatus.get_backup_chain_at_timecs�|jstd���fdd�|jD�}|r|dS�fdd�|jD�}|r'|dS|jd}�|jkrFt�td�t�|j�tjj	t�
|j��|S)z�
        Return signature chain covering specified time

        Tries to find the signature chain covering the given time.  If
        there is none, return the earliest chain before, and failing
        that, the earliest chain.
        zNo signature chains foundcrrrrr�rrrG
rzACollectionsStatus.get_signature_chain_at_time.<locals>.<listcomp>r�cr	rr�rr�rrrGr�rz]No signature chain for the requested time. Using oldest available chain, starting at time %s.)r�rrrr�rNrrYr��no_sig_for_timer�)r#rr
r�oldestrr�r�get_signature_chain_at_times"



�
�z-CollectionsStatus.get_signature_chain_at_timecCsh|jsJ�g}g}|j|j}|D]}|jr|�|���q|�|���q||j7}||j7}||fS)z�
        Return list of the names of extraneous duplicity files

        A duplicity file is considered extraneous if it is
        recognizable as a duplicity file, but isn't part of some
        complete backup set, or current signature chain.
        )r�r�r�rrSrIr�r�)r#�local_filenames�remote_filenames�ext_containers�set_or_chainrrr�get_extraneous s


z CollectionsStatus.get_extraneouscCs$dd�|D�}|��dd�|D�S)z@Return new list containing same elems of setlist, sorted by timecSsg|]}|��|f�qSr�rwr�rrrrG7sz/CollectionsStatus.sort_sets.<locals>.<listcomp>cSr�r�rr�rrrrG9r�)rt)r#�setlist�pairsrrr�	sort_sets5szCollectionsStatus.sort_setscC�F|jsJ�g}|jD]}|j|kr |jr||jdur |�|�q
|S)a�
        Returns a list of backup chains older than the given time t

        All of the times will be associated with an intact chain.
        Furthermore, none of the times will be of a chain which a newer
        set may depend on.  For instance, if set A is a full set older
        than t, and set B is an incremental based on A which is newer
        than t, then the time of set A will not be returned.
        r�)r�r�rr�r>�r#�trr�rrr�get_chains_older_than;�



�
�z'CollectionsStatus.get_chains_older_thancCr)a�
        Returns a list of signature chains older than the given time t

        All of the times will be associated with an intact chain.
        Furthermore, none of the times will be of a chain which a newer
        set may depend on.  For instance, if set A is a full set older
        than t, and set B is an incremental based on A which is newer
        than t, then the time of set A will not be returned.
        r)r�r�rr�r>rrrr�get_signature_chains_older_thanOrz1CollectionsStatus.get_signature_chains_older_thancC�
|�d�S)zY
        Return the time of the last full backup,
        or 0 if there is none.
        r�)�get_nth_last_full_backup_timer&rrr�get_last_full_backup_timec�
z+CollectionsStatus.get_last_full_backup_timecCs |�|�}|durdS|��jS)z`
        Return the time of the nth to last full backup,
        or 0 if there is none.
        Nr)�get_nth_last_backup_chainr�r)r#r�r�rrrr js

z/CollectionsStatus.get_nth_last_full_backup_timecCr)zr
        Return the last full backup of the collection,
        or None if there is no full backup chain.
        r�)r#r&rrr�get_last_backup_chainur"z'CollectionsStatus.get_last_backup_chaincCsZ|jsJ�|dksJ�t|j�|krdS|jdd�}|jdd�d�|��||dS)a!
        Return the nth-to-last full backup of the collection,
        or None if there is less than n backup chains.

        NOTE: n = 1 -> time of latest available chain (n = 0 is not
        a valid input). Thus the second-to-last is obtained with n=2
        rather than n=1.
        rNcSs
|��jSr6)r�rr�rrrr��s
z=CollectionsStatus.get_nth_last_backup_chain.<locals>.<lambda>r�r�)r�rkr�rtrJ)r#r��sortedrrrr#|s
	z+CollectionsStatus.get_nth_last_backup_chaincCs,g}|�|�D]	}|�|���q|�|�S)a�
        Returns a list of backup sets older than the given time t

        All of the times will be associated with an intact chain.
        Furthermore, none of the times will be of a set which a newer
        set may depend on.  For instance, if set A is a full set older
        than t, and set B is an incremental based on A which is newer
        than t, then the time of set A will not be returned.
        )rrSr�r)r#r�old_setsr�rrr�get_older_than�s

z CollectionsStatus.get_older_thancsV|jsJ��fdd�|jD�}g}|D]}�fdd�|��D�}|�|�q|�|�S)a

        Returns list of old backup sets required by new sets

        This function is similar to the previous one, but it only
        returns the times of sets which are old but part of the chains
        where the newer end of the chain is newer than t.
        csg|]	}|j�kr|�qSrr�r�rrrrG�r�z=CollectionsStatus.get_older_than_required.<locals>.<listcomp>csg|]
}|���kr|�qSrrr�r(rrrG�s)r�r�r�rSr)r#r�
new_chains�result_setsr�r&rr(r�get_older_than_required�s

z)CollectionsStatus.get_older_than_requiredc	Cs�|}d|vrd|�dd�d}|jsdS|jd��}g}g}t�|�}|D]$}dd�|��D�}||vrK|�|�|�|�}|�|��|d�q't|t	t
||���S)	z=
        Returns time line of specified file changed
        r��"z\x20r�r�cSr�r�r)rE�fileinforrrrG�r�z=CollectionsStatus.get_file_changed_record.<locals>.<listcomp>r)�replacer�r�r
�fsencoder8r>�index�FileChangedStatusrTr)	r#�filepath�modified_filepath�all_backup_set�specified_file_backup_set�specified_file_backup_type�bsrWr0rrr�get_file_changed_record�s"


�z)CollectionsStatus.get_file_changed_recordr�r6)rrrr{r$r�rXr�r�r�r�r�r�r�rrrrrrr!r r$r#r'r+r8rrrrr�is2
-5&)<
3r�c@seZdZdd�Zdd�ZdS)r1cCs||_||_dSr6)r2�
fileinfo_list)r#r2r9rrrr$�s
zFileChangedStatus.__init__c	Cs�d}dtd�|jtd�t|j�|td�td�td�fg}|jD]'}|d}|d	}|jr4td
�}ntd�}|�||t�|���|�	�f�q"|�d�d�
|�S)
Nz%20s   %30s  %20sr�zFile: %szTotal number of backup: %dr�r�zType of file change:rr�r�r�r�)rNr2rkr9rr>rrYrw�titlerV)r#r�r�r��backup_type�
backup_setr,rrrrX�s�

$

zFileChangedStatus.__str__N)rrrr$rXrrrrr1�sr1)r{�builtinsrrrrr�sys�	duplicityrrr	r
rrr
�
duplicity.gpgr�version_infor�r�rLrrr|r�r�r1rrrr�<module>sB

	f

https://t.me/RX1948 - 2025