File: //usr/lib/python3/dist-packages/duplicity/backends/__pycache__/s3_boto3_backend.cpython-310.pyc
o
��@a�% � @ s~ d dl Zd dlmZ d dlmZ d dlmZmZ d dlmZ d dlmZ G dd� dej j
�ZG d d
� d
e�Z
ej �de� dS )� N)�config)�log)�FatalBackendException�BackendException)�util)�progressc @ sH e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dd� Z
dS )�S3Boto3Backenda�
Backend for Amazon's Simple Storage System, (aka Amazon S3), though
the use of the boto3 module. (See
https://boto3.amazonaws.com/v1/documentation/api/latest/index.html
for information on boto3.)
Pursuant to Amazon's announced deprecation of path style S3 access,
this backend only supports virtual host style bucket URIs.
See the man page for full details.
To make use of this backend, you must provide AWS credentials.
This may be done in several ways: through the environment variables
AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, by the
~/.aws/credentials file, by the ~/.aws/config file,
or by using the boto2 style ~/.boto or /etc/boto.cfg files.
c C s� t jj�| |� dd� |j�d�D �}|r|�d�| _ntd��|r+dd� |� | _
nd| _
|| _t j�|�| _
d | _d | _t� | _d S )Nc S s g | ]}|d kr|�qS )� � )�.0�xr
r
�E/usr/lib/python3/dist-packages/duplicity/backends/s3_boto3_backend.py�
<listcomp>E s z+S3Boto3Backend.__init__.<locals>.<listcomp>�/r zS3 requires a bucket name.z%s/r )� duplicity�backend�Backend�__init__�path�split�pop�bucket_namer �join�
key_prefix�
parsed_url�strip_auth_from_url�straight_url�s3�bucket�UploadProgressTracker�tracker)�selfr �url_path_partsr
r
r
r ? s zS3Boto3Backend.__init__c
C s� dd l }dd l}ddlm} d | _|jdtjtjd�| _ z| j j
jj| j
d� W n% |jjyM } z|jd d }|dkrHtd | j
tjjd
��� d }~ww | j �| j
�| _d S )Nr )�ClientErrorr )�region_name�endpoint_url)�Bucket�Error�Code�404zS3 bucket "%s" does not exist��code)�boto3�botocore�botocore.exceptionsr# r �resourcer �s3_region_name�s3_endpoint_urlr �meta�client�head_bucketr �
exceptions�responser r � ErrorCode�backend_not_foundr&