Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/site-packages/ftputil/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/site-packages/ftputil/__pycache__/sync.cpython-38.pyc
U

O��g��@sVdZddlZddlZddlmZddlZdddgZdZGdd�d�ZGd	d�d�Z	dS)
z}
Tools for syncing combinations of local and remote directories.

*** WARNING: This is an unfinished in-development version!
�N)�FTPHostr�	LocalHost�Synceric@s(eZdZdZdd�Zdd�Zdd�ZdS)	rzt
    Provide an API for local directories and files so we can use the same code
    as for `FTPHost` instances.
    cCs
t||�S)zb
        Return a Python file object for file name `path`, opened in mode
        `mode`.
        )�open)�self�path�mode�r	�9/opt/cppython/lib/python3.8/site-packages/ftputil/sync.pyr$szLocalHost.opencCsdS)z�
        Return the time shift value (see methods `set_time_shift` and
        `time_shift` in class `FTPHost` for a definition). By definition, the
        value is zero for local file systems.
        gr	)rr	r	r
�
time_shift,szLocalHost.time_shiftcCs
tt|�S)N)�getattr�os)r�attrr	r	r
�__getattr__4szLocalHost.__getattr__N)�__name__�
__module__�__qualname__�__doc__rrrr	r	r	r
rsc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)rze
    Control synchronization between combinations of local and remote
    directories and files.
    cCs||_||_dS)a�
        Init the `FTPSyncer` instance.

        Each of `source` and `target` is either an `FTPHost` or a `LocalHost`
        object. The source and target directories, resp. have to be set with
        the `chdir` command before passing them in. The semantics is so that
        the items under the source directory will show up under the target
        directory after the synchronization (unless there's an error).
        N)�_source�_target)r�source�targetr	r	r
�__init__>s
zSyncer.__init__cCs>|jj�|�r tj�d�|���|jj�|�s:|j�|�dS)z�
        Try to create the target directory `target_dir`. If it already exists,
        don't do anything. If the directory is present but it's actually a
        file, raise a `SyncError`.
        z"target dir '{}' is actually a fileN)	rr�isfile�ftputil�errorZ	SyncError�format�isdir�mkdir)r�
target_dirr	r	r
�_mkdirKs�z
Syncer._mkdircCsP|j�|d�}z2|j�|d�}ztj||td�W5|��XW5|��XdS)N�rb�wb)�length)rr�closer�shutil�copyfileobj�
CHUNK_SIZE)r�source_file�target_filerrr	r	r
�
_sync_file]szSyncer._sync_filecCs|�|jj|jj�S)zo
        Return the string `path` with appropriate path separators for the
        target file system.
        )�replacer�sepr)rrr	r	r
�_fix_sep_for_targetoszSyncer._fix_sep_for_targetcCs�|�|�|j�|�D]�\}}}|D]6}|jj�||�}|�||d�}|�|�}|�|�q$|D]8}	|jj�||	�}
|
�||d�}|�|�}|�|
|�q`qdS)a�
        Synchronize the source and the target directory tree by updating the
        target to match the source as far as possible.

        Current limitations:
        - _don't_ delete items which are on the target path but not on the
          source path
        - files are always copied, the modification timestamps are not compared
        - all files are copied in binary mode, never in ASCII/text mode
        - incomplete error handling
        �N)r r�walkr�joinr+r-r*)r�
source_dirr�dirpathZ	dir_namesZ
file_names�dir_nameZinner_source_dirZinner_target_dir�	file_namer(r)r	r	r
�
_sync_treevs


zSyncer._sync_treecCsH|jj�|�}|jj�|�}|jj�|�r8|�||�n|�||�dS)a
        Synchronize `source_path` and `target_path` (both are strings, each
        denoting a directory or file path), i. e. update the target path so
        that it's a copy of the source path.

        This method handles both directory trees and single files.
        N)rr�abspathrrr*r5)r�source_path�target_pathr	r	r
�sync�s
	zSyncer.syncN)
rrrrrr r*r-r5r9r	r	r	r
r8s
)
rr
r%rrZ
ftputil.error�__all__r'rrr	r	r	r
�<module>s


F1le Man4ger