ó FRTc@sªddlZddlZddlZddlZddlmZddlmZddlm Z ddl m Z ddl mZddl mZde fd „ƒYZ dS( iÿÿÿÿN(tStringIO(tBotoClientError(tKey(tKeyFile(t compute_hash(tget_utf8_valueRc BsâeZdZdddd„Zd„Zd„Zed„Zd„Z d„Z ddddd„Z ddd eddddd „Z ddd eddddd „Z dd „Zddd deddd „Zdd„Zd„Zd„Zdd„Zd„Zdedd ddddedd„ Zdedd dddddd„ Zdedd dddd„Zd„Zddddd„Zddd„Zddd„Zddddd„Zddddd„Zddd„ZRS(sÈ Represents a key (object) in a GS bucket. :ivar bucket: The parent :class:`boto.gs.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 GS. :ivar owner: The ID of the owner of this object. :ivar storage_class: The storage class of the object. Currently, one of: STANDARD | DURABLE_REDUCED_AVAILABILITY. :ivar md5: The MD5 hash of the contents of the object. :ivar size: The size, in bytes, of the object. :ivar generation: The generation number of the object. :ivar metageneration: The generation number of the object metadata. :ivar encrypted: Whether the object is encrypted while at rest on the server. :ivar cloud_hashes: Dictionary of checksums as supplied by the storage provider. cCsGtt|ƒjd|d|ƒ||_d|_i|_d|_dS(Ntbuckettname(tsuperRt__init__t generationtNonetmeta_generationt cloud_hashestcomponent_count(tselfRRR ((s8/opt/freeware/lib/python2.7/site-packages/boto/gs/key.pyR As    cCsi|jr+|jr+d|j|jf}nd}|jrTd|jj|j|fSd|j|fSdS(Ns#%s.%stss(R tmetagenerationRR(Rtver_str((s8/opt/freeware/lib/python2.7/site-packages/boto/gs/key.pyt__repr__Hs  cCs|dkr||_ný|dkr0||_nå|dkr`|dkrTt|_qt|_nµ|dkrx||_n|dkr–t|ƒ|_n|dkr®||_ng|dkr½nX|d krÕ||_ n@|d krí||_ n(|d kr||_ nt |||ƒdS( NRtETagtIsLatestttruet LastModifiedtSizet StorageClasstOwnert VersionIdt GenerationtMetaGeneration( RtetagtTruet is_latesttFalset last_modifiedtinttsizet storage_classt version_idR Rtsetattr(RRtvaluet connection((s8/opt/freeware/lib/python2.7/site-packages/boto/gs/key.pyt endElementRs.                    cCs.|jddƒ|_|jddƒ|_dS(Nsx-goog-metagenerationsx-goog-generation(t getheaderR RR (Rtresptforce((s8/opt/freeware/lib/python2.7/site-packages/boto/gs/key.pythandle_version_headersmscCsdS(N((Rtresponse((s8/opt/freeware/lib/python2.7/site-packages/boto/gs/key.pythandle_restore_headersqscCsäxÝ|D]Õ\}}|dkrpxº|jdƒD]:}|jƒjddƒ\}}tj|ƒ|j|  c CsYd|_d|_tt|ƒƒ} |j| ||||||d|ƒ} | jƒ| S(sA Store an object in GCS using the name of the Key object as the key in GCS 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 GCS 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.gs.acl.CannedACLStrings` :param policy: A canned ACL policy that will be applied to the new key in GCS. :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 if_generation: int :param if_generation: (optional) If set to a generation number, the object will only be written to if its current generation number is this value. If set to the value 0, the object will only be written if it doesn't already exist. R{N(R RsRtRRR}tclose( RtsR8RwRCRDRxRsR{RGtr((s8/opt/freeware/lib/python2.7/site-packages/boto/gs/key.pytset_contents_from_string‹s6     cOsj|jddƒ}|dk rM|jdiƒ}t|ƒ|d<||d%ss(%s%ss#%ss Content-TypetPUTR8R?tcomposetdataiÈi+sx-goog-generation(RRRR RvtappendtjoinR)t make_requestRtstatusRatstorage_response_errortreasontreadR+( Rt componentst content_typeR8t compose_reqR9tgeneration_tagtcompose_req_xmlR,((s8/opt/freeware/lib/python2.7/site-packages/boto/gs/key.pyR”‰s0       ! N( t__name__t __module__t__doc__R R RR*R!R.R0R=RBRIRKRRRRTRVR[R]R^RR}RƒR‡RŠRWRURRR’R”(((s8/opt/freeware/lib/python2.7/site-packages/boto/gs/key.pyR"sd        5    0        ¯  A  > @"(RoR5RdRmt boto.compatRtboto.exceptionRt boto.s3.keyRtS3Keytboto.s3.keyfileRt boto.utilsRR(((s8/opt/freeware/lib/python2.7/site-packages/boto/gs/key.pyts