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

�wa;r�@s\dZddlmZddlmZe��ddlmZddlmZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlTdZdaGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd�de!�Z"Gdd�de"�Z#Gdd�de$�Z%dS)z�Wrapper class around a file like "/usr/bin/env"

This class makes certain file operations more convenient and
associates stat information with filenames

�)�print_function)�standard_library)�str)�objectN)�
cached_ops)�config)�dup_time)�file_naming)�gpg)�librsync)�log)�tarfile)�util)�*i�c@seZdZdZdZdS)�
StatResultz3Used to emulate the output of os.stat() and relatedrN)�__name__�
__module__�__qualname__�__doc__�st_mode�rr�0/usr/lib/python3/dist-packages/duplicity/path.pyr;src@seZdZdS)�
PathExceptionN)rrrrrrrrBsrc@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�Zd?d2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Z dS)@�ROPathz�Read only Path

    Objects of this class doesn't represent real files, so they don't
    have a name.  They are required to be indexed though.

    NcCs.d\|_|_||_d\|_|_d\|_|_dS)zROPath initializer�NNN)�opened�fileobj�index�stat�type�mode�devnums)�selfrrrrr�__init__MszROPath.__init__c
Cs|jsd|_|jj}t�|�rd|_nAt�|�rd|_n8t�|�r%d|_n/t�|�r.d|_n&t�|�r>tt	�
|���d��t�|�rGd|_n
t�
|�rPd	|_ntd
��t�|�|_|jdvr�zt�|jj�t�|jj�f|_WdSt�td�t	�
|���|jjf�d
|_YdSdS)z4Set the value of self.type, self.mode from self.statN�reg�dir�sym�fifozis a socket, unsupported by tar�sock�chr�blkzUnknown type)r*r+z7Warning: %s invalid devnums (0x%X), treating as (0, 0).�rr)rr r�S_ISREG�S_ISDIR�S_ISLNK�S_ISFIFO�S_ISSOCKrr�fsdecode�get_relative_path�S_ISCHR�S_ISBLK�S_IMODEr!�os�major�st_rdev�minorr"r�Warn�_)r#rrrr�
set_from_statTs@




�


�
��zROPath.set_from_statcCsd\|_|_dS)z*Black out self - set type and stat to NonerN)r r�r#rrr�blankwszROPath.blankcCs|jS)z!True if corresponding file exists�r r>rrr�exists{sz
ROPath.existscC�
|jdkS)z(True if self corresponds to regular filer%r@r>rrr�isreg�
zROPath.isregcCrB)zTrue if self is dirr&r@r>rrr�isdir�rDzROPath.isdircCrB)zTrue if self is symr'r@r>rrr�issym�rDzROPath.issymcCrB)zTrue if self is fifor(r@r>rrr�isfifo�rDz
ROPath.isfifocCrB)zTrue is self is socketr)r@r>rrr�issock�rDz
ROPath.issockcCs|jdkp	|jdkS)zTrue is self is a device filer*r+r@r>rrr�isdev��zROPath.isdevcC�|jjS)z$Return device number path resides on)r�st_devr>rrr�	getdevloc��zROPath.getdevloccCrK)z'Return length in bytes from stat object)r�st_sizer>rrr�getsize�rNzROPath.getsizecCst|jj�S)z"Return mod time of path in seconds)�intr�st_mtimer>rrr�getmtime��zROPath.getmtimecCs|jr	d�|j�SdS)z(Return relative path, created from index�/�.)r�joinr>rrrr3�szROPath.get_relative_pathcCs|j}d|j|j|jfS)z(Return permissions mode, owner and groupz%s:%s %o)r�st_uid�st_gidr!)r#�s1rrr�getperms�szROPath.getpermscCs6|dkr
|jr
|jrJd||j|jf��d|_|jS)z#Return fileobj associated with self�rbz%s %s %sr�rr�r#r!rrr�open�s
�zROPath.opencCs"|�d�}|��}|��rJ�|S)z/Return contents of associated fileobj in stringr\)r_�read�close)r#�fin�bufrrr�get_data�s
zROPath.get_datacCs|jrJ�||_d|_dS)z"Set file object returned by open()Nr])r#rrrr�
setfileobj�s

zROPath.setfileobjcCs�|j}|tjks
|tjkrd|_n]|tjkrtd��|tjkr5d|_|j|_t	|jdj
�r4t�|j�|_n9|tj
krEd|_|j|jf|_n)|tjkrUd|_|j|jf|_n|tjkr^d|_n|tjkrgd|_ntd	|f��|j|_t�|_	ztjr}t�t�|j�d
|j_Wnty�|j|j_Ynwztjr�t�t�|j �d
|j_!Wnty�|j"|j_!Ynwt#|j$�|j_%|jj%dkr�t&�'t(d�|j)�d|j_%|j*|j_+d
S)z5Set data from tarinfo object (part of tarfile module)r%zHard links not supported yetr'�r*r+r&r(zUnknown tarinfo type %s�r�.Warning: %s has negative mtime, treating as 0.N),r r
�REGTYPE�AREGTYPE�LNKTYPEr�SYMTYPE�linkname�symtext�
isinstance�	__class__r�fsencode�CHRTYPE�devmajor�devminorr"�BLKTYPE�DIRTYPE�FIFOTYPEr!rrr�
numeric_owner�KeyErrorr�getpwnam�unamerX�uid�getgrnam�gnamerY�gidrQ�mtimerRrr;r<�uc_name�sizerO)r#�tarinfor rrr�init_from_tarinfo�s\

�



��
�zROPath.init_from_tarinfocCsVt|j|j�}|j|j|_|_|��r|j|_n|��r!|j|_|�	�r)|j|_|S)zReturn ropath copy of self)
rrrr r!rFrnrIr"rA)r#�
new_ropathrrr�
get_ropath�s
zROPath.get_ropathcCs
t��}|jrt�d�|j��|_nd|_|��r |jd7_d|_|j	r�|�
�r4tj|_	|jj
|_nO|��r=tj|_	nF|��rFtj|_	n=|��r`tj|_	|j|_t|jt�r_t�|j�|_n#|��rz|j	dkrntj|_	ntj|_	|j\|_|_n	tdt|j	���|j|_|jj |jj!|_"|_#|jj$dkr�t%�&t'd�t�|�(���d|_)nt*|jj$�|_)zt+�,|j"�d|_-Wnt.y�d|_-Ynwzt+�/|j#�d|_0Wnt.y�d|_0Ynw|j	tjtjfvr�t1t2d	�r�t1t2d
�r�|j\|_|_|Sd\|_|_|S)z�Generate a tarfile.TarInfo object based on self

        Doesn't set size based on stat, because we may want to replace
        data wiht other stream.  Size should be set separately by
        calling function.

        rU�.�/rr*zUnrecognized type rhrfr8r:r,)3r
�TarInforrr2rW�namerEr�r rCrirrOrvrGrwrFrlrnrmro�bytesrIrrrur"rsrtrrr!rXrYr|rrRrr;r<r3r�rQr�getpwuidr{ry�getgrgidr~�hasattrr7)r#�tirrr�get_tarinfosf

�


�
�
��zROPath.get_tarinfocCs�|js|jsdS|js|js|js|jrdS|j|jkrdS|��s*|��s*|��rK|�|�s1dSt|jj�t|jj�kr?dS|jjdkoJ|jjdkS|��rU|j	|j	kS|�
�rd|�|�oc|j|jkSJ�)z6Used to compare two ROPaths.  Doesn't look at fileobjsrr)r rrCrErG�perms_equalrQrRrFrnrIr"�r#�otherrrr�__eq__Ks"
z
ROPath.__eq__cCs|�|�S�N)r�r�rrr�__ne__d�z
ROPath.__ne__rcs
�fdd�}|durdS�js|jsdS�js"|jr"|td��dS|js0�jr0|td��dS�j|jkrD|td	�|j�jf�dS���sP���sP���r���|�se|td
�|�����f�dSt�jj	�t|jj	�kr��jj	dks}|jj	dkr�|td�t
�t|jj	��t
�t�jj	��f�dS���r���|�r�dS|td��dSdS��
�r҈j|jksˆjt�tj�|jkr�dS|td
�|j�jf�dS����r��|�s�|td
�|�����f�dS�j|jk�r|td�|j�jf�dSdSJ�)a'Compare ROPaths like __eq__, but log reason if different

        This is placed in a separate function from __eq__ because
        __eq__ should be very time sensitive, and logging statements
        would slow it down.  Used when verifying.

        Only run if include_data is true.

        cs,td�d|}t�|t������dS)NzDifference found:� )r<r�Noticerr2r3)�
log_string�log_strr>rr�log_diffqsz(ROPath.compare_verbose.<locals>.log_diffFTrzNew file %srzFile %s is missingz!File %%s has type %s, expected %sz(File %%s has permissions %s, expected %sz"File %%s has mtime %s, expected %szData for file %s is differentz%Symlink %%s points to %s, expected %sz+Device file %%s has numbers %s, expected %s)r rr<rCrErGr�r[rQrRr�timetopretty�compare_datarFrnrrqr7�seprIr")r#r��include_datar�rr>r�compare_verbosegsp

�
���
$
�

�
�zROPath.compare_verbosecsZ|�d��|�d����fdd�}	��t�}��t�}||kr%|�dS|s,|�dSq)z8Compare data from two regular files, return true if samer\cs���rJ����rJ�dSr�)rar��f1�f2rrra�sz"ROPath.compare_data.<locals>.closerr)r_r`�_copy_blocksize)r#r�ra�buf1�buf2rr�rr��s



�zROPath.compare_datacCs2|j|j}}|j|jko|j|jko|j|jkS)z:True if self and other have same permissions and ownership)rr!rYrX)r#r�rZ�s2rrrr��s
�
�zROPath.perms_equalcCs�|��r
|�|�d��n^|��rt�|j�nS|��r9t�|j	|j�t
js3t�|j|j
j|j
j�|��dS|��rDt�|j�n'|��rSt�tj��|j�n|��rk|jdkr_d}nd}|j|g|j�R�|�|�dS)z:Copy self to other.  Also copies data.  Other must be Pathr\Nr*�c�b)rC�writefileobjr_rEr7�mkdirr�rF�symlinkrnr�do_not_restore_ownership�lchownrrXrY�setdatarG�mkfiforH�socket�AF_UNIX�bindrIr �makedevr"�copy_attribs)r#r��devtyperrr�copy�s(
zROPath.copycs�t�t�r3���s-�jrtjst���fdd��t���fdd��t���fdd�����dSt�t	�s:J�t
�}�jj�jj|_|_t
�jj�|_|�_�j�_dS)z'Only copy attributes from self to othercst��j�jj�jj�Sr�)r7�chownr�rrXrYr�r�r#rr�<lambda>�sz%ROPath.copy_attribs.<locals>.<lambda>cst��j�j�Sr�)r7�chmodr�r!rr�rrr��scst��jt���jjf�Sr�)r7�utimer��timerrRrr�rrr��sN)ro�PathrFrrr�r�maybe_ignore_errorsr�rrrXrYrQrRr!)r#r�rrr�rr��s
zROPath.copy_attribscCsdt�|j�|jfS)�Return string representationz(%s %s))r�uindexrr r>rrr�__str__�szROPath.__str__r�)r)!rrrrr$r=r?rArCrErFrGrHrIrMrPrSr3r[r_rdrer�r�r�r�r�r�r�r�r�r�r�rrrrrFs>
#7E
Drc@s�eZdZdZe�d�Zdd�Zd<dd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zd=dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd>d0d1�Zd2d3�Zd>d4d5�Zd6d7�Zd8d9�Z d:d;�Z!d/S)?r�z�
    Path class - wrapper around ordinary local files

    Besides caching stat() results, this class organizes various file
    code.
    z	[\\\"\$`]cCs�tjr|s|Stj�tjj|��}g}|r/|tjvr/tj�|�\}}|�d|�|r/|tjvs|r?tj|�t�	tj
��|S|S)Nr)r�renamer7�path�normcaserW�split�insertrrqr�)r#rr��tail�extrarrr�rename_index�s
�zPath.rename_indexrcCsdd\|_|_t|t�rt�|�}||_|�|�|_t	j
j|g|j�R�|_t�
|j�|_|��dS)zPath initializerrN)rrrorrrq�baser�rr7r�rWr�r2r�r�)r#r�rrrrr$	s

z
Path.__init__c
Cs�ztjrt�|j�|_nt�|j�|_Wn(ty<}ztj|j}|dvr0d\|_|_	d|_
n�WYd}~dSd}~ww|��|��rNt�
|j�|_dSdS)zRefresh stat cache)�ENOENT�ENOTDIR�ELOOP�ENOTCONN�ENODEVrN)r�
copy_linksr7rr��lstat�OSError�errno�	errorcoder r!r=rF�readlinkrn)r#�e�
err_stringrrrr�s$�����zPath.setdatacCs,t|dj�rt�|�}|�|j|j|f�S)z'Return new Path with ext added to indexrf)rorprrqr�r)r#�extrrr�append4s
zPath.appendcCs|�|j|�S)z Return new Path with index index)rpr�)r#rrrr�	new_index:szPath.new_indexcCst�|j�S)z#Return list generated by os.listdir)r7�listdirr�r>rrrr�>rTzPath.listdircCs|��o|��S)z/Return true if path is a directory and is empty)rEr�r>rrr�
isemptydirBszPath.isemptydircCs*t|dj�rt�|�}|��o||��vS)z5Return true if path is a directory and contains childrf)rorprrqrEr�)r#�childrrr�containsFs
z
Path.containsr\cCs*|jrJ�|jr
|j}|St|j|�}|S)z�
        Return fileobj associated with self

        Usually this is just the file data on disk, but can be
        replaced with arbitrary data using the setfileobj method.
        )rrr_r�)r#r!�resultrrrr_Ns
�z	Path.opencCsDd|j|t|�t|�g}t�tjd|�dkrtd|��|��dS)z8Make a device file with specified type, major/minor nums�mknodrzError running %sN)r�rr7�spawnvp�P_WAITrr�)r#r r8r:�cmdlistrrrr�\szPath.makedevcCsZt�td�|j�zt�|j�Wnty&tj	s$t
d|jd��Ynw|��dS)z#Make directory(s) at specified pathzMaking directory %szError creating directory %s�N)r�Infor<r�r7�makedirsr�r�r�forcerr�r>rrrr�cs��z
Path.mkdircCsJt�td�|j�|��rt�tj|j	�nt�tj
|j	�|��dS)zRemove this filezDeleting %sN)rr�r<r�rEr�ignore_missingr7�rmdirr��unlinkr�r>rrr�deletems
zPath.deletecCs*t�td�|j�|�d�}|��dS)z#Open the file, write 0 bytes, closezTouching %s�wbN)rr�r<r�r_ra)r#�fprrr�touchvs
z
Path.touchcCs^ddlm}t�td�|j�ttg�}|�|��	�D]}||j
|�q|��|��dS)z2Remove self by recursively deleting files under itr��	selectionzDeleting tree %sN)
�	duplicityr�rr�r<r��IterTreeReducer�PathDeleter�Select�set_iterr�Finishr�)r#r��itrr�rrr�deltree|s
zPath.deltreecCsZ|jrt|j|jdd��S|j�d�}t|�dkr"|ds"td�Std�|dd���S)z Return directory that self is inN���rUrgr)rr�r�r��lenrW�r#�
componentsrrr�get_parent_dir�szPath.get_parent_dircCsL|�d�}	|�t�}|sn|�|�q|��s|��r td��|��dS)z4Copy file object fin to self.  Close both when done.r�rzError closing file objectN)r_r`r��writerarr�)r#rb�foutrcrrrr��s


�zPath.writefileobjcCs$t�|j|j�|��|��dS)z(Rename file at current path to new_path.N)�shutil�mover�r��r#�new_pathrrrr��szPath.renamecCs|�|�|��dS)z;Like rename but destination may be on different file systemN)r�r�rrrrr�s
z	Path.movecCst�|j|�|��dS)zChange permissions of the pathN)r7r�r�r�r^rrrr��sz
Path.chmodcCsv|��r|��s
J�|��}|�d�}|�d�}t�||�}|�|�|��r)J�|��r/J�|�|�|�|�dS)z2Patch self with diff and then copy attributes overr\N)	rC�get_temp_in_same_dirr_r�PatchedFiler�rar�r�)r#�diff_ropath�	temp_path�fbase�fdiff�
patch_fileobjrrr�patch_with_attribs�s



zPath.patch_with_attribscCsF|��}	|�dtt��}|js|Std7atdks"Jd|j��q)z7Return temp non existent path in same directory as selfrzduplicity_temp.i'z(Warning too many temp files created for )r�r�r�_tmp_path_counterr r�)r#�
parent_dirr	rrrr�s�
��zPath.get_temp_in_same_dirNcCs6ddlm}|�|���}|�|���}t�|||�S)z7Compare self to other Path, descending down directoriesrr�)r�r�r�r��Iter�equal)r#r��verboser��selfsel�otherselrrr�compare_recursive�szPath.compare_recursivecCsd|j|j|jfS)r�z
(%s %s %s))rr�r r>rrr�__repr__�rJz
Path.__repr__cCs |s|j}d|j�dd�|�S)z�
        Return quoted version of s (defaults to self.name)

        The output is meant to be interpreted with shells, so can be
        used with os.system.
        z"%s"cSsd|�d�S)N�\r)�group)�mrrrr��szPath.quote.<locals>.<lambda>)r��regex_chars_to_quote�sub)r#�srrr�quote�sz
Path.quotecCs�|d|dkrdksJ�J�d}d}|t|�dkrC||dkr1|||d7}|d7}n
|||7}|d7}|t|�dks|S)z?Return unquoted version of string s, as quoted by above quote()rr��"rfrrrg)r�)r#rr��irrr�unquote�s$
�zPath.unquotecCs$|j�d�}|r|dsJ�|dS)z!Return filename of last componentrUr�)r�r�r�rrr�get_filename�szPath.get_filenamecCs>d�dd�|j�d�D��}|jddkrd|S|r|SdS)z�
        Return string of canonical version of path

        Remove ".", and trailing slashes where possible.  Note that
        it's harder to remove "..", as "foo/bar/.." is not necessarily
        "foo", so we can't use path.normpath()
        rUcSsg|]
}|r|dkr|�qS)rVr)�.0�xrrr�
<listcomp>�sz&Path.get_canonical.<locals>.<listcomp>rr�rV)rWr�r�r�)r#�newpathrrr�
get_canonical�szPath.get_canonical)r)r\r�)"rrrr�re�compilerr�r$r�r�r�r�r�r�r_r�r�r�r�r�r�r�r�rr�r
rrrrr r!r&rrrrr��s<




	



r�c@s$eZdZdZd	dd�Zd
dd�ZdS)�DupPathz�
    Represent duplicity data files

    Based on the file name, files that are compressed or encrypted
    will have different open() methods.
    rNcCsL|r||_nt|�dksJ�t�|d�|_|jsJd��t�|||�dS)z�
        DupPath initializer

        The actual filename (no directory) must be the single element
        of the index, unless parseresults is given.

        rrz%must be a recognizable duplicity fileN)�prr�r	�parser�r$)r#r�r�parseresultsrrrr$	szDupPath.__init__r\cCs�|js|jrJ�|jjr|jjrJ�|r|jjsJ�|jjr%t�|j|�S|jjrF|s.tj	}|dkr9t
�d||�S|dkrDt
�d||�SdS|�|�S)z�
        Return fileobj with appropriate encryption/compression

        If encryption is specified but no gpg_profile, use
        config.default_profile.
        r\Fr�TN)
rrr*�	encrypted�
compressed�gzip�GzipFiler�r�gpg_profiler
�GPGFiler_)r#r!r1rrr�
filtered_opens�
zDupPath.filtered_open)rN)r\N)rrrrr$r3rrrrr)s
r)c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)r�z+Delete a directory.  Called by Path.deltreecCs
||_dSr�)r��r#rr�rrr�
start_process5�
zPathDeleter.start_processcCs|j��dSr�)r�r�r>rrr�end_process8szPathDeleter.end_processcCs
|��Sr�)rEr4rrr�can_fast_process;r6zPathDeleter.can_fast_processcCs|��dSr�)r�r4rrr�fast_process>r�zPathDeleter.fast_processN)rrrrr5r7r8r9rrrrr�3sr�)&r�
__future__r�futurer�install_aliases�builtinsrrr�r/r7r'rr�rr�r�rrrr	r
rrr
r�duplicity.lazyr�rr�	Exceptionrrr�r)�	ITRBranchr�rrrr�<module>sJ01

https://t.me/RX1948 - 2025