HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/awscli/customizations/s3/__pycache__/filegenerator.cpython-310.pyc
o

.&�a�>�@s�ddlZddlZddlZddlmZddlmZddlmZddl	m
Z
mZddl	mZm
Z
mZmZddlmZddlmZeZd	d
�Zdd�ZGd
d�de�ZGdd�de�ZGdd�de�ZdS)�N)�parse)�tzlocal)�ClientError)�find_bucket_key�
get_file_stat)�BucketLister�create_warning�find_dest_path_comp_key�
EPOCH_TIME)�six)�queuecCsHt�|�j}t�|�r
dSt�|�rdSt�|�rdSt�|�r"dSdS)z�
    This function checks to see if a special file.  It checks if the
    file is a character special device, block special device, FIFO, or
    socket.
    TF)�os�stat�st_mode�S_ISCHR�S_ISBLK�S_ISFIFO�S_ISSOCK)�path�mode�r�H/usr/lib/python3/dist-packages/awscli/customizations/s3/filegenerator.py�is_special_files



rc	Cs�tj�|�rzt�|�WdSttfyYdSwzt|d��
}Wd�WdS1s.wYWdSttfyAYdSw)z�
    This function checks to see if a file or a directory can be read.
    This is tested by performing an operation that requires read access
    on the file or the directory.
    F�rNT)r
r�isdir�listdir�OSError�IOError�_open)r�fdrrr�is_readable4s"	������r cs,eZdZdZde��Z�fdd�Z�ZS)�FileDecodingErrorz1Raised when there was an issue decoding the file.z�Please check your locale settings.  The filename was decoded as: %s
On posix platforms, check the LC_CTYPE environment variable.cs<||_||_dt|j�|j|jf|_tt|��|j�dS)NzJThere was an error trying to decode the the file %s in directory "%s". 
%s)�	directory�	file_name�repr�ADVICE�
error_message�superr!�__init__)�selfr"�filename��	__class__rrr(Ss���zFileDecodingError.__init__)	�__name__�
__module__�__qualname__�__doc__�sys�getfilesystemencodingr%r(�
__classcell__rrr+rr!Js��r!c@seZdZ			ddd�ZdS)�FileStatNc

Cs:||_||_||_||_||_||_||_||_|	|_dS�N)	�src�dest�compare_key�size�last_update�src_type�	dest_type�operation_name�
response_data)
r)r6r7r8r9r:r;r<r=r>rrrr(`s
zFileStat.__init__)NNNNNNNN)r-r.r/r(rrrrr4_s
�r4c@sveZdZdZ		ddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�
FileGeneratora}
    This is a class the creates a generator to yield files based on information
    returned from the ``FileFormat`` class.  It is universal in the sense that
    it will handle s3 files, local files, local directories, and s3 objects
    under the same common prefix.  The generator yields corresponding
    ``FileInfo`` objects to send to a ``Comparator`` or ``S3Handler``.
    TNcCsH||_||_||_||_||_|st��|_i|_|dur"||_dSdSr5)�_clientr=�follow_symlinks�	page_size�result_queuer�Queue�request_parameters)r)�clientr=rArBrCrErrrr(vs

�zFileGenerator.__init__ccs��|j|jd�}|dd}|dd}|dd}||||d�}|D]#\}}t||�\}	}
||	|
|||jd�}|�||�td	i|��Vq%dS)
z�
        This is the generalized function to yield the ``FileInfo`` objects.
        ``dir_op`` and ``use_src_name`` flags affect which files are used and
        ensure the proper destination paths and compare keys are formed.
        )�s3�localr6r�typer7�dir_op)r6r7r8r;r<r=Nr)�list_objects�
list_filesr	r=�_inject_extra_informationr4)r)�files�function_table�sourcer;r<�
file_iterator�src_path�extra_information�	dest_pathr8�file_stat_kwargsrrr�call�s���zFileGenerator.callcCs8|d}|d|d<|d|d<|dkr||d<dSdS)Nr;�Sizer9�LastModifiedr:rGr>r)r)rUrSr;rrrrM�s�z'FileGenerator._inject_extra_informationccs�tjjtjjtjj}}}tjtj}}|�|�s}|s+|�|�}|r)|VdSdS||�}	g}
|	D]}|�	||�sO|||�}||�rJ|tjj
}|
�|�q3|�|
tj
d�|
D]$}|||�}||�rr|�
||�D]}
|
VqkqZ|�|�}|r||VqZdSdS)a{
        This function yields the appropriate local file or local files
        under a directory depending on if the operation is on a directory.
        For directories a depth first search is implemented in order to
        follow the same sorted pattern as a s3 list objects operation
        outputs.  It yields the file's source path, size, and last
        update
        �/N)r
r�joinr�isfile�errorr�should_ignore_file�_safely_get_file_stats�)should_ignore_file_with_decoding_warnings�sep�append�normalize_sortrL)r)rrJrZrr[r\r�stats�
listdir_names�names�name�	file_path�xrrrrL�sB�	


��

�
�
��zFileGenerator.list_filesc	CsNzt|�\}}Wnttfy|�|�YdSw|�||�}|||d�fS)N�rWrX)rr�
ValueError�triggers_warning�_validate_update_time)r)rgr9r:rrrr^�s�z$FileGenerator._safely_get_file_statscCs*|durt|ddd�}|j�|�tS|S)Nz?File has an invalid timestamp. Passing epoch time as timestamp.F)rr&�	skip_file)rrC�putr
)r)�update_timer�warningrrrrl�s�z#FileGenerator._validate_update_timecs|j��fdd�d�dS)a
        The purpose of this function is to ensure that the same path seperator
        is used when sorting.  In windows, the path operator is a backslash as
        opposed to a forward slash which can lead to differences in sorting
        between s3 and a windows machine.
        cs|����Sr5)�replace)�item��	character�os_seprr�<lambda>�sz.FileGenerator.normalize_sort.<locals>.<lambda>)�keyN)�sort)r)rerurtrrsrrb�szFileGenerator.normalize_sortcCsNt|tj�st||�}tt|�|j�}|j�|�dSt	j
�||�}|�|�S)a�
        We can get a UnicodeDecodeError if we try to listdir(<unicode>) and
        can't decode the contents with sys.getfilesystemencoding().  In this
        case listdir() returns the bytestring, which means that
        join(<unicode>, <str>) could raise a UnicodeDecodeError.  When this
        happens we warn using a FileDecodingError that provides more
        information into what's going on.
        T)
�
isinstancer�	text_typer!rr$r&rCrnr
rrZr])r)�dirnamer*�decoding_errorrprrrrr_�s	
�
z7FileGenerator.should_ignore_file_with_decoding_warningscCsP|jstj�|�r|�tj�r|dd�}tj�|�rdS|�|�}|r&dSdS)z�
        This function checks whether a file should be ignored in the
        file generation process.  This includes symlinks that are not to be
        followed and files that generate warnings.
        N���TF)rAr
rr�endswithr`�islinkrk)r)r�warning_triggeredrrrr]s
z FileGenerator.should_ignore_filecCsntj�|�st|d�}|j�|�dSt|�r$t|d�}|j�|�dSt|�s5t|d�}|j�|�dSdS)a�
        This function checks the specific types and properties of a file.
        If the file would cause trouble, the function adds a
        warning to the result queue to be printed out and returns a boolean
        value notify whether the file caused a warning to be generated.
        Files that generate warnings are skipped.  Currently, this function
        checks for files that do not exist and files that the user does
        not have read access.
        zFile does not exist.TzHFile is character special device, block special device, FIFO, or socket.zFile/Directory is not readable.F)r
r�existsrrCrnrr )r)rrprrrrks

�
zFileGenerator.triggers_warningc
cs��t|�\}}|s|r|�|�VdSt|j�}|j�di�}|j|||j|d�D](}|\}}	|	ddkrE|�d�rE|j	dkrD||	fVq)|sL||krLq)||	fVq)dS)z�
        This function yields the appropriate object or objects under a
        common prefix depending if the operation is on objects under a
        common prefix.  It yields the file's source path, size, and last
        update.
        �
ListObjectsV2)�bucket�prefixrB�
extra_argsrWrrY�deleteN)
r�_list_single_objectrr@rE�getrKrBr~r=)
r)�s3_pathrJr�r��listerr�rw�source_pathr>rrrrK2s&�


�

��zFileGenerator.list_objectsc
Cs�|jdkr|ddd�fSt|�\}}z||d�}|�|j�di��|jjd
i|��}Wn(tyT}z|jdddks>�|j�	�}d||dd	<t|d��d}~wwt
|�d
��|d<t|d�}|�
t��|d<||fS)Nr�ri)�Bucket�Key�
HeadObject�Error�Code�404zKey "%s" does not exist�Message�
ContentLengthrWrXr)r=r�updaterEr�r@�head_objectr�response�copy�int�popr�
astimezoner)r)r�r�rw�paramsr��er:rrrr�Ts&



��z!FileGenerator._list_single_object)TNNN)r-r.r/r0r(rVrMrLr^rlrbr_r]rkrKr�rrrrr?ns 
�

4		"r?)r
r1r�dateutil.parserr�dateutil.tzr�botocore.exceptionsr�awscli.customizations.s3.utilsrrrrr	r
�
awscli.compatrr�openrrr �	Exceptionr!�objectr4r?rrrr�<module>s