HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/awscli/customizations/s3/syncstrategy/__pycache__/base.cpython-36.pyc
3

�T_�'�@s`ddlZeje�ZdddgZGdd�de�ZGdd�de�ZGd	d
�d
e�ZGdd�de�Z	dS)
�N�file_at_src_and_dest�file_not_at_dest�file_not_at_srcc@s�eZdZdZdZddd�Zdd�Zedd	��Zd
d�Z	dd
�Z
edd��Zedd��Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)�BaseSynczUBase sync strategy

    To create a new sync strategy, subclass from this class.
    NrcCs|j|�||_dS)a+
        :type sync_type: string
        :param sync_type: This determines where the sync strategy will be
            used. There are three strings to choose from:

            'file_at_src_and_dest': apply sync strategy on a file that
            exists both at the source and the destination.

            'file_not_at_dest': apply sync strategy on a file that
            exists at the source but not the destination.

            'file_not_at_src': apply sync strategy on a file that
            exists at the destination but not the source.
        N)�_check_sync_type�
_sync_type)�self�	sync_type�r
�/usr/lib/python3.6/base.py�__init__0s
zBaseSync.__init__cCs|tkrtd|tf��dS)Nz,Unknown sync_type: %s.
Valid options are %s.)�VALID_SYNC_TYPES�
ValueError)rr	r
r
rrBszBaseSync._check_sync_typecCs|jS)N)r)rr
r
rr	HszBaseSync.sync_typecCs |jd|j�|jd|j�dS)z7Registers the sync strategy class to the given session.zbuilding-arg-table.synczchoosing-s3-sync-strategyN)�register�add_sync_argument�use_sync_strategy)rZsessionr
r
r�register_strategyLszBaseSync.register_strategycCstd��dS)aSubclasses should implement this method.

        This function takes two ``FileStat`` objects (one from the source and
        one from the destination).  Then makes a decision on whether a given
        operation (e.g. a upload, copy, download) should be allowed
        to take place.

        The function currently raises a ``NotImplementedError``.  So this
        method must be overwritten when this class is subclassed.  Note
        that this method must return a Boolean as documented below.

        :type src_file: ``FileStat`` object
        :param src_file: A representation of the opertaion that is to be
            performed on a specfic file existing in the source.  Note if
            the file does not exist at the source, ``src_file`` is None.

        :type dest_file: ``FileStat`` object
        :param dest_file: A representation of the operation that is to be
            performed on a specific file existing in the destination. Note if
            the file does not exist at the destination, ``dest_file`` is None.

        :rtype: Boolean
        :return: True if an operation based on the ``FileStat`` should be
            allowed to occur.
            False if if an operation based on the ``FileStat`` should not be
            allowed to occur. Note the operation being referred to depends on
            the ``sync_type`` of the sync strategy:

            'file_at_src_and_dest': refers to ``src_file``

            'file_not_at_dest': refers to ``src_file``

            'file_not_at_src': refers to ``dest_file``
         �determine_should_syncN)�NotImplementedError)r�src_file�	dest_filer
r
rrSs$zBaseSync.determine_should_synccCs d}|jdk	r|jjdd�}|S)N�name)�ARGUMENT�get)rrr
r
r�arg_nameys
zBaseSync.arg_namecCs d}|jdk	r|jjdd�}|S)N�dest)rr)rrr
r
r�arg_dest�s
zBaseSync.arg_destcKs|jdk	r|j|j�dS)N)r�append)rZ	arg_table�kwargsr
r
rr�s
zBaseSync.add_sync_argumentcKsHd}|jdk	r|j}n|jdk	r.|jjdd�}|dk	rD|j|�rD|SdS)N�-�_)rr�replacer)rZparamsrZname_in_paramsr
r
rr�s


zBaseSync.use_sync_strategycCs"|j|j|jddddS)z�
        timedelta's time_seconds() function for python 2.6 users

        :param td: The difference between two datetime objects.
        �i�
�i@Bi@B)ZmicrosecondsZsecondsZdays)rZtdr
r
r�
total_seconds�szBaseSync.total_secondscCs|j|jkS)zX
        :returns: True if the sizes are the same.
            False otherwise.
        )�size)rrrr
r
r�compare_size�szBaseSync.compare_sizecCsd|j}|j}||}|j}|dks*|dkrB|j|�dkr<dSdSn|dkr`|j|�dkr\dSdSdS)a
        :returns: True if the file does not need updating based on time of
            last modification and type of operation.
            False if the file does need updating based on the time of
            last modification and type of operation.
        Zupload�copyrTFZdownloadN)�last_updateZoperation_namer%)rrrZsrc_timeZ	dest_timeZdelta�cmdr
r
r�compare_time�szBaseSync.compare_time)r)�__name__�
__module__�__qualname__�__doc__rrr�propertyr	rrrrrrr%r'r+r
r
r
rrs
&%	rc@seZdZdd�ZdS)�SizeAndLastModifiedSynccCsN|j||�}|j||�}|p"|}|rJtjd|j|j|j|j|j|j�|S)Nz:syncing: %s -> %s, size: %s -> %s, modified time: %s -> %s)r'r+�LOG�debug�srcrr&r))rrrZ	same_sizeZsame_last_modified_timeZshould_syncr
r
rr�sz-SizeAndLastModifiedSync.determine_should_syncN)r,r-r.rr
r
r
rr1�sr1cs&eZdZd�fdd�	Zdd�Z�ZS)�	NeverSyncrcstt|�j|�dS)N)�superr5r)rr	)�	__class__r
rr�szNeverSync.__init__cCsdS)NFr
)rrrr
r
rr�szNeverSync.determine_should_sync)r)r,r-r.rr�
__classcell__r
r
)r7rr5�sr5cs&eZdZd�fdd�	Zdd�Z�ZS)�MissingFileSyncrcstt|�j|�dS)N)r6r9r)rr	)r7r
rr�szMissingFileSync.__init__cCstjd|j|j�dS)Nz5syncing: %s -> %s, file does not exist at destinationT)r2r3r4r)rrrr
r
rr�sz%MissingFileSync.determine_should_sync)r)r,r-r.rrr8r
r
)r7rr9�sr9)
ZloggingZ	getLoggerr,r2r
�objectrr1r5r9r
r
r
r�<module>
s
M