U
    3dzE                    @   s  d dl Zd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dlm
Z
 d dlZd dlmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZmZ d dlmZ d dlm Z  G dd de!Z"dS )    N)md5)BytesIOsixurllibencodebytesBotoClientError)StorageDataError)PleaseRetryException)Provider)KeyFile)User)	UserAgent)compute_md5compute_hash)find_matching_headers)merge_headers_by_namec                   @   s  e Zd ZdZdZdZejdddZ	e
ddd	d
ddddgZe
 ZeD ]Zeedd qFee
ddddgB ZdddZdd Zdd Zedd Zdd Zd d! ZeeeZd"d# Zd$d% ZeeeZd&d' Zd(d) ZeeeZd*d+ Zd,d- Z eee Z!d.d/ Z"d0d1 Z#d2d3 Z$dd5d6Z%d7d8 Z&d9d: Z'dd<d=Z(dd>d?Z)ddAdBZ*d4Z+ddCdDZ,dEdF Z-e-Z.ddHdIZ/ddKdLZ0ddMdNZ1dOdP Z2dQdR Z3ddSdTZ4ddUdVZ5dWdX Z6dYdZ Z7d[d\ Z8dd]d^Z9dd_d`Z:ddadbZ;ddcddZ<ddedfZ=dgdh Z>ddidjZ?ddkdlZ@ddndoZAddqdrZBddsdtZCddudvZDddwdxZEddydzZFdd{d|ZGdd}d~ZHdddZIdddZJdddZKdddZLdddZMdddZNdddZOdddZPdddZQdd ZRdddZSdddZTdddZUdS )KeyaC  
    Represents a key (object) in an S3 bucket.

    :ivar bucket: The parent :class:`boto.s3.bucket.Bucket`.
    :ivar name: The name of this Key object.
    :ivar metadata: A dictionary containing user metadata that you
        wish to store with the object or that has been retrieved from
        an existing object.
    :ivar cache_control: The value of the `Cache-Control` HTTP header.
    :ivar content_type: The value of the `Content-Type` HTTP header.
    :ivar content_encoding: The value of the `Content-Encoding` HTTP header.
    :ivar content_disposition: The value of the `Content-Disposition` HTTP
        header.
    :ivar content_language: The value of the `Content-Language` HTTP header.
    :ivar etag: The `etag` associated with this object.
    :ivar last_modified: The string timestamp representing the last
        time this object was modified in S3.
    :ivar owner: The ID of the owner of this object.
    :ivar storage_class: The storage class of the object.  Currently, one of:
        STANDARD | REDUCED_REDUNDANCY | GLACIER
    :ivar md5: The MD5 hash of the contents of the object.
    :ivar size: The size, in bytes, of the object.
    :ivar version_id: The version ID of this object, if it is a versioned
        object.
    :ivar encrypted: Whether the object is encrypted while at rest on
        the server.
    zapplication/octet-streamz<?xml version="1.0" encoding="UTF-8"?>
      <RestoreRequest xmlns="http://s3.amazonaws.com/doc/2006-03-01">
        <Days>%s</Days>
      </RestoreRequest>ZBotoZkey_buffer_sizei    zcache-controlzcontent-dispositionzcontent-encodingzcontent-languagecontent-md5content-typezx-robots-tagexpires-_zlast-modifiedcontent-lengthdateetagNc                 C   s   || _ || _i | _d | _| j| _d | _d | _d | _d | _	d | _
d| _d | _d | _d | _d | _d | _d | _d | _d | _d | _d| _d | _d | _d | _i | _d S )NF)bucketnamemetadataZcache_controlDefaultContentTypecontent_typecontent_encodingcontent_dispositioncontent_languagefilenamer   	is_latestlast_modifiedowner_storage_classpathrespmodesize
version_idsource_version_iddelete_marker	encryptedongoing_restoreexpiry_datelocal_hashes)selfr   r    r5   //tmp/pip-unpacked-wheel-d7dsrkjd/boto/s3/key.py__init__i   s2    zKey.__init__c                 C   s<   | j rd| j j| jf }n
d| j }t|ts8|d}|S )Nz<Key: %s,%s>z<Key: None,%s>utf-8)r   r   
isinstancestrencoder4   r   r5   r5   r6   __repr__   s    


zKey.__repr__c                 C   s   | S Nr5   r4   r5   r5   r6   __iter__   s    zKey.__iter__c                 C   s    d }| j r| j jr| j jj}|S r>   )r   
connectionprovider)r4   rB   r5   r5   r6   rB      s    
zKey.providerc                 C   s   | j S r>   r   r?   r5   r5   r6   _get_key   s    zKey._get_keyc                 C   s
   || _ d S r>   rC   r4   valuer5   r5   r6   _set_key   s    zKey._set_keyc                 C   s(   d| j kr$| j d r$t| j d S d S Nr   )r3   binasciib2a_hexr?   r5   r5   r6   _get_md5   s    zKey._get_md5c                 C   s2   |rt || jd< nd| jkr.| jdd  d S rH   )rI   a2b_hexr3   poprE   r5   r5   r6   _set_md5   s    
zKey._set_md5c                 C   sL   d| j krH| j d rH| j d }t|ts2|d}t|ddS d S )Nr   r8   
)r3   r9   bytesr;   rI   
b2a_base64decoderstrip)r4   r   r5   r5   r6   _get_base64md5   s
    


zKey._get_base64md5c                 C   sB   |r,t |tjs|d}t|| jd< nd| jkr>| jd= d S )Nr8   r   )r9   r   string_typesrR   rI   
a2b_base64r3   rE   r5   r5   r6   _set_base64md5   s    

zKey._set_base64md5c                 C   sZ   | j d krT| jrTt| j| jd}t|rNt|d dd rN|d j | _ nd| _ | j S )Nr8   r   r(   STANDARD)r(   r   listr   r;   lengetattr)r4   Z
list_itemsr5   r5   r6   _get_storage_class   s    zKey._get_storage_classc                 C   s
   || _ d S r>   )r(   rE   r5   r5   r6   _set_storage_class   s    zKey._set_storage_classc                 C   s2   t |}t|}|d dkr*|dd }||fS )z
        A utility function to create the 2-tuple (md5hexdigest, base64md5)
        from just having a precalculated md5_hexdigest.
        rO   r   )rI   	unhexlifyr   )r4   Zmd5_hexdigestdigest	base64md5r5   r5   r6   get_md5_from_hexdigest   s
    
zKey.get_md5_from_hexdigestc                 C   s,   | j jj}|jr"||jd | _nd | _d S r>   )r   rA   rB   server_side_encryption_header	getheaderr0   r4   r*   rB   r5   r5   r6   handle_encryption_headers   s    
 zKey.handle_encryption_headersc                 C   s@   | j jj}|jr<||jd | _| jd kr<| dkr<d| _d S )NZawsrX   )r   rA   rB   storage_class_headerrd   r(   get_provider_namere   r5   r5   r6   handle_storage_class_header   s    
 

zKey.handle_storage_class_headerFc                 C   s\   | j jj}| jd ks|r(||jd | _||jd | _||jddkrRd| _nd| _d S )NfalsetrueTF)r   rA   rB   r-   rd   Zcopy_source_version_idr.   r/   )r4   r*   forcerB   r5   r5   r6   handle_version_headers   s    
zKey.handle_version_headersc                 C   s   | j jj}||j}|d kr"d S |dd}|D ]V}dd |dD \}}|dd}|dkrz| d	krrd
nd| _q2|dkr2|| _	q2d S )N,   c                 S   s   g | ]}|  qS r5   )strip).0ir5   r5   r6   
<listcomp>  s     z.Key.handle_restore_headers.<locals>.<listcomp>=" zongoing-requestrk   TFzexpiry-date)
r   rA   rB   rd   Zrestore_headersplitreplacelowerr1   r2   )r4   responserB   headerpartspartkeyvalr5   r5   r6   handle_restore_headers  s    
zKey.handle_restore_headersc                 C   s   dS )z
        Used by Key subclasses to do additional, provider-specific
        processing of response headers. No-op for this base class.
        Nr5   r4   headersr5   r5   r6   handle_addl_headers  s    zKey.handle_addl_headersrv   c           
      C   sB  | j dkr>d| _| jjj}| jjjd| jj| j|||d| _ | j jdk sV| j jdkrv| j  }|	| j j| j j
|| j j}tj||| _| D ]r\}}| dkrd|krt|| _q| d	krtd
d|}	t|	| _q| tjkr|| j| dd< q| | j  | | j  | | j  | | j   dS )a  
        Open this key for reading

        :type headers: dict
        :param headers: Headers to pass in the web request

        :type query_args: string
        :param query_args: Arguments to pass in the query string
            (ie, 'torrent')

        :type override_num_retries: int
        :param override_num_retries: If not None will override configured
            num_retries parameter for underlying GET.

        :type response_headers: dict
        :param response_headers: A dictionary containing HTTP
            headers/values that will override any headers associated
            with the stored object in the response.  See
            http://goo.gl/EWOPb for details.
        NrGET
query_argsoverride_num_retries   +  r   zContent-Rangezcontent-rangez.*/(.*)z\1r   r   )r*   r+   r   rA   rB   make_requestr   statusreadstorage_response_errorreasonmsgbotoutilsZget_aws_metadatar   itemsry   intr,   resubr   base_fields__dict__rx   rm   rf   r   r   
getheaders)
r4   r   r   r   response_headersrB   bodyr   rF   Z	end_ranger5   r5   r6   	open_read  sF    
   

 zKey.open_readc                 C   s   t ddS )aK  
        Open this key for writing.
        Not yet implemented

        :type headers: dict
        :param headers: Headers to pass in the write request

        :type override_num_retries: int
        :param override_num_retries: If not None will override configured
            num_retries parameter for underlying PUT.
        zNot ImplementedNr   )r4   r   r   r5   r5   r6   
open_writeP  s    zKey.open_writer   c                 C   sN   |dkr d| _ | j|||d n*|dkr>d| _ | j||d ntd| d S )Nr   )r   r   r   w)r   r   zInvalid mode: %s)r+   r   r   r   )r4   r+   r   r   r   r5   r5   r6   open^  s    zKey.openc                 C   s*   | j r|s| j   d| _ d| _d| _dS )a  
        Close this key.

        :type fast: bool
        :param fast: True if you want the connection to be closed without first
        reading the content. This should only be used in cases where subsequent
        calls don't need to return the content from the open HTTP connection.
        Note: As explained at
        http://docs.python.org/2/library/httplib.html#httplib.HTTPConnection.getresponse,
        callers must read the whole response before sending a new request to the
        server. Calling Key.close(fast=True) and making a subsequent request to
        the server will work because boto will get an httplib exception and
        close/reopen the connection.

        NT)r*   r   r+   closed)r4   fastr5   r5   r6   closem  s
    

z	Key.closec                 C   s*   |    | j| j}|s&|   t|S )a  
        By providing a next method, the key object supports use as an iterator.
        For example, you can now say:

        for bytes in key:
            write bytes to a file or whatever

        All of the HTTP connection stuff is handled for you.
        )r   r*   r   
BufferSizer   StopIteration)r4   datar5   r5   r6   next  s    
zKey.nextr   c                 C   s8   |    |dkr| j }n| j|}|s4|   |S )Nr   )r   r*   r   r   )r4   r,   r   r5   r5   r6   r     s    zKey.readTc                 C   sX   |p
| j j}|dkr*| j|| jdd|dS |dkrH| j|| jdd|dS td| dS )a  
        Change the storage class of an existing key.
        Depending on whether a different destination bucket is supplied
        or not, this will either move the item within the bucket, preserving
        all metadata and ACL info bucket changing the storage class or it
        will copy the item to the provided destination bucket, also
        preserving metadata and ACL info.

        :type new_storage_class: string
        :param new_storage_class: The new storage class for the Key.
            Possible values are:
            * STANDARD
            * REDUCED_REDUNDANCY

        :type dst_bucket: string
        :param dst_bucket: The name of a destination bucket.  If not
            provided the current bucket of the key will be used.

        :type validate_dst_bucket: bool
        :param validate_dst_bucket: If True, will validate the dst_bucket
            by using an extra list request.
        rX   FT)reduced_redundancypreserve_aclvalidate_dst_bucketREDUCED_REDUNDANCYzInvalid storage class: %sN)r   r   copyr   )r4   Znew_storage_class
dst_bucketr   Zbucket_namer5   r5   r6   change_storage_class  s     
 
 zKey.change_storage_classc           	   
   C   sB   | j j||}|rd}n| j}|j|| j j| j||||| jdS )a  
        Copy this Key to another bucket.

        :type dst_bucket: string
        :param dst_bucket: The name of the destination bucket

        :type dst_key: string
        :param dst_key: The name of the destination key

        :type metadata: dict
        :param metadata: Metadata to be associated with new key.  If
            metadata is supplied, it will replace the metadata of the
            source key being copied.  If no metadata is supplied, the
            source key's metadata will be copied to the new key.

        :type reduced_redundancy: bool
        :param reduced_redundancy: If True, this will force the
            storage class of the new Key to be REDUCED_REDUNDANCY
            regardless of the storage class of the key being copied.
            The Reduced Redundancy Storage (RRS) feature of S3,
            provides lower redundancy at lower storage cost.

        :type preserve_acl: bool
        :param preserve_acl: If True, the ACL from the source key will
            be copied to the destination key.  If False, the
            destination key will have the default ACL.  Note that
            preserving the ACL in the new key object will require two
            additional API calls to S3, one to retrieve the current
            ACL and one to set that ACL on the new object.  If you
            don't care about the ACL, a value of False will be
            significantly more efficient.

        :type encrypt_key: bool
        :param encrypt_key: If True, the new copy of the object will
            be encrypted on the server-side by S3 and will be stored
            in an encrypted form while at rest in S3.

        :type validate_dst_bucket: bool
        :param validate_dst_bucket: If True, will validate the dst_bucket
            by using an extra list request.

        :rtype: :class:`boto.s3.key.Key` or subclass
        :returns: An instance of the newly created key object
        r   )storage_classr   encrypt_keyZsrc_version_id)r   rA   lookupr   copy_keyr   r-   )	r4   r   Zdst_keyr   r   r   r   r   r   r5   r5   r6   r     s    /
 zKey.copyc                 C   s    |dkrt | | _| jS d S d S )NOwner)r   r'   )r4   r   attrsrA   r5   r5   r6   startElement  s    
zKey.startElementc                 C   s   |dkr|| _ n|dkr || _nz|dkr@|dkr8d| _qd| _nZ|dkrP|| _nJ|dkrdt|| _n6|d	krt|| _n&|d
kr~n|dkr|| _nt| || d S )Nr   ETagZIsLatestrk   TFZLastModifiedSizeZStorageClassr   Z	VersionId)	r   r   r%   r&   r   r,   r   r-   setattr)r4   r   rF   rA   r5   r5   r6   
endElement	  s&    zKey.endElementc                 C   s   t | jj| j|dS )zt
        Returns True if the key exists

        :rtype: bool
        :return: Whether the key exists on S3
        r   )boolr   r   r   r   r5   r5   r6   exists   s    z
Key.existsc                 C   s   | j j| j| j|dS )z)
        Delete this key from S3
        )r-   r   )r   Z
delete_keyr   r-   r   r5   r5   r6   delete)  s    z
Key.deletec                 C   s   | j |S r>   )r   getr<   r5   r5   r6   get_metadata0  s    zKey.get_metadatac                 C   sb   |  dkr|| jd< n"|  dkr0|| jd< n
|| j|< |  tjkr^|| j|  dd< d S )Nr   Content-Typer   Content-MD5r   r   )ry   r   r   base_user_settable_fieldsr   rx   )r4   r   rF   r5   r5   r6   set_metadata3  s    
zKey.set_metadatac                 C   s   | j | d S r>   )r   update)r4   dr5   r5   r6   update_metadata?  s    zKey.update_metadatac                 C   s"   | j d k	r| j j|| j|d d S Nr   )r   set_aclr   r4   Zacl_strr   r5   r5   r6   r   C  s    
zKey.set_aclc                 C   s    | j d k	r| j j| j|dS d S r   )r   get_aclr   r   r5   r5   r6   r   G  s    
zKey.get_aclc                 C   s    | j d k	r| j j| j|dS d S r   )r   get_xml_aclr   r   r5   r5   r6   r   K  s    
zKey.get_xml_aclc                 C   s"   | j d k	r| j j|| j|dS d S r   )r   set_xml_aclr   r   r5   r5   r6   r   O  s    
zKey.set_xml_aclc                 C   s   | j || j|S r>   r   set_canned_aclr   r   r5   r5   r6   r   S  s    zKey.set_canned_aclc                 C   sH   | j jd| j j| j}|jdkr,|dS | j|j|j|	 dS )zReturn the redirect location configured for this key.

        If no redirect is configured (via set_redirect), then None
        will be returned.

        HEAD   x-amz-website-redirect-locationN)
r   rA   r   r   r   rd   rB   r   r   r   )r4   rz   r5   r5   r6   get_redirectV  s      

  zKey.get_redirectc                 C   sb   |dkri }n|  }||d< | jjd| jj| j|}|jdkrFdS | j|j|j|	 dS )aO  Configure this key to redirect to another location.

        When the bucket associated with this key is accessed from the website
        endpoint, a 301 redirect will be issued to the specified
        `redirect_location`.

        :type redirect_location: string
        :param redirect_location: The location to redirect.

        Nr   PUTr   T)
r   r   rA   r   r   r   rB   r   r   r   )r4   redirect_locationr   rz   r5   r5   r6   set_redirecte  s     
  zKey.set_redirectc                 C   s   | j d| j|S )Nzpublic-readr   r   r5   r5   r6   make_public~  s    zKey.make_publicr   c                 C   s   | j jj}|p| j}|dkr"i }n| }|	r8|	||j< |
rTd| _|jrT| j||j< |rbd||j< t	j
|| j|}| j j||| j j| j||||||
S )a$  
        Generate a URL to access this key.

        :type expires_in: int
        :param expires_in: How long the url is valid for, in seconds.

        :type method: string
        :param method: The method to use for retrieving the file
            (default is GET).

        :type headers: dict
        :param headers: Any headers to pass along in the request.

        :type query_auth: bool
        :param query_auth: If True, signs the request in the URL.

        :type force_http: bool
        :param force_http: If True, http will be used instead of https.

        :type response_headers: dict
        :param response_headers: A dictionary containing HTTP
            headers/values that will override any headers associated
            with the stored object in the response.  See
            http://goo.gl/EWOPb for details.

        :type expires_in_absolute: bool
        :param expires_in_absolute:

        :type version_id: string
        :param version_id: The version_id of the object to GET. If specified
            this overrides any value in the key.

        :type policy: :class:`boto.s3.acl.CannedACLStrings`
        :param policy: A canned ACL policy that will be applied to the
            new key in S3.

        :type reduced_redundancy: bool
        :param reduced_redundancy: If True, this will set the storage
            class of the new Key to be REDUCED_REDUNDANCY. The Reduced
            Redundancy Storage (RRS) feature of S3, provides lower
            redundancy at lower storage cost.

        :type encrypt_key: bool
        :param encrypt_key: If True, the new copy of the object will
            be encrypted on the server-side by S3 and will be stored
            in an encrypted form while at rest in S3.

        :rtype: string
        :return: The URL to access the key
        Nr   AES256)r   rA   rB   r-   r   
acl_headerr   rg   rc   r   r   
merge_metar   generate_urlr   )r4   Z
expires_inmethodr   Z
query_authZ
force_httpr   Zexpires_in_absoluter-   policyr   r   rB   r5   r5   r6   r     s0    6



  zKey.generate_url
   c              	   C   s   | j |||||||d dS )at  
        Upload a file to a key into a bucket on S3.

        :type fp: file
        :param fp: The file pointer to upload. The file pointer must
            point at the offset from which you wish to upload.
            ie. if uploading the full file, it should point at the
            start of the file. Normally when a file is opened for
            reading, the fp will point at the first byte.  See the
            bytes parameter below for more info.

        :type headers: dict
        :param headers: The headers to pass along with the PUT request

        :type num_cb: int
        :param num_cb: (optional) If a callback is specified with the
            cb parameter this parameter determines the granularity of
            the callback by defining the maximum number of times the
            callback will be called during the file
            transfer. Providing a negative integer will cause your
            callback to be called with each buffer read.

        :type query_args: string
        :param query_args: (optional) Arguments to pass in the query string.

        :type chunked_transfer: boolean
        :param chunked_transfer: (optional) If true, we use chunked
            Transfer-Encoding.

        :type size: int
        :param size: (optional) The Maximum number of bytes to read
            from the file pointer (fp). This is useful when uploading
            a file in multiple parts where you are splitting the file
            up into different ranges to be uploaded. If not specified,
            the default behaviour is to read all bytes from the file
            pointer. Less bytes may be available.
        r   cbnum_cbr   chunked_transferr,   N)_send_file_internal)r4   fpr   r   r   r   r   r,   r5   r5   r6   	send_file  s
    ' zKey.send_filec	              	      sN  j jjz 	W n tk
r4   d 	d_Y nX d krLjsLdtitfddp^i D  	f	dd}	|si }n| }t	d|D ]
}
||
= qt
|d< jdkrȈj|j< t	d	|rtd	|_t	d
|rtd
|_t	d|}|r>t|dkr0||d  d kr0||d = ntd|_nDjrxtjd _jd krlj_j|d< n
j|d< jrj|d< rd|d< ntj|d< dj j krtjd}d k	r|d< tf |d |d< d|d< tj |j!}j jj"dj j#j#||	|d}j$|dd %|&  d S )NFr   c                 3   s   | ]}| |  fV  qd S r>   r5   rq   alg	hash_algsr5   r6   	<genexpr>
  s     z*Key._send_file_internal.<locals>.<genexpr>c                    sP  d k	r   kr  nd kr8jr8di }tjd|rRd|d< tjd|rhd|d< | j||f| |D ]}| |||  q|| 	  j
jj}dj
j_t| ddd	k r| d d} rTr܈}	njrj}	nd}	r
|	dkr
d
j }
n<dkr2tt|	j d  }
ndk rBd}
nd}
d} ||	 }|rv|jk rv|}nj}t|ts|d}d krd_|rt|}||7 }r| d|  | | | d n
| | D ]}| | q|r(||8 }|dkr(q rX|d7 }||
ksJ|
dkrX ||	 d}|rv|jk rv|}nj}t|ts|d}q|_D ]}|  j|< qr| d | d  r|
dks|dkr|dkr ||	 | | |j
j_|  }| }|sL|j |j!||S )Nz9Cannot retry failed request. fp does not support seeking.hostro   	skip_hostzaccept-encodingskip_accept_encodingr   
debuglevel            ?r^   r8   Tz%x;
z
z0
)"tellseekread_from_streamstorage_data_errorr   r   r   
putrequest	putheader
endheadersr   rA   debugr[   set_debuglevelr,   r   r   mathceilr   r9   rP   r;   rZ   sendr   r`   r3   getresponseshould_retryr   r   r   )	http_connr   r)   r   r   skipsr~   
save_debugdata_lencb_sizecb_countrr   Z
bytes_togochunkZ	chunk_lenr   rz   r   )	r   r   	digestersr   r   rB   r4   r,   sposr5   r6   sender  s    













$


  z'Key._send_file_internal.<locals>.senderz
User-Agent)NrX   zContent-EncodingzContent-Languager   ro   r   r   chunkedzTransfer-EncodingzContent-Lengthz
hmac-v4-s3)r   Zhash_algorithmr,   _sha256z100-ContinueZExpectr   )r  r   T)rl   )'r   rA   rB   r   IOErrorr   r   dictr   r   r   r(   r   rg   r   r!   r#   rZ   r    r)   	mimetypes
guess_typer   ra   r:   r,   Z_required_auth_capabilityhashlibsha256r   r   r   r   r   r   r   rm   r   r   )r4   r   r   r   r   r   r   r,   r   r  r{   Zcontent_type_headerskwargsr*   r5   )
r   r   r  r   r   r   rB   r4   r,   r  r6   r     s    
x

 
 
 



zKey._send_file_internalc           	      C   s   | j jj}|s*|jdkrdS |dr*dS d|j  kr@dkrn nv|d| _| j}t|trj|	d}|dd }|d	d }|d kr|d kr| jd
| kr|
d| j| jf dS |jdkr| }||j|j|}|jdkrtd|j |ddS )N)i  i  Tlocationr   r   r   r8   z/x-amz-server-side-encryption-customer-algorithmzx-goog-encryption-kms-key-namez"%s"z2ETag from S3 did not match computed MD5. %s vs. %si  )ZRequestTimeoutzSaw %s, retrying)rz   F)r   rA   rB   r   rd   r   r   r9   rP   rR   r   r   r   r   Z
error_coder
   )	r4   rz   r   rB   r   Z-amz_server_side_encryption_customer_algorithmZ goog_customer_managed_encryptionr   errr5   r5   r6   r     sT    




  


zKey.should_retryc                 C   s    t ||d\}}}|| _||fS )a  
        :type fp: file
        :param fp: File pointer to the file to MD5 hash.  The file
            pointer will be reset to the same position before the
            method returns.

        :type size: int
        :param size: (optional) The Maximum number of bytes to read
            from the file pointer (fp). This is useful when uploading
            a file in multiple parts where the file is being split
            in place into different parts. Less bytes may be available.
        )r,   )r   r,   )r4   r   r,   
hex_digestZ
b64_digest	data_sizer5   r5   r6   r     s    zKey.compute_md5c
              	   C   s   | j jj}
|
 s"td|
  | jr2| jdkr:td|dkrFi }|rT|||
j< |rpd| _|
j	rp| j||
j	< | j dk	r|s| j 
| jrdS | j|||||d|	d dS )a"
  
        Store an object using the name of the Key object as the key in
        cloud and the contents of the data stream pointed to by 'fp' as
        the contents.

        The stream object is not seekable and total size is not known.
        This has the implication that we can't specify the
        Content-Size and Content-MD5 in the header. So for huge
        uploads, the delay in calculating MD5 is avoided but with a
        penalty of inability to verify the integrity of the uploaded
        data.

        :type fp: file
        :param fp: the file whose contents are to be uploaded

        :type headers: dict
        :param headers: additional HTTP headers to be sent with the
            PUT request.

        :type replace: bool
        :param replace: If this parameter is False, the method will first check
            to see if an object exists in the bucket with the same key. If it
            does, it won't overwrite it. The default value is True which will
            overwrite the object.

        :type cb: function
        :param cb: a callback function that will be called to report
            progress on the upload. The callback should accept two integer
            parameters, the first representing the number of bytes that have
            been successfully transmitted to GS and the second representing the
            total number of bytes that need to be transmitted.

        :type num_cb: int
        :param num_cb: (optional) If a callback is specified with the
            cb parameter, this parameter determines the granularity of
            the callback by defining the maximum number of times the
            callback will be called during the file transfer.

        :type policy: :class:`boto.gs.acl.CannedACLStrings`
        :param policy: A canned ACL policy that will be applied to the new key
            in GS.

        :type reduced_redundancy: bool
        :param reduced_redundancy: If True, this will set the storage
            class of the new Key to be REDUCED_REDUNDANCY. The Reduced
            Redundancy Storage (RRS) feature of S3, provides lower
            redundancy at lower storage cost.

        :type size: int
        :param size: (optional) The Maximum number of bytes to read from
            the file pointer (fp). This is useful when uploading a
            file in multiple parts where you are splitting the file up
            into different ranges to be uploaded. If not specified,
            the default behaviour is to read all bytes from the file
            pointer. Less bytes may be available.
        z$%s does not support chunked transferrv   zACannot determine the destination object name for the given streamNr   T)r   r,   )r   rA   rB   supports_chunked_transferr   rh   r   r   r   rg   r   r   )r4   r   r   rx   r   r   r   r   r   r,   rB   r5   r5   r6   set_contents_from_stream  s.    =


 zKey.set_contents_from_streamc              	   C   s  | j jj}|pi }|r |||j< |
r.d||j< |rB|dtj nbt|t	s|
 }|dtj |
 |kr|dtj |
 |kr|| td|| |rd| _|jr| j||j< t|dr|j| _| j dk	r|s| rd}d| _nd}t|t	rR| }|j|
  }|| _td	|jrR|jd
}|tt|f}|sl| ||}| j}nB|rz|| _n4|
 }|dtj |
 | | _|| | j}|d | _|d | _| jdkr| j| _|s| j  | jrdS | j!|||||	||d | jS dS )a  
        Store an object in S3 using the name of the Key object as the
        key in S3 and the contents of the file pointed to by 'fp' as the
        contents. The data is read from 'fp' from its current position until
        'size' bytes have been read or EOF.

        :type fp: file
        :param fp: the file whose contents to upload

        :type headers: dict
        :param headers: Additional HTTP headers that will be sent with
            the PUT request.

        :type replace: bool
        :param replace: If this parameter is False, the method will
            first check to see if an object exists in the bucket with
            the same key.  If it does, it won't overwrite it.  The
            default value is True which will overwrite the object.

        :type cb: function
        :param cb: a callback function that will be called to report
            progress on the upload.  The callback should accept two
            integer parameters, the first representing the number of
            bytes that have been successfully transmitted to S3 and
            the second representing the size of the to be transmitted
            object.

        :type num_cb: int
        :param num_cb: (optional) If a callback is specified with the
            cb parameter this parameter determines the granularity of
            the callback by defining the maximum number of times the
            callback will be called during the file transfer.

        :type policy: :class:`boto.s3.acl.CannedACLStrings`
        :param policy: A canned ACL policy that will be applied to the
            new key in S3.

        :type md5: A tuple containing the hexdigest version of the MD5
            checksum of the file as the first element and the
            Base64-encoded version of the plain checksum as the second
            element.  This is the same format returned by the
            compute_md5 method.
        :param md5: If you need to compute the MD5 for any reason
            prior to upload, it's silly to have to do it twice so this
            param, if present, will be used as the MD5 values of the
            file.  Otherwise, the checksum will be computed.

        :type reduced_redundancy: bool
        :param reduced_redundancy: If True, this will set the storage
            class of the new Key to be REDUCED_REDUNDANCY. The Reduced
            Redundancy Storage (RRS) feature of S3, provides lower
            redundancy at lower storage cost.

        :type encrypt_key: bool
        :param encrypt_key: If True, the new copy of the object will
            be encrypted on the server-side by S3 and will be stored
            in an encrypted form while at rest in S3.

        :type size: int
        :param size: (optional) The Maximum number of bytes to read
            from the file pointer (fp). This is useful when uploading
            a file in multiple parts where you are splitting the file
            up into different ranges to be uploaded. If not specified,
            the default behaviour is to read all bytes from the file
            pointer. Less bytes may be available.

        :type rewind: bool
        :param rewind: (optional) If True, the file pointer (fp) will
            be rewound to the start before any bytes are read from
            it. The default behaviour is False which reads from the
            current position of the file pointer (fp).

        :rtype: int
        :return: The number of bytes written to the key.
        r   r   z8fp is at EOF. Use rewind option or seek() to data start.r   r   NTFz^"[a-fA-F0-9]{32}"$ru   ro   r   )"r   rA   rB   r   rc   r   osSEEK_SETr9   r   r   SEEK_ENDAttributeErrorr   rg   hasattrr   r)   r  r,   Zgetkeyr   matchr   rp   base64	b64encoderI   r_   r   r   ra   r   r   )r4   r   r   rx   r   r   r   r   r   r   r   r,   rewindrB   r  r   r~   r   r5   r5   r6   set_contents_from_fileo  st    O









 zKey.set_contents_from_filec
                 C   s>   t |d*}
| j|
||||||||	d	W  5 Q R  S Q R X dS )a#
  
        Store an object in S3 using the name of the Key object as the
        key in S3 and the contents of the file named by 'filename'.
        See set_contents_from_file method for details about the
        parameters.

        :type filename: string
        :param filename: The name of the file that you want to put onto S3

        :type headers: dict
        :param headers: Additional headers to pass along with the
            request to AWS.

        :type replace: bool
        :param replace: If True, replaces the contents of the file
            if it already exists.

        :type cb: function
        :param cb: a callback function that will be called to report
            progress on the upload.  The callback should accept two
            integer parameters, the first representing the number of
            bytes that have been successfully transmitted to S3 and
            the second representing the size of the to be transmitted
            object.

        :type cb: int
        :param num_cb: (optional) If a callback is specified with the
            cb parameter this parameter determines the granularity of
            the callback by defining the maximum number of times the
            callback will be called during the file transfer.

        :type policy: :class:`boto.s3.acl.CannedACLStrings`
        :param policy: A canned ACL policy that will be applied to the
            new key in S3.

        :type md5: A tuple containing the hexdigest version of the MD5
            checksum of the file as the first element and the
            Base64-encoded version of the plain checksum as the second
            element.  This is the same format returned by the
            compute_md5 method.
        :param md5: If you need to compute the MD5 for any reason
            prior to upload, it's silly to have to do it twice so this
            param, if present, will be used as the MD5 values of the
            file.  Otherwise, the checksum will be computed.

        :type reduced_redundancy: bool
        :param reduced_redundancy: If True, this will set the storage
            class of the new Key to be REDUCED_REDUNDANCY. The Reduced
            Redundancy Storage (RRS) feature of S3, provides lower
            redundancy at lower storage cost.  :type encrypt_key: bool
            :param encrypt_key: If True, the new copy of the object
            will be encrypted on the server-side by S3 and will be
            stored in an encrypted form while at rest in S3.

        :rtype: int
        :return: The number of bytes written to the key.
        rbr   N)r   r   )r4   r$   r   rx   r   r   r   r   r   r   r   r5   r5   r6   set_contents_from_filename!  s    =  zKey.set_contents_from_filenamec
                 C   sD   t |ts|d}t|}
| j|
||||||||	d	}|
  |S )ah	  
        Store an object in S3 using the name of the Key object as the
        key in S3 and the string 's' as the contents.
        See set_contents_from_file method for details about the
        parameters.

        :type headers: dict
        :param headers: Additional headers to pass along with the
            request to AWS.

        :type replace: bool
        :param replace: If True, replaces the contents of the file if
            it already exists.

        :type cb: function
        :param cb: a callback function that will be called to report
            progress on the upload.  The callback should accept two
            integer parameters, the first representing the number of
            bytes that have been successfully transmitted to S3 and
            the second representing the size of the to be transmitted
            object.

        :type num_cb: int
        :param num_cb: (optional) If a callback is specified with the
            num_cb parameter this parameter determines the granularity of
            the callback by defining the maximum number of times the
            callback will be called during the file transfer.

        :type policy: :class:`boto.s3.acl.CannedACLStrings`
        :param policy: A canned ACL policy that will be applied to the
            new key in S3.

        :type md5: A tuple containing the hexdigest version of the MD5
            checksum of the file as the first element and the
            Base64-encoded version of the plain checksum as the second
            element.  This is the same format returned by the
            compute_md5 method.
        :param md5: If you need to compute the MD5 for any reason
            prior to upload, it's silly to have to do it twice so this
            param, if present, will be used as the MD5 values of the
            file.  Otherwise, the checksum will be computed.

        :type reduced_redundancy: bool
        :param reduced_redundancy: If True, this will set the storage
            class of the new Key to be REDUCED_REDUNDANCY. The Reduced
            Redundancy Storage (RRS) feature of S3, provides lower
            redundancy at lower storage cost.

        :type encrypt_key: bool
        :param encrypt_key: If True, the new copy of the object will
            be encrypted on the server-side by S3 and will be stored
            in an encrypted form while at rest in S3.
        r8   r"  )r9   rP   r;   r   r   r   )r4   Zstring_datar   rx   r   r   r   r   r   r   r   r   r5   r5   r6   set_contents_from_stringd  s    9

  zKey.set_contents_from_stringc	           	      C   s"   | j ||||||||ddd
 dS )aN  
        Retrieves a file from an S3 Key

        :type fp: file
        :param fp: File pointer to put the data into

        :type headers: string
        :param: headers to send when retrieving the files

        :type cb: function
        :param cb: a callback function that will be called to report
            progress on the upload.  The callback should accept two
            integer parameters, the first representing the number of
            bytes that have been successfully transmitted to S3 and
            the second representing the size of the to be transmitted
            object.

        :type cb: int
        :param num_cb: (optional) If a callback is specified with the
            cb parameter this parameter determines the granularity of
            the callback by defining the maximum number of times the
            callback will be called during the file transfer.

        :type torrent: bool
        :param torrent: Flag for whether to get a torrent for the file

        :type override_num_retries: int
        :param override_num_retries: If not None will override configured
            num_retries parameter for underlying GET.

        :type response_headers: dict
        :param response_headers: A dictionary containing HTTP
            headers/values that will override any headers associated
            with the stored object in the response.  See
            http://goo.gl/EWOPb for details.

        :type version_id: str
        :param version_id: The ID of a particular version of the object.
            If this parameter is not supplied but the Key object has
            a ``version_id`` attribute, that value will be used when
            retrieving the object.  You can set the Key object's
            ``version_id`` attribute to None to always grab the latest
            version from a version-enabled bucket.
        N)	r   r   r   torrentr-   r   r   r   r   )_get_file_internal)	r4   r   r   r   r   r%  r-   r   r   r5   r5   r6   get_file  s    / zKey.get_filec              
      s  |d kri }| j jj}| j jjdkr.d| j j_|
p4g }
|rD|
d  d krX|sXdti t fdd pji D }|d kr| j}|r|
d|  |r|D ]"}|
d|tj	|| f  qd	
|
}
| jd
||
|d d}|rf| jd krd}n| j}| jd kr|dkrd| j }n<|dkrDtt|| j |d  }n|dk rTd}nd}d}||| z| D ]}|| |t|7 }|D ]}|| | q|rl|dkr||kr q|d7 }||ks|dkrl||| d}qlW nB tk
r2 } z"|jtjkr td|j  W 5 d }~X Y nX |rb|dksN|dkrb|dkrb||| |D ]}||  | j|< qf| jd kr|sd|kr|| _|   || j j_d S )Nro   r   r%  r   c                 3   s   | ]}| |  fV  qd S r>   r5   r   r   r5   r6   r     s     z)Key._get_file_internal.<locals>.<genexpr>zversionId=%sz%s=%s&r   r   r^   r   r   z$Out of space for destination file %sZRange)r   rA   r   appendr   r  r-   r   parsequotejoinr   r,   r   r   r   r   writerZ   r   r
  errnoENOSPCr	   r   r`   r3   r   )r4   r   r   r   r   r%  r-   r   r   r   r   r   r  r~   r  r  r  rr   rP   r   er5   r   r6   r&    s    


 








$
zKey._get_file_internalc                 C   s   | j ||||ddS )a  
        Get a torrent file (see to get_file)

        :type fp: file
        :param fp: The file pointer of where to put the torrent

        :type headers: dict
        :param headers: Headers to be passed

        :type cb: function
        :param cb: a callback function that will be called to report
            progress on the upload.  The callback should accept two
            integer parameters, the first representing the number of
            bytes that have been successfully transmitted to S3 and
            the second representing the size of the to be transmitted
            object.

        :type cb: int
        :param num_cb: (optional) If a callback is specified with the
            cb parameter this parameter determines the granularity of
            the callback by defining the maximum number of times the
            callback will be called during the file transfer.

        T)r%  )r'  )r4   r   r   r   r   r5   r5   r6   get_torrent_file)  s    zKey.get_torrent_filec	           	   	   C   sD   | j dk	r@|r(|j| ||||||d n| j|||||||d dS )a  
        Retrieve an object from S3 using the name of the Key object as the
        key in S3.  Write the contents of the object to the file pointed
        to by 'fp'.

        :type fp: File -like object
        :param fp:

        :type headers: dict
        :param headers: additional HTTP headers that will be sent with
            the GET request.

        :type cb: function
        :param cb: a callback function that will be called to report
            progress on the upload.  The callback should accept two
            integer parameters, the first representing the number of
            bytes that have been successfully transmitted to S3 and
            the second representing the size of the to be transmitted
            object.

        :type cb: int
        :param num_cb: (optional) If a callback is specified with the
            cb parameter this parameter determines the granularity of
            the callback by defining the maximum number of times the
            callback will be called during the file transfer.

        :type torrent: bool
        :param torrent: If True, returns the contents of a torrent
            file as a string.

        :type res_upload_handler: ResumableDownloadHandler
        :param res_download_handler: If provided, this handler will
            perform the download.

        :type response_headers: dict
        :param response_headers: A dictionary containing HTTP
            headers/values that will override any headers associated
            with the stored object in the response.  See
            http://goo.gl/EWOPb for details.

        :type version_id: str
        :param version_id: The ID of a particular version of the object.
            If this parameter is not supplied but the Key object has
            a ``version_id`` attribute, that value will be used when
            retrieving the object.  You can set the Key object's
            ``version_id`` attribute to None to always grab the latest
            version from a version-enabled bucket.
        N)r%  r-   r%  r-   r   )r   r'  )	r4   r   r   r   r   r%  r-   res_download_handlerr   r5   r5   r6   get_contents_to_fileD  s    6
zKey.get_contents_to_filec	                 C   s   z4t |d }	| j|	|||||||d W 5 Q R X W n  tk
rT   t|  Y nX | jdk	rz4tj| j}
t	tj
|
}t|	j||f W n tk
r   Y nX dS )aO  
        Retrieve an object from S3 using the name of the Key object as the
        key in S3.  Store contents of the object to a file named by 'filename'.
        See get_contents_to_file method for details about the
        parameters.

        :type filename: string
        :param filename: The filename of where to put the file contents

        :type headers: dict
        :param headers: Any additional headers to send in the request

        :type cb: function
        :param cb: a callback function that will be called to report
            progress on the upload.  The callback should accept two
            integer parameters, the first representing the number of
            bytes that have been successfully transmitted to S3 and
            the second representing the size of the to be transmitted
            object.

        :type num_cb: int
        :param num_cb: (optional) If a callback is specified with the
            cb parameter this parameter determines the granularity of
            the callback by defining the maximum number of times the
            callback will be called during the file transfer.

        :type torrent: bool
        :param torrent: If True, returns the contents of a torrent file
            as a string.

        :type res_upload_handler: ResumableDownloadHandler
        :param res_download_handler: If provided, this handler will
            perform the download.

        :type response_headers: dict
        :param response_headers: A dictionary containing HTTP
            headers/values that will override any headers associated
            with the stored object in the response.  See
            http://goo.gl/EWOPb for details.

        :type version_id: str
        :param version_id: The ID of a particular version of the object.
            If this parameter is not supplied but the Key object has
            a ``version_id`` attribute, that value will be used when
            retrieving the object.  You can set the Key object's
            ``version_id`` attribute to None to always grab the latest
            version from a version-enabled bucket.
        wb)r%  r-   r3  r   N)r   r4  	Exceptionr  remover&   emailr   parsedate_tzr   	mktime_tzutimer   )r4   r$   r   r   r   r%  r-   r3  r   r   Zmodified_tupleZmodified_stampr5   r5   r6   get_contents_to_filename  s$    6

zKey.get_contents_to_filenamec           
   	   C   s<   t  }| j|||||||d | }	|dk	r8|	|}	|	S )ao  
        Retrieve an object from S3 using the name of the Key object as the
        key in S3.  Return the contents of the object as a string.
        See get_contents_to_file method for details about the
        parameters.

        :type headers: dict
        :param headers: Any additional headers to send in the request

        :type cb: function
        :param cb: a callback function that will be called to report
            progress on the upload.  The callback should accept two
            integer parameters, the first representing the number of
            bytes that have been successfully transmitted to S3 and
            the second representing the size of the to be transmitted
            object.

        :type cb: int
        :param num_cb: (optional) If a callback is specified with the
            cb parameter this parameter determines the granularity of
            the callback by defining the maximum number of times the
            callback will be called during the file transfer.

        :type torrent: bool
        :param torrent: If True, returns the contents of a torrent file
            as a string.

        :type response_headers: dict
        :param response_headers: A dictionary containing HTTP
            headers/values that will override any headers associated
            with the stored object in the response.  See
            http://goo.gl/EWOPb for details.

        :type version_id: str
        :param version_id: The ID of a particular version of the object.
            If this parameter is not supplied but the Key object has
            a ``version_id`` attribute, that value will be used when
            retrieving the object.  You can set the Key object's
            ``version_id`` attribute to None to always grab the latest
            version from a version-enabled bucket.

        :type encoding: str
        :param encoding: The text encoding to use, such as ``utf-8``
            or ``iso-8859-1``. If set, then a string will be returned.
            Defaults to ``None`` and returns bytes.

        :rtype: bytes or str
        :returns: The contents of the file as bytes or a string
        r2  N)r   r4  getvaluerR   )
r4   r   r   r   r%  r-   r   encodingr   rF   r5   r5   r6   get_contents_as_string  s    6
zKey.get_contents_as_stringc                 C   s,   | j |d}|j|| | j||d dS )a  
        Convenience method that provides a quick way to add an email grant
        to a key. This method retrieves the current ACL, creates a new
        grant based on the parameters passed in, adds that grant to the ACL
        and then PUT's the new ACL back to S3.

        :type permission: string
        :param permission: The permission being granted. Should be one of:
            (READ, WRITE, READ_ACP, WRITE_ACP, FULL_CONTROL).

        :type email_address: string
        :param email_address: The email address associated with the AWS
            account your are granting the permission to.

        :type recursive: boolean
        :param recursive: A boolean value to controls whether the
            command will apply the grant to all keys within the bucket
            or not.  The default value is False.  By passing a True
            value, the call will iterate through all keys in the
            bucket and apply the same grant to each key.  CAUTION: If
            you have a lot of keys, this could take a long time!
        r   N)r   acladd_email_grantr   )r4   
permissionZemail_addressr   r   r5   r5   r6   rA    s    zKey.add_email_grantc                 C   s0   | j |d}|jj|||d | j||d dS )a  
        Convenience method that provides a quick way to add a canonical
        user grant to a key.  This method retrieves the current ACL,
        creates a new grant based on the parameters passed in, adds that
        grant to the ACL and then PUT's the new ACL back to S3.

        :type permission: string
        :param permission: The permission being granted. Should be one of:
            (READ, WRITE, READ_ACP, WRITE_ACP, FULL_CONTROL).

        :type user_id: string
        :param user_id: The canonical user id associated with the AWS
            account your are granting the permission to.

        :type display_name: string
        :param display_name: An option string containing the user's
            Display Name.  Only required on Walrus.
        r   )display_nameN)r   r@  add_user_grantr   )r4   rB  Zuser_idr   rC  r   r5   r5   r6   rD  )  s
    
zKey.add_user_grantc                 C   sN   t |tkr,t }|D ]}||  qni }|D ]}|| || < q4|S r>   )typesetaddry   )r4   r   Znorm_metadatakr5   r5   r6   _normalize_metadataB  s    zKey._normalize_metadatac                 C   s~   i }| j D ]4}t| |r
t| |}|r
|dd}||| < q
| jj}| jD ]*}|dd}| j| |d|| f < qN|S )z
        Extracts metadata from existing URI into a dict, so we can
        overwrite/delete from it to form the new set of metadata to apply to a
        key.
        r   r   z%s%s)%_underscore_base_user_settable_fieldsr  r[   rx   ry   rB   Zmetadata_prefixr   )r4   r   r   Zunderscore_namerF   
field_nameprefixr5   r5   r6   _get_remote_metadataM  s    



zKey._get_remote_metadatac           
      C   s   |  |}|  |}|  }|| |D ]}||kr*||= q*| j}i }|D ]>}|dsd|drz|dddd}	n|}	|| ||	< qL|}|j| j| jj| j|||d d S )Nzx-goog-meta-zx-amz-meta-rv   )r   r   r   )rI  rM  r   r   
startswithrx   r   r   )
r4   Zmetadata_plusZmetadata_minusr   r   r   hZ
src_bucketZrewritten_metadataZrewritten_hr5   r5   r6   set_remote_metadatac  s.    


  zKey.set_remote_metadatac                 C   sT   | j jjd| j j| j| j| |dd}|jdkrP| j jj}||j|j|	 dS )a  Restore an object from an archive.

        :type days: int
        :param days: The lifetime of the restored object (must
            be at least 1 day).  If the object is already restored
            then this parameter can be used to readjust the lifetime
            of the restored object.  In this case, the days
            param is with respect to the initial time of the request.
            If the object has not been restored, this param is with
            respect to the completion time of the request.

        POSTrestore)r   r   r   )r      N)
r   rA   r   r   RestoreBodyr   rB   r   r   r   )r4   daysr   rz   rB   r5   r5   r6   rR  |  s       

zKey.restore)NN)F)Nrv   NN)NN)r   NNN)F)r   )NT)NFFFT)N)N)N)N)N)N)N)N)N)
r   NTFNFNNFF)NNr   NFN)NNr   NFNN)F)N)NTNr   NFNN)NTNr   NNFNFNF)NTNr   NNFF)NTNr   NNFF)NNr   FNNN)	NNr   FNNNNN)NNr   )NNr   FNNN)NNr   FNNN)NNr   FNNN)N)NN)N)N)N)V__name__
__module____qualname____doc__r   rT  r   configgetintr   rF  r   rJ  frG  rx   r   r7   r=   r@   propertyrB   rD   rG   r~   rK   rN   r   rT   rW   ra   r\   r]   r   rb   rf   ri   rm   r   r   r   r   r   r   r   r   __next__r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r#  r$  r'  r&  r1  r4  r<  r?  rA  rD  rI  rM  rP  rR  r5   r5   r5   r6   r   0   st     
 





    
6
  



  
%       
<
	







              
P      
+       
 M
7
          
X                
 3          
C          
B       
6           
M
        
@        
I         
A
  

 
r   )#email.utilsr8  r.  r  r  r  r   r  rI   r   r   Z
boto.utilsr   Zboto.compatr   r   r   r   Zboto.exceptionr   r	   r
   Zboto.providerr   Zboto.s3.keyfiler   Zboto.s3.userr   r   r   r   r   r   objectr   r5   r5   r5   r6   <module>   s,   