ó
zkF[c           @   s¦   d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l m Z d  d l m Z d  d l m Z d e	 f d „  ƒ  YZ
 d e
 f d „  ƒ  YZ d	 e
 f d
 „  ƒ  YZ d S(   iÿÿÿÿN(   t   DeleteMarker(   t   BotoClientError(   t   InvalidUriErrort
   StorageUric        	   B   s@  e  Z d  Z d Z d Z i  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d d d „ Z d	 „  Z e d d d d
 „ Z d d d e d „ Z e d d d „ Z e d d „ Z e d d d „ Z e d d „ Z d d d „ Z d d d e d d d d d „ Z e d d d e d d „ Z d „  Z d „  Z RS(   sæ   
    Base class for representing storage provider-independent bucket and
    object name with a shorthand URI-like syntax.

    This is an abstract class: the constructor cannot be called (throws an
    exception if you try).
    c         C   s   t  d ƒ ‚ d S(   sB   Uncallable constructor on abstract base StorageUri class.
        s0   Attempt to instantiate abstract StorageUri classN(   R   (   t   self(    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   __init__6   s    c         C   s   |  j  S(   s%   Returns string representation of URI.(   t   uri(   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   __repr__<   s    c         C   s   |  j  | j  k S(   s#   Returns true if two URIs are equal.(   R   (   R   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   equals@   s    c         C   s>   | d  k r: t d j t j d | | f d ƒ ƒ ƒ ‚ n  d  S(   Ns   
sÉ   Attempt to get %s for "%s" failed. This can happen if the URI refers to a non-existent object or if you meant to operate on a directory (e.g., leaving off -R option on gsutil cp, mv, or ls of a bucket)iP   (   t   NoneR   t   joint   textwrapt   wrap(   R   t   respt   levelR   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   check_responseD   s    c         C   s?   t  t |  ƒ t ƒ r; |  j r; t d | |  j f ƒ ‚ n  d  S(   Ns   %s on bucket-less URI (%s)(   t
   issubclasst   typet   BucketStorageUrit   bucket_nameR   R   (   R   t   function_name(    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   _check_bucket_uriL   s    c         C   s?   t  t |  ƒ t ƒ r; |  j r; t d | |  j f ƒ ‚ n  d  S(   Ns   %s on object-less URI (%s)(   R   R   R   t   object_nameR   R   (   R   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   _check_object_uriQ   s    c         K   sI   xB | D]: } | | r t  j j d | | t | | ƒ f ƒ q q Wd  S(   Ns$   Warning: %s ignores argument: %s=%s
(   t   syst   stderrt   writet   str(   R   R   t   argst   arg(    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   _warn_about_argsV   s
    
	c   	      K   sŒ  t  |  j p d ƒ } t |  d ƒ r@ d | k r@ |  j | d <n  | j | ƒ |  j sv|  j |  j k r~ |  j |  j |  _ qv|  j d k rÈ d d l m	 } | | | |  |  _ |  j |  j |  j <qv|  j d k r/d d l
 m } d d l m } | ƒ  | d <| | | |  |  _ |  j |  j |  j <qv|  j d	 k r`d d
 l m } | |  ƒ |  _ qvt d |  j ƒ ‚ n  |  j |  j _ |  j S(   sË  
        Opens a connection to appropriate provider, depending on provider
        portion of URI. Requires Credentials defined in boto config file (see
        boto/pyami/config.py).
        @type storage_uri: StorageUri
        @param storage_uri: StorageUri specifying a bucket or a bucket+object
        @rtype: L{AWSAuthConnection<boto.gs.connection.AWSAuthConnection>}
        @return: A connection to storage service provider of the given URI.
        t   suppress_consec_slashest   s3iÿÿÿÿ(   t   S3Connectiont   gs(   t   GSConnection(   t   OrdinaryCallingFormatt   calling_formatt   file(   t   FileConnections   Unrecognized scheme "%s"(    (   t   dictt   connection_argst   hasattrR   t   updatet
   connectiont   schemet   provider_poolt   boto.s3.connectionR!   t   boto.gs.connectionR#   R$   t   boto.file.connectionR'   R   t   debug(	   R   t   access_key_idt   secret_access_keyt   kwargsR)   R!   R#   R$   R'   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   connect]   s:    
	c         C   s1   t  t |  ƒ t ƒ o0 |  j d  k	 p0 |  j d  k	 S(   N(   R   R   R   t
   version_idR	   t
   generation(   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   has_version—   s    c         C   s8   |  j  d ƒ |  j | | ƒ } | j |  j | | | ƒ S(   Nt
   delete_key(   R   t
   get_bucketR:   R   (   R   t   validatet   headersR7   t	   mfa_tokent   bucket(    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR:   œ   s    t    c         C   sk   |  j  d ƒ |  j d | ƒ } | rK d „  | j d | d | d | ƒ Dƒ S| j d | d | d | ƒ Sd  S(   Nt   list_bucketR=   c         s   s$   |  ] } t  | t ƒ s | Vq d  S(   N(   t
   isinstanceR    (   t   .0t   v(    (    s/   lib/python2.7/site-packages/boto/storage_uri.pys	   <genexpr>¨   s    t   prefixt	   delimiter(   R   R;   t   list_versionst   list(   R   RE   RF   R=   t   all_versionsR?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRA   £   s    c         C   s   |  j  | | ƒ } | j | ƒ S(   N(   R;   t   get_all_keys(   R   R<   R=   RE   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRJ   ¯   s    c         C   sK   |  j  d ƒ |  j ƒ  } | j |  j | | ƒ } |  j | d |  j ƒ | S(   NR;   R?   (   R   R6   R;   R   R   R   (   R   R<   R=   t   connR?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR;   ³   s
    c         C   sQ   |  j  d ƒ |  j | | ƒ } | j |  j | | ƒ } |  j | d |  j ƒ | S(   Nt   get_keyt   key(   R   R;   RL   R   R   R   (   R   R<   R=   R7   R?   RM   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRL   º   s
    c         C   s/   |  j  d ƒ |  j | | ƒ } | j |  j ƒ S(   Nt   new_key(   R   R;   RN   R   (   R   R<   R=   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRN   Á   s    c         C   s^   |  j  d ƒ |  j d d t ƒ|  j d  | ƒ } |  j | d |  j ƒ | j | | d | ƒS(   NRL   R<   RM   R7   (   R   R   t   FalseRL   R	   R   R   t   get_contents_to_file(   R   t   fpR=   R7   RM   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   get_contents_to_streamÆ   s
    i
   c
         C   sŒ   |  j  d ƒ |  j d  | ƒ }
 |  j |
 d |  j ƒ |	 rf |
 j | | | | | | | | d |	 ƒn" |
 j | | | | | | | | ƒ d  S(   NRP   RM   t	   hash_algs(   R   RL   R	   R   R   RP   (   R   RQ   R=   t   cbt   num_cbt   torrentR7   t   res_download_handlert   response_headersRS   RM   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRP   Í   s    
c         C   sN   |  j  d ƒ |  j | | ƒ } |  j | d |  j ƒ | j | | | | | ƒ S(   Nt   get_contents_as_stringRM   (   R   RL   R   R   RY   (   R   R<   R=   RT   RU   RV   R7   RM   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRY   Þ   s
    c         C   s2   |  j  ƒ  } | j j } |  j | d |  j ƒ | S(   Nt	   acl_class(   R6   t   providerRZ   R   R   (   R   RK   RZ   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRZ   æ   s    c         C   s2   |  j  ƒ  } | j j } |  j | d |  j ƒ | S(   Nt   canned_acls(   R6   R[   R\   R   R   (   R   RK   R\   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR\   ì   s    N(   t   __name__t
   __module__t   __doc__R	   R,   R)   R.   R   R   R   R   R   R   R   R6   R9   RO   R:   RA   RJ   R;   RL   RN   RR   RP   RY   RZ   R\   (    (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR       s<   							:						R   c        
   B   sæ  e  Z d  Z d Z e g  ƒ Z dC dC d dC e dC dC e d „ Z	 d „  Z
 d „  Z d „  Z e dC dC d „ Z e dC dC dC d „ Z d	 „  Z d
 „  Z e dC dC d „ Z e dC d „ Z e dC d „ Z e dC d „ Z e dC d „ Z e dC d „ Z e dC d „ Z e dC dC d „ Z e e dC d „ Z e e dC d „ Z e e dC d „ Z dC d „ Z d „  Z d „  Z d „  Z d „  Z  d „  Z! d „  Z" d „  Z# d „  Z$ d „  Z% d  „  Z& dC d! dC dC d" „ Z' dC d# „ Z( dC d$ „ Z) d% „  Z* d! e dC dC dC dC d& „ Z+ d! e dC dC dC dC d' „ Z, e dC d( „ Z- e dC dC d) „ Z. e dC dC d* „ Z/ e dC dC d+ „ Z0 e dC dC d, „ Z1 dC e dC d- dC dC e d. „ Z2 dC e dC d- dC dC dC e dC d/ „	 Z3 dC e dC dC e d0 „ Z4 dC dC d1 e e dC dC dC d2 „ Z5 dC e dC dC d3 „ Z6 e dC dC d4 „ Z7 e dC dC d5 „ Z8 dC dC e dC d6 „ Z9 e dC d7 „ Z: dC d8 „ Z; dC d9 „ Z< dC d: „ Z= dC dC d; „ Z> e dC d< „ Z? e dC d= „ Z@ dC d> „ ZA e e dC d? „ ZB e dC d@ „ ZC dC e dC dA „ ZD dC dB „ ZE RS(D   s   
    StorageUri subclass that handles bucket storage providers.
    Callers should instantiate this class by calling boto.storage_uri().
    t   /i    c
   
      C   s’   | |  _  | |  _ | |  _ | |  _ | r6 | |  _ n  | |  _ | |  _ | oW t | ƒ |  _ |	 |  _	 t
 |  j ƒ p~ t
 | ƒ |  _ |  j ƒ  d S(   sÐ  Instantiate a BucketStorageUri from scheme,bucket,object tuple.

        @type scheme: string
        @param scheme: URI scheme naming the storage provider (gs, s3, etc.)
        @type bucket_name: string
        @param bucket_name: bucket name
        @type object_name: string
        @param object_name: object name, excluding generation/version.
        @type debug: int
        @param debug: debug level to pass in to connection (range 0..2)
        @type connection_args: map
        @param connection_args: optional map containing args to be
            passed to {S3,GS}Connection constructor (e.g., to override
            https_connection_factory).
        @param suppress_consec_slashes: If provided, controls whether
            consecutive slashes will be suppressed in key paths.
        @param version_id: Object version id (S3-specific).
        @param generation: Object generation number (GCS-specific).
        @param is_latest: boolean indicating that a versioned object is the
            current version

        After instantiation the components are available in the following
        fields: scheme, bucket_name, object_name, version_id, generation,
        is_latest, versionless_uri, version_specific_uri, uri.
        Note: If instantiated without version info, the string representation
        for a URI stays versionless; similarly, if instantiated with version
        info, the string representation for a URI stays version-specific. If you
        call one of the uri.set_contents_from_xyz() methods, a specific object
        version will be created, and its version-specific URI string can be
        retrieved from version_specific_uri even if the URI was instantiated
        without version info.
        N(   R-   R   R   R2   R)   R   R7   t   intR8   t	   is_latestt   boolt   is_version_specifict   _build_uri_strings(
   R   R-   R   R   R2   R)   R   R7   R8   Rb   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR   ü   s    $							c         C   sÛ   |  j  r¢ |  j r¢ d |  j |  j  |  j f |  _ |  j rV d |  j |  j f |  _ n% |  j r{ d |  j |  j f |  _ n  |  j r“ |  j |  _ q× |  j |  _ n5 |  j  rÇ d |  j |  j  f |  _ n d |  j |  _ d  S(   Ns
   %s://%s/%ss   %s#%ss   %s://%s/s   %s://(	   R   R   R-   t   versionless_uriR8   t   version_specific_uriR7   Rd   R   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRe   -  s    					c         C   sJ   |  j  t | d d  ƒ t | d d  ƒ t | d d  ƒ t | d d  ƒ ƒ d  S(   NR7   R8   Rb   t   md5(   t   _update_from_valuest   getattrR	   (   R   RM   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   _update_from_key@  s
    c         C   s2   | |  _  | |  _ | |  _ |  j ƒ  | |  _ d  S(   N(   R7   R8   Rb   Re   Rh   (   R   R7   R8   Rb   Rh   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRi   G  s
    			
c         C   s«   |  j  d ƒ |  j | | ƒ } |  j ƒ  j d k r[ | j |  j | d | pR |  j ƒ} n6 |  j ƒ  j d k r‘ | j |  j | d |  j ƒ} n  |  j | d |  j	 ƒ | S(   NRL   t   awsR7   t   googleR8   RM   (
   R   R;   t   get_providert   nameRL   R   R7   R8   R   R   (   R   R<   R=   R7   R?   RM   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRL   N  s    c         C   s‘   |  j  d ƒ |  j | | ƒ } |  j ƒ  j d k r\ | p@ |  j } | j |  j | | | ƒ S|  j ƒ  j d k r | j |  j | d |  j ƒSd  S(   NR:   Rl   Rm   R8   (   R   R;   Rn   Ro   R7   R:   R   R8   (   R   R<   R=   R7   R>   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR:   Z  s    c      
   C   s;   |  j  d ƒ t |  j d |  j d | d |  j d |  j ƒS(   sº   Instantiate a BucketStorageUri from the current BucketStorageUri,
        but replacing the object_name.

        @type new_name: string
        @param new_name: new object name
        t   clone_replace_nameR   R   R2   R   (   R   R   R-   R   R2   R   (   R   t   new_name(    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRp   f  s
    	c         C   s¼   |  j  d ƒ d	 } d	 } t } t | d ƒ r: | j } n  t | d ƒ rU | j } n  t | d ƒ rp | j } n  t | j j	 ƒ  d | j
 j d | j d |  j d |  j d | d | d | ƒS(
   s)  Instantiate a BucketStorageUri from the current BucketStorageUri, by
        replacing the object name with the object name and other metadata found
        in the given Key object (including generation).

        @type key: Key
        @param key: key for the new StorageUri to represent
        t   clone_replace_keyR7   R8   Rb   R   R   R2   R   N(   R   R	   RO   R*   R7   R8   Rb   R   R[   t   get_provider_nameR?   Ro   R2   R   (   R   RM   R7   R8   Rb   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRr   s  s&    			c         C   sŸ   |  j  d ƒ |  j | | ƒ } |  j p+ d } |  j ƒ  j d k rj | pO |  j } | j | | | ƒ } n | j | | d |  j ƒ} |  j | d |  j	 ƒ | S(   s   returns a bucket's aclt   get_aclR@   Rl   R8   t   acl(
   R   R;   R   Rn   Ro   R7   Rt   R8   R   R   (   R   R<   R=   R7   R?   t   key_nameRu   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRt     s    c         C   sH   |  j  d ƒ |  j | | ƒ } | j | ƒ } |  j | d |  j ƒ | S(   s%   returns a bucket's default object aclt   get_def_aclRu   (   R   R;   Rw   R   R   (   R   R<   R=   R?   Ru   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRw   Ÿ  s
    c         C   sH   |  j  d ƒ |  j | | ƒ } | j | ƒ } |  j | d |  j ƒ | S(   s   returns a bucket's CORS XMLt   get_corst   cors(   R   R;   Rx   R   R   (   R   R<   R=   R?   Ry   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRx   §  s
    c         C   s[   |  j  d ƒ |  j | | ƒ } |  j d k rA | j | | ƒ n | j | j ƒ  | ƒ d S(   s#   sets or updates a bucket's CORS XMLs	   set_cors R    N(   R   R;   R-   t   set_corst   to_xml(   R   Ry   R<   R=   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRz   ¯  s
    c         C   s,   |  j  d ƒ |  j | | ƒ } | j | ƒ S(   Nt   get_location(   R   R;   R|   (   R   R<   R=   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR|   ¸  s    c         C   sQ   |  j  d ƒ |  j d k r2 t d |  j ƒ ‚ n  |  j | | ƒ } | j | ƒ S(   Nt   get_storage_classR"   s.   get_storage_class() not supported for %s URIs.(   R   R-   t
   ValueErrorR;   R}   (   R   R<   R=   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR}   ½  s    c         C   sX   |  j  d ƒ |  j d k r2 t d |  j ƒ ‚ n  |  j | | ƒ } | j | | ƒ d S(   s!   Updates a bucket's storage class.t   set_storage_classR"   s.   set_storage_class() not supported for %s URIs.N(   R   R-   R~   R;   R   (   R   t   storage_classR<   R=   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR   Ç  s    c         C   s8   |  j  d ƒ |  j | | ƒ } | j | |  j | | ƒ S(   Nt   get_subresource(   R   R;   R   R   (   R   t   subresourceR<   R=   R7   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR   Ò  s    c         C   sÙ   |  j  d ƒ |  j d k r2 t d |  j ƒ ‚ n  |  j rŽ | rP t d ƒ ‚ n  |  j | | ƒ } |  j | d |  j ƒ | j | | | ƒ nG |  j rÂ |  j	 | | ƒ } | j | | | | ƒ n t
 d |  j ƒ ‚ d  S(   Nt   add_group_email_grantR"   s2   add_group_email_grant() not supported for %s URIs.sD   add_group_email_grant() on key-ful URI cannot specify recursive=TrueRM   s-   add_group_email_grant() on bucket-less URI %s(   R   R-   R~   R   RL   R   R   Rƒ   R   R;   R   (   R   t
   permissiont   email_addresst	   recursiveR<   R=   RM   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRƒ   Ù  s     		
c         C   s}   |  j  d ƒ |  j sA |  j | | ƒ } | j | | | | ƒ n8 |  j | | ƒ } |  j | d |  j ƒ | j | | ƒ d  S(   Nt   add_email_grantRM   (   R   R   R;   R‡   RL   R   R   (   R   R„   R…   R†   R<   R=   R?   RM   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR‡   î  s    	
c         C   s}   |  j  d ƒ |  j sA |  j | | ƒ } | j | | | | ƒ n8 |  j | | ƒ } |  j | d |  j ƒ | j | | ƒ d  S(   Nt   add_user_grantRM   (   R   R   R;   Rˆ   RL   R   R   (   R   R„   t   user_idR†   R<   R=   R?   RM   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRˆ   ú  s    	c         C   s)   |  j  d ƒ |  j | ƒ } | j | ƒ S(   Ns   list_grants (   R   R;   t   list_grants(   R   R=   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRŠ     s    c         C   s   t  S(   s3   Returns True if this URI names a file or directory.(   RO   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   is_file_uri
  s    c         C   s   t  S(   s2   Returns True if this URI names a bucket or object.(   t   True(   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   is_cloud_uri  s    c         C   s   t  |  j ƒ S(   sÒ   
        Returns True if this URI names a directory or bucket. Will return
        False for bucket subdirs; providing bucket subdir semantics needs to
        be done by the caller (like gsutil does).
        (   Rc   R   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   names_container  s    c         C   s   t  |  j ƒ S(   s0   Returns True if this URI names a file or object.(   Rc   R   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   names_singleton  s    c         C   s   t  S(   s+   Returns True if this URI names a directory.(   RO   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   names_directory  s    c         C   s   t  |  j ƒ S(   s*   Returns True if this URI names a provider.(   Rc   R   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   names_provider"  s    c         C   s   t  |  j ƒ o t  |  j ƒ S(   s(   Returns True if this URI names a bucket.(   Rc   R   R   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   names_bucket&  s    c         C   s   t  S(   s&   Returns True if this URI names a file.(   RO   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt
   names_file*  s    c         C   s
   |  j  ƒ  S(   s)   Returns True if this URI names an object.(   R   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   names_object.  s    c         C   s   t  S(   s8   Returns True if this URI represents input/output stream.(   RO   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt	   is_stream2  s    R@   c         C   sa   |  j  d ƒ |  j ƒ  } |  j d k rD | j |  j | | | | ƒ S| j |  j | | | ƒ Sd  S(   Ns   create_bucket R"   (   R   R6   R-   t   create_bucketR   (   R   R=   t   locationt   policyR€   RK   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR–   6  s    c         C   s,   |  j  d ƒ |  j ƒ  } | j |  j | ƒ S(   Nt   delete_bucket(   R   R6   R™   R   (   R   R=   RK   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR™   B  s    c         C   s   |  j  ƒ  } | j | ƒ S(   N(   R6   t   get_all_buckets(   R   R=   RK   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRš   G  s    c         C   s/   |  j  ƒ  } | j } |  j | d |  j ƒ | S(   NR[   (   R6   R[   R   R   (   R   RK   R[   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRn   K  s    	c   	   
   C   s‘   |  j  d ƒ | p |  j p d } |  j | | ƒ } |  j rh | j | | | d |  j d | d | ƒn% | pt |  j } | j | | | | ƒ d S(   s   Sets or updates a bucket's ACL.t   set_aclR@   R8   t   if_generationt   if_metagenerationN(   R   R   R;   R8   R›   R7   (	   R   t
   acl_or_strRv   R<   R=   R7   Rœ   R   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR›   Q  s    	c   	   
   C   s”   |  j  d ƒ | p |  j p d } |  j | | ƒ } |  j rh | j | | | d |  j d | d | ƒn( | pt |  j } | j | | | d | ƒd S(   s2   Sets or updates a bucket's ACL with an XML string.t   set_xml_aclR@   R8   Rœ   R   R7   N(   R   R   R;   R8   RŸ   R7   (	   R   t	   xmlstringRv   R<   R=   R7   Rœ   R   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRŸ   _  s    	c         C   s-   |  j  d ƒ |  j | | ƒ j | | ƒ d S(   sA   Sets or updates a bucket's default object ACL with an XML string.t   set_def_xml_aclN(   R   R;   R¡   (   R   R    R<   R=   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR¡   n  s    c         C   s-   |  j  d ƒ |  j | | ƒ j | | ƒ d S(   s.   Sets or updates a bucket's default object ACL.t   set_def_aclN(   R   R;   R¢   (   R   Rž   R<   R=   R7   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR¢   s  s    c         C   s\   |  j  d ƒ |  j d d | ƒ|  j | | ƒ } |  j | d |  j ƒ | j | | ƒ d S(   s>   Sets or updates a bucket's acl to a predefined (canned) value.t   set_canned_aclR7   RM   N(   R   R   RL   R   R   R£   (   R   t   acl_strR<   R=   R7   RM   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR£   y  s
    c         C   sL   |  j  d ƒ |  j | | ƒ } |  j | d |  j ƒ | j | | | ƒ d S(   sX   Sets or updates a bucket's default object acl to a predefined
           (canned) value.s   set_def_canned_acl RM   N(   R   RL   R   R   t   set_def_canned_acl(   R   R¤   R<   R=   R7   RM   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR¥   ‚  s    c         C   s?   |  j  d ƒ |  j | | ƒ } | j | | |  j | | ƒ d  S(   Nt   set_subresource(   R   R;   R¦   R   (   R   R‚   t   valueR<   R=   R7   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR¦   ‹  s    i
   c	      	   C   s    |  j  d ƒ |  j d | ƒ }	 |  j d k rk | rG t j j d ƒ n  |	 j | | | | | | | ƒ }
 n$ |	 j | | | | | | | | ƒ }
 |  j |	 ƒ |
 S(   Nt   set_contents_from_stringR=   R"   s^   Warning: GCS does not support reduced_redundancy; argument ignored by set_contents_from_string(   R   RN   R-   R   R   R   R¨   Rk   (   R   t   sR=   t   replaceRT   RU   R˜   Rh   t   reduced_redundancyRM   t   result(    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR¨   ’  s    	c         C   s×   |  j  d ƒ |  j d | ƒ } |  j d k r† | j | | | | | | | d | d |	 d |
 ƒ} |
 rÆ |  j d  |
 j d  | ƒ qÆ n@ |  j d d |
 ƒ| j | | | | | | | d | d |	 ƒ} |  j | ƒ | S(   Nt   set_contents_from_fileR=   R"   t   sizet   rewindt   res_upload_handler(	   R   RN   R-   R­   Ri   R	   R8   R   Rk   (   R   RQ   R=   Rª   RT   RU   R˜   Rh   R®   R¯   R°   RM   R¬   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR­   ¥  s     	c   	   	   C   sT   |  j  d ƒ |  j t | ƒ } | j | | | | d | d | ƒ} |  j | ƒ | S(   Nt   set_contents_from_streamR˜   R«   (   R   RN   RO   R±   Rk   (	   R   RQ   R=   Rª   RT   R˜   R«   t   dst_keyR¬   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR±   º  s    	t   STANDARDc         C   sÁ   |  j  d ƒ |  j d t d | ƒ } |
 rt | j d |  j d | d | d | d | d	 | d
 | d | d |	 d |
 ƒ 
S| j d |  j d | d | d | d | d | d	 | d
 | d | d |	 ƒ 
Sd S(   s   Returns newly created key.t   copy_keyR<   R=   t   new_key_namet   src_bucket_namet   src_key_namet   metadataR€   t   preserve_aclt   encrypt_keyt
   query_argst   src_generationt   src_version_idN(   R   R;   RO   R´   R   (   R   R¶   R·   R¸   R½   R€   R¹   Rº   R=   R»   R¼   t
   dst_bucket(    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR´   Ä  s     				c         C   s9   |  j  d ƒ |  j | | ƒ } | j | | d | ƒd  S(   Nt   enable_loggingR=   (   R   R;   R¿   (   R   t   target_buckett   target_prefixR<   R=   R7   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR¿   Û  s    c         C   s3   |  j  d ƒ |  j | | ƒ } | j d | ƒ d  S(   Nt   disable_loggingR=   (   R   R;   RÂ   (   R   R<   R=   R7   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRÂ   á  s    c         C   s/   |  j  d ƒ |  j | | ƒ } | j d | ƒ S(   Nt   get_logging_configR=   (   R   R;   RÃ   (   R   R<   R=   R7   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRÃ   æ  s    c         C   sR   |  j  d ƒ |  j | | ƒ } | p( | s; | j | ƒ n | j | | | ƒ d  S(   Nt   set_website_config(   R   R;   t   delete_website_configurationt   configure_website(   R   t   main_page_suffixt	   error_keyR<   R=   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRÄ   ë  s
    c         C   s,   |  j  d ƒ |  j | | ƒ } | j | ƒ S(   Nt   get_website_config(   R   R;   t   get_website_configuration(   R   R<   R=   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRÉ   ô  s    c         C   s,   |  j  d ƒ |  j t | ƒ } | j | ƒ S(   Nt   get_versioning_config(   R   R;   RO   t   get_versioning_status(   R   R=   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRË   ù  s    c         C   s/   |  j  d ƒ |  j t | ƒ } | j | | ƒ S(   Nt   configure_versioning(   R   R;   RO   RÍ   (   R   t   enabledR=   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRÍ   þ  s    c         C   s"   |  j  t ƒ j | | | d | ƒS(   NR=   (   RL   RO   t   set_remote_metadata(   R   t   metadata_plust   metadata_minusR¹   R=   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   set_metadata  s    c         C   sy   |  j  d ƒ g  } x1 | D]) } | j | j ƒ  ƒ | j | d _ q W|  j ƒ  j | d | d | ƒ|  _ |  j ƒ  |  S(   Nt   composeiÿÿÿÿt   content_typeR=   (   R   t   appendRN   R8   RÓ   Re   (   R   t
   componentsRÔ   R=   t   component_keyst   suri(    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRÓ   
  s    
c         C   sH   |  j  d ƒ |  j | | ƒ } | j | ƒ } |  j | d |  j ƒ | S(   s+   Returns a bucket's lifecycle configuration.t   get_lifecycle_configt	   lifecycle(   R   R;   RÙ   R   R   (   R   R<   R=   R?   t   lifecycle_config(    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRÙ     s
    c         C   s3   |  j  d ƒ |  j | | ƒ } | j | | ƒ d S(   s3   Sets or updates a bucket's lifecycle configuration.t   configure_lifecycleN(   R   R;   RÜ   (   R   RÛ   R<   R=   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRÜ     s    c         C   sQ   |  j  d ƒ |  j d k r2 t d |  j ƒ ‚ n  |  j t | ƒ } | j | ƒ S(   Nt   get_billing_configR"   s/   get_billing_config() not supported for %s URIs.(   R   R-   R~   R;   RO   RÝ   (   R   R=   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRÝ   $  s    c         C   s^   |  j  d ƒ |  j d k r2 t d |  j ƒ ‚ n  |  j | | ƒ } | j d | d | ƒ d S(   s1   Sets or updates a bucket's billing configuration.t   configure_billingR"   s.   configure_billing() not supported for %s URIs.t   requester_paysR=   N(   R   R-   R~   R;   RÞ   (   R   Rß   R<   R=   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRÞ   -  s    c         C   sT   |  j  d ƒ |  j d k r2 t d |  j ƒ ‚ n  |  j | | ƒ } | j d | ƒ S(   s0   Returns a GCS bucket's encryption configuration.t   get_encryption_configR"   s2   get_encryption_config() not supported for %s URIs.R=   (   R   R-   R~   R;   Rà   (   R   R<   R=   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRà   8  s    c         C   s9   |  j  d ƒ |  j | | ƒ } | j d | d | ƒ d S(   s-   Sets a GCS bucket's encryption configuration.t   set_encryption_configt   default_kms_key_nameR=   N(   R   R;   Rá   (   R   Râ   R<   R=   R?   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRá   C  s    c         C   sP   |  j  s t d |  j ƒ ‚ n  |  j | ƒ } | j |  j  d | ƒ} t | ƒ S(   s8   Returns True if the object exists or False if it doesn'ts   exists on object-less URI (%s)R=   (   R   R   R   R;   RL   Rc   (   R   R=   R?   RM   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   existsK  s
    	N(F   R]   R^   R_   t   delimt   sett   capabilitiesR	   RŒ   RO   R   Re   Rk   Ri   RL   R:   Rp   Rr   Rt   Rw   Rx   Rz   R|   R}   R   R   Rƒ   R‡   Rˆ   RŠ   R‹   R   RŽ   R   R   R‘   R’   R“   R”   R•   R–   R™   Rš   Rn   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ã   (    (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR   ó   s¶   	/							

																			
t   FileStorageUric           B   s›   e  Z d  Z e j Z e d „ Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d d „ Z RS(   sã   
    StorageUri subclass that handles files in the local file system.
    Callers should instantiate this class by calling boto.storage_uri().

    See file/README about how we map StorageUri operations onto a file system.
    c         C   s>   d |  _  d |  _ | |  _ d | |  _ | |  _ | |  _ d S(   s™  Instantiate a FileStorageUri from a path name.

        @type object_name: string
        @param object_name: object name
        @type debug: boolean
        @param debug: whether to enable debugging on this StorageUri

        After instantiation the components are available in the following
        fields: uri, scheme, bucket_name (always blank for this "anonymous"
        bucket), object_name.
        R&   R@   s   file://N(   R-   R   R   R   R2   t   stream(   R   R   R2   R•   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR   ^  s    				c         C   s   t  | |  j |  j ƒ S(   s¶   Instantiate a FileStorageUri from the current FileStorageUri,
        but replacing the object_name.

        @type new_name: string
        @param new_name: new object name
        (   Rç   R2   Rè   (   R   Rq   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRp   r  s    c         C   s   t  S(   s3   Returns True if this URI names a file or directory.(   RŒ   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR‹   {  s    c         C   s   t  S(   s2   Returns True if this URI names a bucket or object.(   RO   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR     s    c         C   s
   |  j  ƒ  S(   s5   Returns True if this URI names a directory or bucket.(   R   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRŽ   ƒ  s    c         C   s   |  j  ƒ  S(   s<   Returns True if this URI names a file (or stream) or object.(   RŽ   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR   ‡  s    c         C   s    |  j  r t St j j |  j ƒ S(   s+   Returns True if this URI names a directory.(   Rè   RO   t   ost   patht   isdirR   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR   ‹  s    	c         C   s   t  S(   s*   Returns True if this URI names a provider.(   RO   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR‘   ‘  s    c         C   s   t  S(   s(   Returns True if this URI names a bucket.(   RO   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR’   •  s    c         C   s
   |  j  ƒ  S(   s&   Returns True if this URI names a file.(   R   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR“   ™  s    c         C   s   t  S(   s)   Returns True if this URI names an object.(   RO   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR”     s    c         C   s   t  |  j ƒ S(   sA   Returns True if this URI represents input/output stream.
        (   Rc   Rè   (   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyR•   ¡  s    c         C   s   |  j  ƒ  j ƒ  d S(   s$   Closes the underlying file.
        N(   RL   t   close(   R   (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRì   ¦  s    c         C   s   t  j j |  j ƒ S(   s6   Returns True if the file exists or False if it doesn't(   Ré   Rê   Rã   R   (   R   t   _headers_not_used(    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRã   «  s    N(   R]   R^   R_   Ré   t   sepRä   RO   R   Rp   R‹   R   RŽ   R   R   R‘   R’   R“   R”   R•   Rì   R	   Rã   (    (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyRç   T  s    														(   t   botoRé   R   R   t   boto.s3.deletemarkerR    t   boto.exceptionR   R   t   objectR   R   Rç   (    (    (    s/   lib/python2.7/site-packages/boto/storage_uri.pyt   <module>   s   Óÿ ÿ c