File: //lib/python3/dist-packages/awscli/customizations/s3/__pycache__/fileformat.cpython-310.pyc
o
.&�a� � @ s d dl Z G dd� de�ZdS )� Nc @ s, e Zd Zdd� Zdd� Zdd� Zdd� Zd S )
�
FileFormatc C st | � |�\}}| � |�\}}| j| jd�}|d } || || �d }|| || �\}}
||d�||d�| |
d�}|S )a�
This function formats the source and destination
path to the proper form for a file generator.
Note that a file is designated as an s3 file if it begins with s3://
:param src: The path of the source
:type src: string
:param dest: The path of the dest
:type dest: string
:param parameters: A dictionary that will be formed when the arguments
of the command line have been parsed. For this
function the dictionary should have the key 'dir_op'
which is a boolean value that is true when
the operation is being performed on a local directory/
all objects under a common prefix in s3 or false when
it is on a single file/object.
:returns: A dictionary that will be passed to a file generator.
The dictionary contains the keys src, dest, dir_op, and
use_src_name. src is a dictionary containing the source path
and whether its located locally or in s3. dest is a dictionary
containing the destination path and whether its located
locally or in s3.
)�s3�local�dir_opr )�path�type)�src�destr �use_src_name)�
identify_type� s3_format�local_format)�selfr r �
parameters�src_type�src_path� dest_type� dest_path�format_tabler r
�files� r �E/usr/lib/python3/dist-packages/awscli/customizations/s3/fileformat.py�format s �zFileFormat.formatc C s` t j�|�}t j�|�rt j�|�s|r|t j7 }|dfS |�t j�r,|t j7 }|dfS |dfS )a�
This function formats the path of local files and returns whether the
destination will keep its own name or take the source's name along with
the editted path.
Formatting Rules:
1) If a destination file is taking on a source name, it must end
with the appropriate operating system seperator
General Options:
1) If the operation is on a directory, the destination file will
always use the name of the corresponding source file.
2) If the path of the destination exists and is a directory it
will always use the name of the source file.
3) If the destination path ends with the appropriate operating
system seperator but is not an existing directory, the
appropriate directories will be made and the file will use the
source's name.
4) If the destination path does not end with the appropriate
operating system seperator and is not an existing directory, the
appropriate directories will be created and the file name will
be of the one provided.
TF)�osr �abspath�exists�isdir�sep�endswith)r r r � full_pathr r r r
= s
zFileFormat.local_formatc C s8 |r|� d�s|d7 }|dfS |� d�s|dfS |dfS )aj
This function formats the path of source files and returns whether the
destination will keep its own name or take the source's name along
with the edited path.
Formatting Rules:
1) If a destination file is taking on a source name, it must end
with a forward slash.
General Options:
1) If the operation is on objects under a common prefix,
the destination file will always use the name of the
corresponding source file.
2) If the path ends with a forward slash, the appropriate prefixes
will be formed and will use the name of the source.
3) If the path does not end with a forward slash, the appropriate
prefix will be formed but use the the name provided as opposed
to the source name.
�/TF)r )r r r r r r r _ s
zFileFormat.s3_formatc C s"